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))]
46unsafe impl NSAccessibility for NSComboButton {}
47
48#[cfg(all(
49    feature = "NSAccessibilityProtocols",
50    feature = "NSControl",
51    feature = "NSResponder",
52    feature = "NSView"
53))]
54unsafe impl NSAccessibilityElementProtocol for NSComboButton {}
55
56#[cfg(all(
57    feature = "NSAnimation",
58    feature = "NSControl",
59    feature = "NSResponder",
60    feature = "NSView"
61))]
62unsafe impl NSAnimatablePropertyContainer for NSComboButton {}
63
64#[cfg(all(
65    feature = "NSAppearance",
66    feature = "NSControl",
67    feature = "NSResponder",
68    feature = "NSView"
69))]
70unsafe impl NSAppearanceCustomization for NSComboButton {}
71
72#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
73unsafe impl NSCoding for NSComboButton {}
74
75#[cfg(all(
76    feature = "NSControl",
77    feature = "NSDragging",
78    feature = "NSResponder",
79    feature = "NSView"
80))]
81unsafe impl NSDraggingDestination for NSComboButton {}
82
83#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
84unsafe impl NSObjectProtocol for NSComboButton {}
85
86#[cfg(all(
87    feature = "NSControl",
88    feature = "NSResponder",
89    feature = "NSUserInterfaceItemIdentification",
90    feature = "NSView"
91))]
92unsafe impl NSUserInterfaceItemIdentification for NSComboButton {}
93
94#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
95impl NSComboButton {
96    extern_methods!(
97        #[cfg(feature = "NSMenu")]
98        /// Creates a standard combo button with a title, menu, and primary action.
99        ///
100        /// Parameter `title`: The localized title string that is displayed on the button.
101        ///
102        /// Parameter `menu`: The additional menu to display on the button.
103        ///
104        /// Parameter `target`: The target object that receives primary action messages from the control.
105        ///
106        /// Parameter `action`: The action message sent by the primary action portion of the control.
107        #[unsafe(method(comboButtonWithTitle:menu:target:action:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn comboButtonWithTitle_menu_target_action(
110            title: &NSString,
111            menu: Option<&NSMenu>,
112            target: Option<&AnyObject>,
113            action: Option<Sel>,
114            mtm: MainThreadMarker,
115        ) -> Retained<Self>;
116
117        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
118        /// Creates a standard combo button with a image, menu, and primary action.
119        ///
120        /// Parameter `image`: The image to display in the body of the button.
121        ///
122        /// Parameter `menu`: The additional menu to display on the button.
123        ///
124        /// Parameter `target`: The target object that receives primary action messages from the control.
125        ///
126        /// Parameter `action`: The action message sent by the primary action portion of the control.
127        #[unsafe(method(comboButtonWithImage:menu:target:action:))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn comboButtonWithImage_menu_target_action(
130            image: &NSImage,
131            menu: Option<&NSMenu>,
132            target: Option<&AnyObject>,
133            action: Option<Sel>,
134            mtm: MainThreadMarker,
135        ) -> Retained<Self>;
136
137        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
138        /// Creates a standard combo button with a title, image, menu, and primary action.
139        ///
140        /// Parameter `title`: The localized title string that is displayed on the button.
141        ///
142        /// Parameter `image`: The image to display in the body of the button.
143        ///
144        /// Parameter `menu`: The additional menu to display on the button.
145        ///
146        /// Parameter `target`: The target object that receives primary action messages from the control.
147        ///
148        /// Parameter `action`: The action message sent by the primary action portion of the control.
149        #[unsafe(method(comboButtonWithTitle:image:menu:target:action:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn comboButtonWithTitle_image_menu_target_action(
152            title: &NSString,
153            image: &NSImage,
154            menu: Option<&NSMenu>,
155            target: Option<&AnyObject>,
156            action: Option<Sel>,
157            mtm: MainThreadMarker,
158        ) -> Retained<Self>;
159
160        /// The title displayed on the control. The default value is an empty string.
161        #[unsafe(method(title))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn title(&self) -> Retained<NSString>;
164
165        /// Setter for [`title`][Self::title].
166        #[unsafe(method(setTitle:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setTitle(&self, title: &NSString);
169
170        #[cfg(feature = "NSImage")]
171        /// The image displayed on the control. The default value is `nil`.
172        #[unsafe(method(image))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
175
176        #[cfg(feature = "NSImage")]
177        /// Setter for [`image`][Self::image].
178        #[unsafe(method(setImage:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setImage(&self, image: Option<&NSImage>);
181
182        #[cfg(feature = "NSCell")]
183        /// The scaling mode applied to fit the button's image within the content area. The default value is `NSImageScaleProportionallyDown`.
184        #[unsafe(method(imageScaling))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn imageScaling(&self) -> NSImageScaling;
187
188        #[cfg(feature = "NSCell")]
189        /// Setter for [`imageScaling`][Self::imageScaling].
190        #[unsafe(method(setImageScaling:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
193
194        #[cfg(feature = "NSMenu")]
195        /// 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.
196        #[unsafe(method(menu))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn menu(&self) -> Retained<NSMenu>;
199
200        #[cfg(feature = "NSMenu")]
201        /// Setter for [`menu`][Self::menu].
202        #[unsafe(method(setMenu:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setMenu(&self, menu: &NSMenu);
205
206        /// Specifies the visual presentation and behavior for NSComboButton's primary action and its menu. The default value is `NSComboButtonStyleSplit`.
207        #[unsafe(method(style))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn style(&self) -> NSComboButtonStyle;
210
211        /// Setter for [`style`][Self::style].
212        #[unsafe(method(setStyle:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn setStyle(&self, style: NSComboButtonStyle);
215    );
216}
217
218/// Methods declared on superclass `NSControl`.
219#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
220impl NSComboButton {
221    extern_methods!(
222        #[unsafe(method(initWithFrame:))]
223        #[unsafe(method_family = init)]
224        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
225
226        #[unsafe(method(initWithCoder:))]
227        #[unsafe(method_family = init)]
228        pub unsafe fn initWithCoder(
229            this: Allocated<Self>,
230            coder: &NSCoder,
231        ) -> Option<Retained<Self>>;
232    );
233}
234
235/// Methods declared on superclass `NSResponder`.
236#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
237impl NSComboButton {
238    extern_methods!(
239        #[unsafe(method(init))]
240        #[unsafe(method_family = init)]
241        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
242    );
243}
244
245/// Methods declared on superclass `NSObject`.
246#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
247impl NSComboButton {
248    extern_methods!(
249        #[unsafe(method(new))]
250        #[unsafe(method_family = new)]
251        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
252    );
253}