objc2_app_kit/generated/
NSComboButton.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscombobuttonstyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSComboButtonStyle(pub NSInteger);
15impl NSComboButtonStyle {
16    /// The button will be split across 2 segments. The leading segment shows `title`, `image`, or both. If `action` is set, it will be performed when the leading segment is clicked. If `action` is `nil`, the leading segment will be disabled. The trailing segment shows a menu indicator. If `menu` is set, clicking the trailing segment will show it. If `menu` is empty, the trailing segment will be disabled.
17    #[doc(alias = "NSComboButtonStyleSplit")]
18    pub const Split: Self = Self(0);
19    /// The button will be unified in a single segment. If `action` is set, `menu` will appear on click and hold. If `action` is `nil`, then `menu` will appear on click.
20    #[doc(alias = "NSComboButtonStyleUnified")]
21    pub const Unified: Self = Self(1);
22}
23
24unsafe impl Encode for NSComboButtonStyle {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSComboButtonStyle {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscombobutton?language=objc)
34    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
37    pub struct NSComboButton;
38);
39
40#[cfg(all(
41    feature = "NSAccessibilityProtocols",
42    feature = "NSControl",
43    feature = "NSResponder",
44    feature = "NSView"
45))]
46extern_conformance!(
47    unsafe impl NSAccessibility for NSComboButton {}
48);
49
50#[cfg(all(
51    feature = "NSAccessibilityProtocols",
52    feature = "NSControl",
53    feature = "NSResponder",
54    feature = "NSView"
55))]
56extern_conformance!(
57    unsafe impl NSAccessibilityElementProtocol for NSComboButton {}
58);
59
60#[cfg(all(
61    feature = "NSAnimation",
62    feature = "NSControl",
63    feature = "NSResponder",
64    feature = "NSView"
65))]
66extern_conformance!(
67    unsafe impl NSAnimatablePropertyContainer for NSComboButton {}
68);
69
70#[cfg(all(
71    feature = "NSAppearance",
72    feature = "NSControl",
73    feature = "NSResponder",
74    feature = "NSView"
75))]
76extern_conformance!(
77    unsafe impl NSAppearanceCustomization for NSComboButton {}
78);
79
80#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
81extern_conformance!(
82    unsafe impl NSCoding for NSComboButton {}
83);
84
85#[cfg(all(
86    feature = "NSControl",
87    feature = "NSDragging",
88    feature = "NSResponder",
89    feature = "NSView"
90))]
91extern_conformance!(
92    unsafe impl NSDraggingDestination for NSComboButton {}
93);
94
95#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
96extern_conformance!(
97    unsafe impl NSObjectProtocol for NSComboButton {}
98);
99
100#[cfg(all(
101    feature = "NSControl",
102    feature = "NSResponder",
103    feature = "NSUserInterfaceItemIdentification",
104    feature = "NSView"
105))]
106extern_conformance!(
107    unsafe impl NSUserInterfaceItemIdentification for NSComboButton {}
108);
109
110#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
111impl NSComboButton {
112    extern_methods!(
113        #[cfg(feature = "NSMenu")]
114        /// Creates a standard combo button with a title, menu, and primary action.
115        ///
116        /// Parameter `title`: The localized title string that is displayed on the button.
117        ///
118        /// Parameter `menu`: The additional menu to display on the button.
119        ///
120        /// Parameter `target`: The target object that receives primary action messages from the control.
121        ///
122        /// Parameter `action`: The action message sent by the primary action portion of the control.
123        #[unsafe(method(comboButtonWithTitle:menu:target:action:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn comboButtonWithTitle_menu_target_action(
126            title: &NSString,
127            menu: Option<&NSMenu>,
128            target: Option<&AnyObject>,
129            action: Option<Sel>,
130            mtm: MainThreadMarker,
131        ) -> Retained<Self>;
132
133        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
134        /// Creates a standard combo button with a image, menu, and primary action.
135        ///
136        /// Parameter `image`: The image to display in the body of the button.
137        ///
138        /// Parameter `menu`: The additional menu to display on the button.
139        ///
140        /// Parameter `target`: The target object that receives primary action messages from the control.
141        ///
142        /// Parameter `action`: The action message sent by the primary action portion of the control.
143        #[unsafe(method(comboButtonWithImage:menu:target:action:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn comboButtonWithImage_menu_target_action(
146            image: &NSImage,
147            menu: Option<&NSMenu>,
148            target: Option<&AnyObject>,
149            action: Option<Sel>,
150            mtm: MainThreadMarker,
151        ) -> Retained<Self>;
152
153        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
154        /// Creates a standard combo button with a title, image, menu, and primary action.
155        ///
156        /// Parameter `title`: The localized title string that is displayed on the button.
157        ///
158        /// Parameter `image`: The image to display in the body of the button.
159        ///
160        /// Parameter `menu`: The additional menu to display on the button.
161        ///
162        /// Parameter `target`: The target object that receives primary action messages from the control.
163        ///
164        /// Parameter `action`: The action message sent by the primary action portion of the control.
165        #[unsafe(method(comboButtonWithTitle:image:menu:target:action:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn comboButtonWithTitle_image_menu_target_action(
168            title: &NSString,
169            image: &NSImage,
170            menu: Option<&NSMenu>,
171            target: Option<&AnyObject>,
172            action: Option<Sel>,
173            mtm: MainThreadMarker,
174        ) -> Retained<Self>;
175
176        /// The title displayed on the control. The default value is an empty string.
177        #[unsafe(method(title))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn title(&self) -> Retained<NSString>;
180
181        /// Setter for [`title`][Self::title].
182        #[unsafe(method(setTitle:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setTitle(&self, title: &NSString);
185
186        #[cfg(feature = "NSImage")]
187        /// The image displayed on the control. The default value is `nil`.
188        #[unsafe(method(image))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
191
192        #[cfg(feature = "NSImage")]
193        /// Setter for [`image`][Self::image].
194        #[unsafe(method(setImage:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setImage(&self, image: Option<&NSImage>);
197
198        #[cfg(feature = "NSCell")]
199        /// The scaling mode applied to fit the button's image within the content area. The default value is `NSImageScaleProportionallyDown`.
200        #[unsafe(method(imageScaling))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn imageScaling(&self) -> NSImageScaling;
203
204        #[cfg(feature = "NSCell")]
205        /// Setter for [`imageScaling`][Self::imageScaling].
206        #[unsafe(method(setImageScaling:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
209
210        #[cfg(feature = "NSMenu")]
211        /// Overrides behavior of NSResponder menu. This menu is shown when interacting with the button (see NSComboButtonStyle). NSComboButton does not have a context menu. Items in this menu specify their own target and action independent of the primary action that is configured on the control.
212        #[unsafe(method(menu))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn menu(&self) -> Retained<NSMenu>;
215
216        #[cfg(feature = "NSMenu")]
217        /// Setter for [`menu`][Self::menu].
218        #[unsafe(method(setMenu:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn setMenu(&self, menu: &NSMenu);
221
222        /// Specifies the visual presentation and behavior for NSComboButton's primary action and its menu. The default value is `NSComboButtonStyleSplit`.
223        #[unsafe(method(style))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn style(&self) -> NSComboButtonStyle;
226
227        /// Setter for [`style`][Self::style].
228        #[unsafe(method(setStyle:))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn setStyle(&self, style: NSComboButtonStyle);
231    );
232}
233
234/// Methods declared on superclass `NSControl`.
235#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
236impl NSComboButton {
237    extern_methods!(
238        #[unsafe(method(initWithFrame:))]
239        #[unsafe(method_family = init)]
240        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
241
242        #[unsafe(method(initWithCoder:))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn initWithCoder(
245            this: Allocated<Self>,
246            coder: &NSCoder,
247        ) -> Option<Retained<Self>>;
248    );
249}
250
251/// Methods declared on superclass `NSResponder`.
252#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
253impl NSComboButton {
254    extern_methods!(
255        #[unsafe(method(init))]
256        #[unsafe(method_family = init)]
257        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
258    );
259}
260
261/// Methods declared on superclass `NSObject`.
262#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
263impl NSComboButton {
264    extern_methods!(
265        #[unsafe(method(new))]
266        #[unsafe(method_family = new)]
267        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
268    );
269}