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 fn appearsDisabled(&self) -> bool;
157
158        /// Setter for [`appearsDisabled`][Self::appearsDisabled].
159        #[unsafe(method(setAppearsDisabled:))]
160        #[unsafe(method_family = none)]
161        pub 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        ///
187        /// # Safety
188        ///
189        /// - `target` should be of the correct type.
190        /// - `action` must be a valid selector.
191        #[unsafe(method(buttonWithTitle:image:target:action:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn buttonWithTitle_image_target_action(
194            title: &NSString,
195            image: &NSImage,
196            target: Option<&AnyObject>,
197            action: Option<Sel>,
198            mtm: MainThreadMarker,
199        ) -> Retained<Self>;
200
201        /// Creates a standard push button with the provided title.
202        ///
203        /// Parameter `title`: The localized title string that is displayed on the button.
204        ///
205        /// Parameter `target`: The target object that receives action messages from the control.
206        ///
207        /// Parameter `action`: The action message sent by the control.
208        ///
209        /// Returns: An initialized button object.
210        ///
211        /// # Safety
212        ///
213        /// - `target` should be of the correct type.
214        /// - `action` must be a valid selector.
215        #[unsafe(method(buttonWithTitle:target:action:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn buttonWithTitle_target_action(
218            title: &NSString,
219            target: Option<&AnyObject>,
220            action: Option<Sel>,
221            mtm: MainThreadMarker,
222        ) -> Retained<Self>;
223
224        #[cfg(feature = "NSImage")]
225        /// Creates a standard push button with the provided image. Set the image's accessibilityDescription property to ensure accessibility for this control.
226        ///
227        /// Parameter `image`: The image to display in the body of the button.
228        ///
229        /// Parameter `target`: The target object that receives action messages from the control.
230        ///
231        /// Parameter `action`: The action message sent by the control.
232        ///
233        /// Returns: An initialized button object.
234        ///
235        /// # Safety
236        ///
237        /// - `target` should be of the correct type.
238        /// - `action` must be a valid selector.
239        #[unsafe(method(buttonWithImage:target:action:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn buttonWithImage_target_action(
242            image: &NSImage,
243            target: Option<&AnyObject>,
244            action: Option<Sel>,
245            mtm: MainThreadMarker,
246        ) -> Retained<Self>;
247
248        /// Creates a standard checkbox with the provided title.
249        ///
250        /// Parameter `title`: The localized title string that is displayed alongside the checkbox.
251        ///
252        /// Parameter `target`: The target object that receives action messages from the control.
253        ///
254        /// Parameter `action`: The action message sent by the control.
255        ///
256        /// Returns: An initialized button object.
257        ///
258        /// # Safety
259        ///
260        /// - `target` should be of the correct type.
261        /// - `action` must be a valid selector.
262        #[unsafe(method(checkboxWithTitle:target:action:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn checkboxWithTitle_target_action(
265            title: &NSString,
266            target: Option<&AnyObject>,
267            action: Option<Sel>,
268            mtm: MainThreadMarker,
269        ) -> Retained<Self>;
270
271        /// Creates a standard radio button with the provided title.
272        ///
273        /// Parameter `title`: The localized title string that is displayed alongside the radio button.
274        ///
275        /// Parameter `target`: The target object that receives action messages from the control.
276        ///
277        /// Parameter `action`: The action message sent by the control.
278        ///
279        /// Returns: An initialized button object.
280        ///
281        /// # Safety
282        ///
283        /// - `target` should be of the correct type.
284        /// - `action` must be a valid selector.
285        #[unsafe(method(radioButtonWithTitle:target:action:))]
286        #[unsafe(method_family = none)]
287        pub unsafe fn radioButtonWithTitle_target_action(
288            title: &NSString,
289            target: Option<&AnyObject>,
290            action: Option<Sel>,
291            mtm: MainThreadMarker,
292        ) -> Retained<Self>;
293    );
294}
295
296/// Methods declared on superclass `NSControl`.
297#[cfg(all(
298    feature = "NSButton",
299    feature = "NSControl",
300    feature = "NSResponder",
301    feature = "NSView"
302))]
303impl NSStatusBarButton {
304    extern_methods!(
305        #[unsafe(method(initWithFrame:))]
306        #[unsafe(method_family = init)]
307        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
308
309        /// # Safety
310        ///
311        /// `coder` possibly has further requirements.
312        #[unsafe(method(initWithCoder:))]
313        #[unsafe(method_family = init)]
314        pub unsafe fn initWithCoder(
315            this: Allocated<Self>,
316            coder: &NSCoder,
317        ) -> Option<Retained<Self>>;
318    );
319}
320
321/// Methods declared on superclass `NSResponder`.
322#[cfg(all(
323    feature = "NSButton",
324    feature = "NSControl",
325    feature = "NSResponder",
326    feature = "NSView"
327))]
328impl NSStatusBarButton {
329    extern_methods!(
330        #[unsafe(method(init))]
331        #[unsafe(method_family = init)]
332        pub fn init(this: Allocated<Self>) -> Retained<Self>;
333    );
334}
335
336/// Methods declared on superclass `NSObject`.
337#[cfg(all(
338    feature = "NSButton",
339    feature = "NSControl",
340    feature = "NSResponder",
341    feature = "NSView"
342))]
343impl NSStatusBarButton {
344    extern_methods!(
345        #[unsafe(method(new))]
346        #[unsafe(method_family = new)]
347        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
348    );
349}