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        ///
124        /// # Safety
125        ///
126        /// - `target` should be of the correct type.
127        /// - `action` must be a valid selector.
128        #[unsafe(method(comboButtonWithTitle:menu:target:action:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn comboButtonWithTitle_menu_target_action(
131            title: &NSString,
132            menu: Option<&NSMenu>,
133            target: Option<&AnyObject>,
134            action: Option<Sel>,
135            mtm: MainThreadMarker,
136        ) -> Retained<Self>;
137
138        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
139        /// Creates a standard combo button with a image, menu, and primary action.
140        ///
141        /// Parameter `image`: The image to display in the body of the button.
142        ///
143        /// Parameter `menu`: The additional menu to display on the button.
144        ///
145        /// Parameter `target`: The target object that receives primary action messages from the control.
146        ///
147        /// Parameter `action`: The action message sent by the primary action portion of the control.
148        ///
149        /// # Safety
150        ///
151        /// - `target` should be of the correct type.
152        /// - `action` must be a valid selector.
153        #[unsafe(method(comboButtonWithImage:menu:target:action:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn comboButtonWithImage_menu_target_action(
156            image: &NSImage,
157            menu: Option<&NSMenu>,
158            target: Option<&AnyObject>,
159            action: Option<Sel>,
160            mtm: MainThreadMarker,
161        ) -> Retained<Self>;
162
163        #[cfg(all(feature = "NSImage", feature = "NSMenu"))]
164        /// Creates a standard combo button with a title, image, menu, and primary action.
165        ///
166        /// Parameter `title`: The localized title string that is displayed on the button.
167        ///
168        /// Parameter `image`: The image to display in the body of the button.
169        ///
170        /// Parameter `menu`: The additional menu to display on the button.
171        ///
172        /// Parameter `target`: The target object that receives primary action messages from the control.
173        ///
174        /// Parameter `action`: The action message sent by the primary action portion of the control.
175        ///
176        /// # Safety
177        ///
178        /// - `target` should be of the correct type.
179        /// - `action` must be a valid selector.
180        #[unsafe(method(comboButtonWithTitle:image:menu:target:action:))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn comboButtonWithTitle_image_menu_target_action(
183            title: &NSString,
184            image: &NSImage,
185            menu: Option<&NSMenu>,
186            target: Option<&AnyObject>,
187            action: Option<Sel>,
188            mtm: MainThreadMarker,
189        ) -> Retained<Self>;
190
191        /// The title displayed on the control. The default value is an empty string.
192        #[unsafe(method(title))]
193        #[unsafe(method_family = none)]
194        pub fn title(&self) -> Retained<NSString>;
195
196        /// Setter for [`title`][Self::title].
197        ///
198        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
199        #[unsafe(method(setTitle:))]
200        #[unsafe(method_family = none)]
201        pub fn setTitle(&self, title: &NSString);
202
203        #[cfg(feature = "NSImage")]
204        /// The image displayed on the control. The default value is `nil`.
205        #[unsafe(method(image))]
206        #[unsafe(method_family = none)]
207        pub fn image(&self) -> Option<Retained<NSImage>>;
208
209        #[cfg(feature = "NSImage")]
210        /// Setter for [`image`][Self::image].
211        #[unsafe(method(setImage:))]
212        #[unsafe(method_family = none)]
213        pub fn setImage(&self, image: Option<&NSImage>);
214
215        #[cfg(feature = "NSCell")]
216        /// The scaling mode applied to fit the button's image within the content area. The default value is `NSImageScaleProportionallyDown`.
217        #[unsafe(method(imageScaling))]
218        #[unsafe(method_family = none)]
219        pub fn imageScaling(&self) -> NSImageScaling;
220
221        #[cfg(feature = "NSCell")]
222        /// Setter for [`imageScaling`][Self::imageScaling].
223        #[unsafe(method(setImageScaling:))]
224        #[unsafe(method_family = none)]
225        pub fn setImageScaling(&self, image_scaling: NSImageScaling);
226
227        #[cfg(feature = "NSMenu")]
228        /// 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.
229        #[unsafe(method(menu))]
230        #[unsafe(method_family = none)]
231        pub fn menu(&self) -> Retained<NSMenu>;
232
233        #[cfg(feature = "NSMenu")]
234        /// Setter for [`menu`][Self::menu].
235        #[unsafe(method(setMenu:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn setMenu(&self, menu: &NSMenu);
238
239        /// Specifies the visual presentation and behavior for NSComboButton's primary action and its menu. The default value is `NSComboButtonStyleSplit`.
240        #[unsafe(method(style))]
241        #[unsafe(method_family = none)]
242        pub fn style(&self) -> NSComboButtonStyle;
243
244        /// Setter for [`style`][Self::style].
245        #[unsafe(method(setStyle:))]
246        #[unsafe(method_family = none)]
247        pub fn setStyle(&self, style: NSComboButtonStyle);
248    );
249}
250
251/// Methods declared on superclass `NSControl`.
252#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
253impl NSComboButton {
254    extern_methods!(
255        #[unsafe(method(initWithFrame:))]
256        #[unsafe(method_family = init)]
257        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
258
259        /// # Safety
260        ///
261        /// `coder` possibly has further requirements.
262        #[unsafe(method(initWithCoder:))]
263        #[unsafe(method_family = init)]
264        pub unsafe fn initWithCoder(
265            this: Allocated<Self>,
266            coder: &NSCoder,
267        ) -> Option<Retained<Self>>;
268    );
269}
270
271/// Methods declared on superclass `NSResponder`.
272#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
273impl NSComboButton {
274    extern_methods!(
275        #[unsafe(method(init))]
276        #[unsafe(method_family = init)]
277        pub fn init(this: Allocated<Self>) -> Retained<Self>;
278    );
279}
280
281/// Methods declared on superclass `NSObject`.
282#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
283impl NSComboButton {
284    extern_methods!(
285        #[unsafe(method(new))]
286        #[unsafe(method_family = new)]
287        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
288    );
289}