objc2_app_kit/generated/
NSStatusItem.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstatusitemautosavename?language=objc)
13pub type NSStatusItemAutosaveName = NSString;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstatusitembehavior?language=objc)
16// NS_OPTIONS
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct NSStatusItemBehavior(pub NSUInteger);
20bitflags::bitflags! {
21    impl NSStatusItemBehavior: NSUInteger {
22        #[doc(alias = "NSStatusItemBehaviorRemovalAllowed")]
23        const RemovalAllowed = 1<<1;
24        #[doc(alias = "NSStatusItemBehaviorTerminationOnRemoval")]
25        const TerminationOnRemoval = 1<<2;
26    }
27}
28
29unsafe impl Encode for NSStatusItemBehavior {
30    const ENCODING: Encoding = NSUInteger::ENCODING;
31}
32
33unsafe impl RefEncode for NSStatusItemBehavior {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsstatusitem?language=objc)
39    #[unsafe(super(NSObject))]
40    #[derive(Debug, PartialEq, Eq, Hash)]
41    pub struct NSStatusItem;
42);
43
44extern_conformance!(
45    unsafe impl NSObjectProtocol for NSStatusItem {}
46);
47
48impl NSStatusItem {
49    extern_methods!(
50        #[cfg(feature = "NSStatusBar")]
51        #[unsafe(method(statusBar))]
52        #[unsafe(method_family = none)]
53        pub fn statusBar(&self) -> Option<Retained<NSStatusBar>>;
54
55        #[cfg(feature = "objc2-core-foundation")]
56        #[unsafe(method(length))]
57        #[unsafe(method_family = none)]
58        pub fn length(&self) -> CGFloat;
59
60        #[cfg(feature = "objc2-core-foundation")]
61        /// Setter for [`length`][Self::length].
62        #[unsafe(method(setLength:))]
63        #[unsafe(method_family = none)]
64        pub fn setLength(&self, length: CGFloat);
65
66        #[cfg(feature = "NSMenu")]
67        #[unsafe(method(menu))]
68        #[unsafe(method_family = none)]
69        pub fn menu(&self, mtm: MainThreadMarker) -> Option<Retained<NSMenu>>;
70
71        #[cfg(feature = "NSMenu")]
72        /// Setter for [`menu`][Self::menu].
73        #[unsafe(method(setMenu:))]
74        #[unsafe(method_family = none)]
75        pub fn setMenu(&self, menu: Option<&NSMenu>);
76
77        #[cfg(all(
78            feature = "NSButton",
79            feature = "NSControl",
80            feature = "NSResponder",
81            feature = "NSStatusBarButton",
82            feature = "NSView"
83        ))]
84        #[unsafe(method(button))]
85        #[unsafe(method_family = none)]
86        pub fn button(&self, mtm: MainThreadMarker) -> Option<Retained<NSStatusBarButton>>;
87
88        #[unsafe(method(behavior))]
89        #[unsafe(method_family = none)]
90        pub fn behavior(&self) -> NSStatusItemBehavior;
91
92        /// Setter for [`behavior`][Self::behavior].
93        #[unsafe(method(setBehavior:))]
94        #[unsafe(method_family = none)]
95        pub fn setBehavior(&self, behavior: NSStatusItemBehavior);
96
97        #[unsafe(method(isVisible))]
98        #[unsafe(method_family = none)]
99        pub fn isVisible(&self) -> bool;
100
101        /// Setter for [`isVisible`][Self::isVisible].
102        #[unsafe(method(setVisible:))]
103        #[unsafe(method_family = none)]
104        pub fn setVisible(&self, visible: bool);
105
106        #[unsafe(method(autosaveName))]
107        #[unsafe(method_family = none)]
108        pub fn autosaveName(&self) -> Retained<NSStatusItemAutosaveName>;
109
110        /// Setter for [`autosaveName`][Self::autosaveName].
111        ///
112        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
113        #[unsafe(method(setAutosaveName:))]
114        #[unsafe(method_family = none)]
115        pub fn setAutosaveName(&self, autosave_name: Option<&NSStatusItemAutosaveName>);
116    );
117}
118
119/// Methods declared on superclass `NSObject`.
120impl NSStatusItem {
121    extern_methods!(
122        #[unsafe(method(init))]
123        #[unsafe(method_family = init)]
124        pub fn init(this: Allocated<Self>) -> Retained<Self>;
125
126        #[unsafe(method(new))]
127        #[unsafe(method_family = new)]
128        pub fn new() -> Retained<Self>;
129    );
130}
131
132impl DefaultRetained for NSStatusItem {
133    #[inline]
134    fn default_retained() -> Retained<Self> {
135        Self::new()
136    }
137}
138
139/// NSStatusItemDeprecated.
140impl NSStatusItem {
141    extern_methods!(
142        #[deprecated = "Use the receiver's button.action instead"]
143        #[unsafe(method(action))]
144        #[unsafe(method_family = none)]
145        pub fn action(&self) -> Option<Sel>;
146
147        /// Setter for [`action`][Self::action].
148        ///
149        /// # Safety
150        ///
151        /// `action` must be a valid selector.
152        #[deprecated = "Use the receiver's button.action instead"]
153        #[unsafe(method(setAction:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn setAction(&self, action: Option<Sel>);
156
157        #[deprecated = "Use the receiver's button.doubleAction instead"]
158        #[unsafe(method(doubleAction))]
159        #[unsafe(method_family = none)]
160        pub fn doubleAction(&self) -> Option<Sel>;
161
162        /// Setter for [`doubleAction`][Self::doubleAction].
163        ///
164        /// # Safety
165        ///
166        /// `double_action` must be a valid selector.
167        #[deprecated = "Use the receiver's button.doubleAction instead"]
168        #[unsafe(method(setDoubleAction:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setDoubleAction(&self, double_action: Option<Sel>);
171
172        #[deprecated = "Use the receiver's button.target instead"]
173        #[unsafe(method(target))]
174        #[unsafe(method_family = none)]
175        pub fn target(&self) -> Option<Retained<AnyObject>>;
176
177        /// Setter for [`target`][Self::target].
178        ///
179        /// This is a [weak property][objc2::topics::weak_property].
180        ///
181        /// # Safety
182        ///
183        /// `target` should be of the correct type.
184        #[deprecated = "Use the receiver's button.target instead"]
185        #[unsafe(method(setTarget:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
188
189        #[deprecated = "Use the receiver's button.title instead"]
190        #[unsafe(method(title))]
191        #[unsafe(method_family = none)]
192        pub fn title(&self) -> Option<Retained<NSString>>;
193
194        /// Setter for [`title`][Self::title].
195        ///
196        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
197        #[deprecated = "Use the receiver's button.title instead"]
198        #[unsafe(method(setTitle:))]
199        #[unsafe(method_family = none)]
200        pub fn setTitle(&self, title: Option<&NSString>);
201
202        #[deprecated = "Use the receiver's button.attributedTitle instead"]
203        #[unsafe(method(attributedTitle))]
204        #[unsafe(method_family = none)]
205        pub fn attributedTitle(&self) -> Option<Retained<NSAttributedString>>;
206
207        /// Setter for [`attributedTitle`][Self::attributedTitle].
208        ///
209        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
210        #[deprecated = "Use the receiver's button.attributedTitle instead"]
211        #[unsafe(method(setAttributedTitle:))]
212        #[unsafe(method_family = none)]
213        pub fn setAttributedTitle(&self, attributed_title: Option<&NSAttributedString>);
214
215        #[cfg(feature = "NSImage")]
216        #[deprecated = "Use the receiver's button.image instead"]
217        #[unsafe(method(image))]
218        #[unsafe(method_family = none)]
219        pub fn image(&self) -> Option<Retained<NSImage>>;
220
221        #[cfg(feature = "NSImage")]
222        /// Setter for [`image`][Self::image].
223        #[deprecated = "Use the receiver's button.image instead"]
224        #[unsafe(method(setImage:))]
225        #[unsafe(method_family = none)]
226        pub fn setImage(&self, image: Option<&NSImage>);
227
228        #[cfg(feature = "NSImage")]
229        #[deprecated = "Use the receiver's button.alternateImage instead"]
230        #[unsafe(method(alternateImage))]
231        #[unsafe(method_family = none)]
232        pub fn alternateImage(&self) -> Option<Retained<NSImage>>;
233
234        #[cfg(feature = "NSImage")]
235        /// Setter for [`alternateImage`][Self::alternateImage].
236        #[deprecated = "Use the receiver's button.alternateImage instead"]
237        #[unsafe(method(setAlternateImage:))]
238        #[unsafe(method_family = none)]
239        pub fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
240
241        #[deprecated = "Use the receiver's button.enabled instead"]
242        #[unsafe(method(isEnabled))]
243        #[unsafe(method_family = none)]
244        pub fn isEnabled(&self) -> bool;
245
246        /// Setter for [`isEnabled`][Self::isEnabled].
247        #[deprecated = "Use the receiver's button.enabled instead"]
248        #[unsafe(method(setEnabled:))]
249        #[unsafe(method_family = none)]
250        pub fn setEnabled(&self, enabled: bool);
251
252        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
253        #[unsafe(method(highlightMode))]
254        #[unsafe(method_family = none)]
255        pub fn highlightMode(&self) -> bool;
256
257        /// Setter for [`highlightMode`][Self::highlightMode].
258        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
259        #[unsafe(method(setHighlightMode:))]
260        #[unsafe(method_family = none)]
261        pub fn setHighlightMode(&self, highlight_mode: bool);
262
263        #[deprecated = "Use the receiver's button.toolTip instead"]
264        #[unsafe(method(toolTip))]
265        #[unsafe(method_family = none)]
266        pub fn toolTip(&self) -> Option<Retained<NSString>>;
267
268        /// Setter for [`toolTip`][Self::toolTip].
269        ///
270        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
271        #[deprecated = "Use the receiver's button.toolTip instead"]
272        #[unsafe(method(setToolTip:))]
273        #[unsafe(method_family = none)]
274        pub fn setToolTip(&self, tool_tip: Option<&NSString>);
275
276        #[cfg(feature = "NSEvent")]
277        #[deprecated = "Use the receiver's button's -sendActionOn: instead"]
278        #[unsafe(method(sendActionOn:))]
279        #[unsafe(method_family = none)]
280        pub fn sendActionOn(&self, mask: NSEventMask) -> NSInteger;
281
282        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
283        #[deprecated = "Use the standard button property instead"]
284        #[unsafe(method(view))]
285        #[unsafe(method_family = none)]
286        pub fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
287
288        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
289        /// Setter for [`view`][Self::view].
290        #[deprecated = "Use the standard button property instead"]
291        #[unsafe(method(setView:))]
292        #[unsafe(method_family = none)]
293        pub fn setView(&self, view: Option<&NSView>);
294
295        #[deprecated = "Use the standard button instead which handles highlight drawing, making this method obsolete"]
296        #[unsafe(method(drawStatusBarBackgroundInRect:withHighlight:))]
297        #[unsafe(method_family = none)]
298        pub fn drawStatusBarBackgroundInRect_withHighlight(&self, rect: NSRect, highlight: bool);
299
300        #[cfg(feature = "NSMenu")]
301        #[deprecated = "Use the menu property instead"]
302        #[unsafe(method(popUpStatusItemMenu:))]
303        #[unsafe(method_family = none)]
304        pub fn popUpStatusItemMenu(&self, menu: &NSMenu);
305    );
306}