objc2_app_kit/generated/
NSStatusBarButton.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
10extern_class!(
11    /// Status bar buttons are the visual representation of `NSStatusItem`s, and are primarily displayed on the right side of the menu bar.
12    /// When a template image is set as the `image` property of the status bar button, it is rendered with the correct menu bar style. This guarantees that the button will look correct in various button states and appearances (such as dark menu bar).
13    ///
14    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstatusbarbutton?language=objc)
15    #[unsafe(super(NSButton, NSControl, NSView, NSResponder, NSObject))]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(all(
18        feature = "NSButton",
19        feature = "NSControl",
20        feature = "NSResponder",
21        feature = "NSView"
22    ))]
23    pub struct NSStatusBarButton;
24);
25
26#[cfg(all(
27    feature = "NSAccessibilityProtocols",
28    feature = "NSButton",
29    feature = "NSControl",
30    feature = "NSResponder",
31    feature = "NSView"
32))]
33extern_conformance!(
34    unsafe impl NSAccessibility for NSStatusBarButton {}
35);
36
37#[cfg(all(
38    feature = "NSAccessibilityProtocols",
39    feature = "NSButton",
40    feature = "NSControl",
41    feature = "NSResponder",
42    feature = "NSView"
43))]
44extern_conformance!(
45    unsafe impl NSAccessibilityButton for NSStatusBarButton {}
46);
47
48#[cfg(all(
49    feature = "NSAccessibilityProtocols",
50    feature = "NSButton",
51    feature = "NSControl",
52    feature = "NSResponder",
53    feature = "NSView"
54))]
55extern_conformance!(
56    unsafe impl NSAccessibilityElementProtocol for NSStatusBarButton {}
57);
58
59#[cfg(all(
60    feature = "NSAnimation",
61    feature = "NSButton",
62    feature = "NSControl",
63    feature = "NSResponder",
64    feature = "NSView"
65))]
66extern_conformance!(
67    unsafe impl NSAnimatablePropertyContainer for NSStatusBarButton {}
68);
69
70#[cfg(all(
71    feature = "NSAppearance",
72    feature = "NSButton",
73    feature = "NSControl",
74    feature = "NSResponder",
75    feature = "NSView"
76))]
77extern_conformance!(
78    unsafe impl NSAppearanceCustomization for NSStatusBarButton {}
79);
80
81#[cfg(all(
82    feature = "NSButton",
83    feature = "NSControl",
84    feature = "NSResponder",
85    feature = "NSView"
86))]
87extern_conformance!(
88    unsafe impl NSCoding for NSStatusBarButton {}
89);
90
91#[cfg(all(
92    feature = "NSButton",
93    feature = "NSControl",
94    feature = "NSDragging",
95    feature = "NSResponder",
96    feature = "NSView"
97))]
98extern_conformance!(
99    unsafe impl NSDraggingDestination for NSStatusBarButton {}
100);
101
102#[cfg(all(
103    feature = "NSButton",
104    feature = "NSControl",
105    feature = "NSResponder",
106    feature = "NSView"
107))]
108extern_conformance!(
109    unsafe impl NSObjectProtocol for NSStatusBarButton {}
110);
111
112#[cfg(all(
113    feature = "NSButton",
114    feature = "NSControl",
115    feature = "NSResponder",
116    feature = "NSUserInterfaceCompression",
117    feature = "NSView"
118))]
119extern_conformance!(
120    unsafe impl NSUserInterfaceCompression for NSStatusBarButton {}
121);
122
123#[cfg(all(
124    feature = "NSButton",
125    feature = "NSControl",
126    feature = "NSResponder",
127    feature = "NSUserInterfaceItemIdentification",
128    feature = "NSView"
129))]
130extern_conformance!(
131    unsafe impl NSUserInterfaceItemIdentification for NSStatusBarButton {}
132);
133
134#[cfg(all(
135    feature = "NSButton",
136    feature = "NSControl",
137    feature = "NSResponder",
138    feature = "NSUserInterfaceValidation",
139    feature = "NSView"
140))]
141extern_conformance!(
142    unsafe impl NSUserInterfaceValidations for NSStatusBarButton {}
143);
144
145#[cfg(all(
146    feature = "NSButton",
147    feature = "NSControl",
148    feature = "NSResponder",
149    feature = "NSView"
150))]
151impl NSStatusBarButton {
152    extern_methods!(
153        /// If `YES`, the status bar icon has a disabled/off appearance while still being functional, such as allowing selection and actions. Defaults to `NO`.
154        #[unsafe(method(appearsDisabled))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn appearsDisabled(&self) -> bool;
157
158        /// Setter for [`appearsDisabled`][Self::appearsDisabled].
159        #[unsafe(method(setAppearsDisabled:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn setAppearsDisabled(&self, appears_disabled: bool);
162    );
163}
164
165/// Methods declared on superclass `NSButton`.
166#[cfg(all(
167    feature = "NSButton",
168    feature = "NSControl",
169    feature = "NSResponder",
170    feature = "NSView"
171))]
172impl NSStatusBarButton {
173    extern_methods!(
174        #[cfg(feature = "NSImage")]
175        /// Creates a standard push button with a title and image.
176        ///
177        /// Parameter `title`: The localized title string that is displayed on the button.
178        ///
179        /// Parameter `image`: The image that is displayed alongside the title. In left-to-right localizations, the image is displayed to the left of the title. In right-to-left localizations, it is displayed to the right.
180        ///
181        /// Parameter `target`: The target object that receives action messages from the control.
182        ///
183        /// Parameter `action`: The action message sent by the control.
184        ///
185        /// Returns: An initialized button object.
186        #[unsafe(method(buttonWithTitle:image:target:action:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn buttonWithTitle_image_target_action(
189            title: &NSString,
190            image: &NSImage,
191            target: Option<&AnyObject>,
192            action: Option<Sel>,
193            mtm: MainThreadMarker,
194        ) -> Retained<Self>;
195
196        /// Creates a standard push button with the provided title.
197        ///
198        /// Parameter `title`: The localized title string that is displayed on the button.
199        ///
200        /// Parameter `target`: The target object that receives action messages from the control.
201        ///
202        /// Parameter `action`: The action message sent by the control.
203        ///
204        /// Returns: An initialized button object.
205        #[unsafe(method(buttonWithTitle:target:action:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn buttonWithTitle_target_action(
208            title: &NSString,
209            target: Option<&AnyObject>,
210            action: Option<Sel>,
211            mtm: MainThreadMarker,
212        ) -> Retained<Self>;
213
214        #[cfg(feature = "NSImage")]
215        /// Creates a standard push button with the provided image. Set the image's accessibilityDescription property to ensure accessibility for this control.
216        ///
217        /// Parameter `image`: The image to display in the body of the button.
218        ///
219        /// Parameter `target`: The target object that receives action messages from the control.
220        ///
221        /// Parameter `action`: The action message sent by the control.
222        ///
223        /// Returns: An initialized button object.
224        #[unsafe(method(buttonWithImage:target:action:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn buttonWithImage_target_action(
227            image: &NSImage,
228            target: Option<&AnyObject>,
229            action: Option<Sel>,
230            mtm: MainThreadMarker,
231        ) -> Retained<Self>;
232
233        /// Creates a standard checkbox with the provided title.
234        ///
235        /// Parameter `title`: The localized title string that is displayed alongside the checkbox.
236        ///
237        /// Parameter `target`: The target object that receives action messages from the control.
238        ///
239        /// Parameter `action`: The action message sent by the control.
240        ///
241        /// Returns: An initialized button object.
242        #[unsafe(method(checkboxWithTitle:target:action:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn checkboxWithTitle_target_action(
245            title: &NSString,
246            target: Option<&AnyObject>,
247            action: Option<Sel>,
248            mtm: MainThreadMarker,
249        ) -> Retained<Self>;
250
251        /// Creates a standard radio button with the provided title.
252        ///
253        /// Parameter `title`: The localized title string that is displayed alongside the radio button.
254        ///
255        /// Parameter `target`: The target object that receives action messages from the control.
256        ///
257        /// Parameter `action`: The action message sent by the control.
258        ///
259        /// Returns: An initialized button object.
260        #[unsafe(method(radioButtonWithTitle:target:action:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn radioButtonWithTitle_target_action(
263            title: &NSString,
264            target: Option<&AnyObject>,
265            action: Option<Sel>,
266            mtm: MainThreadMarker,
267        ) -> Retained<Self>;
268    );
269}
270
271/// Methods declared on superclass `NSControl`.
272#[cfg(all(
273    feature = "NSButton",
274    feature = "NSControl",
275    feature = "NSResponder",
276    feature = "NSView"
277))]
278impl NSStatusBarButton {
279    extern_methods!(
280        #[unsafe(method(initWithFrame:))]
281        #[unsafe(method_family = init)]
282        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
283
284        #[unsafe(method(initWithCoder:))]
285        #[unsafe(method_family = init)]
286        pub unsafe fn initWithCoder(
287            this: Allocated<Self>,
288            coder: &NSCoder,
289        ) -> Option<Retained<Self>>;
290    );
291}
292
293/// Methods declared on superclass `NSResponder`.
294#[cfg(all(
295    feature = "NSButton",
296    feature = "NSControl",
297    feature = "NSResponder",
298    feature = "NSView"
299))]
300impl NSStatusBarButton {
301    extern_methods!(
302        #[unsafe(method(init))]
303        #[unsafe(method_family = init)]
304        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
305    );
306}
307
308/// Methods declared on superclass `NSObject`.
309#[cfg(all(
310    feature = "NSButton",
311    feature = "NSControl",
312    feature = "NSResponder",
313    feature = "NSView"
314))]
315impl NSStatusBarButton {
316    extern_methods!(
317        #[unsafe(method(new))]
318        #[unsafe(method_family = new)]
319        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
320    );
321}