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
44unsafe impl NSObjectProtocol for NSStatusItem {}
45
46impl NSStatusItem {
47    extern_methods!(
48        #[cfg(feature = "NSStatusBar")]
49        #[unsafe(method(statusBar))]
50        #[unsafe(method_family = none)]
51        pub unsafe fn statusBar(&self) -> Option<Retained<NSStatusBar>>;
52
53        #[cfg(feature = "objc2-core-foundation")]
54        #[unsafe(method(length))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn length(&self) -> CGFloat;
57
58        #[cfg(feature = "objc2-core-foundation")]
59        /// Setter for [`length`][Self::length].
60        #[unsafe(method(setLength:))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn setLength(&self, length: CGFloat);
63
64        #[cfg(feature = "NSMenu")]
65        #[unsafe(method(menu))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn menu(&self, mtm: MainThreadMarker) -> Option<Retained<NSMenu>>;
68
69        #[cfg(feature = "NSMenu")]
70        /// Setter for [`menu`][Self::menu].
71        #[unsafe(method(setMenu:))]
72        #[unsafe(method_family = none)]
73        pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);
74
75        #[cfg(all(
76            feature = "NSButton",
77            feature = "NSControl",
78            feature = "NSResponder",
79            feature = "NSStatusBarButton",
80            feature = "NSView"
81        ))]
82        #[unsafe(method(button))]
83        #[unsafe(method_family = none)]
84        pub unsafe fn button(&self, mtm: MainThreadMarker) -> Option<Retained<NSStatusBarButton>>;
85
86        #[unsafe(method(behavior))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn behavior(&self) -> NSStatusItemBehavior;
89
90        /// Setter for [`behavior`][Self::behavior].
91        #[unsafe(method(setBehavior:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn setBehavior(&self, behavior: NSStatusItemBehavior);
94
95        #[unsafe(method(isVisible))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn isVisible(&self) -> bool;
98
99        /// Setter for [`isVisible`][Self::isVisible].
100        #[unsafe(method(setVisible:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setVisible(&self, visible: bool);
103
104        #[unsafe(method(autosaveName))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn autosaveName(&self) -> Retained<NSStatusItemAutosaveName>;
107
108        /// Setter for [`autosaveName`][Self::autosaveName].
109        #[unsafe(method(setAutosaveName:))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn setAutosaveName(&self, autosave_name: Option<&NSStatusItemAutosaveName>);
112    );
113}
114
115/// Methods declared on superclass `NSObject`.
116impl NSStatusItem {
117    extern_methods!(
118        #[unsafe(method(init))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122        #[unsafe(method(new))]
123        #[unsafe(method_family = new)]
124        pub unsafe fn new() -> Retained<Self>;
125    );
126}
127
128/// NSStatusItemDeprecated.
129impl NSStatusItem {
130    extern_methods!(
131        #[deprecated = "Use the receiver's button.action instead"]
132        #[unsafe(method(action))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn action(&self) -> Option<Sel>;
135
136        /// Setter for [`action`][Self::action].
137        #[deprecated = "Use the receiver's button.action instead"]
138        #[unsafe(method(setAction:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setAction(&self, action: Option<Sel>);
141
142        #[deprecated = "Use the receiver's button.doubleAction instead"]
143        #[unsafe(method(doubleAction))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn doubleAction(&self) -> Option<Sel>;
146
147        /// Setter for [`doubleAction`][Self::doubleAction].
148        #[deprecated = "Use the receiver's button.doubleAction instead"]
149        #[unsafe(method(setDoubleAction:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setDoubleAction(&self, double_action: Option<Sel>);
152
153        #[deprecated = "Use the receiver's button.target instead"]
154        #[unsafe(method(target))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn target(&self) -> Option<Retained<AnyObject>>;
157
158        /// This is a [weak property][objc2::topics::weak_property].
159        /// Setter for [`target`][Self::target].
160        #[deprecated = "Use the receiver's button.target instead"]
161        #[unsafe(method(setTarget:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
164
165        #[deprecated = "Use the receiver's button.title instead"]
166        #[unsafe(method(title))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
169
170        /// Setter for [`title`][Self::title].
171        #[deprecated = "Use the receiver's button.title instead"]
172        #[unsafe(method(setTitle:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setTitle(&self, title: Option<&NSString>);
175
176        #[deprecated = "Use the receiver's button.attributedTitle instead"]
177        #[unsafe(method(attributedTitle))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn attributedTitle(&self) -> Option<Retained<NSAttributedString>>;
180
181        /// Setter for [`attributedTitle`][Self::attributedTitle].
182        #[deprecated = "Use the receiver's button.attributedTitle instead"]
183        #[unsafe(method(setAttributedTitle:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setAttributedTitle(&self, attributed_title: Option<&NSAttributedString>);
186
187        #[cfg(feature = "NSImage")]
188        #[deprecated = "Use the receiver's button.image instead"]
189        #[unsafe(method(image))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
192
193        #[cfg(feature = "NSImage")]
194        /// Setter for [`image`][Self::image].
195        #[deprecated = "Use the receiver's button.image instead"]
196        #[unsafe(method(setImage:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn setImage(&self, image: Option<&NSImage>);
199
200        #[cfg(feature = "NSImage")]
201        #[deprecated = "Use the receiver's button.alternateImage instead"]
202        #[unsafe(method(alternateImage))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn alternateImage(&self) -> Option<Retained<NSImage>>;
205
206        #[cfg(feature = "NSImage")]
207        /// Setter for [`alternateImage`][Self::alternateImage].
208        #[deprecated = "Use the receiver's button.alternateImage instead"]
209        #[unsafe(method(setAlternateImage:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn setAlternateImage(&self, alternate_image: Option<&NSImage>);
212
213        #[deprecated = "Use the receiver's button.enabled instead"]
214        #[unsafe(method(isEnabled))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn isEnabled(&self) -> bool;
217
218        /// Setter for [`isEnabled`][Self::isEnabled].
219        #[deprecated = "Use the receiver's button.enabled instead"]
220        #[unsafe(method(setEnabled:))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn setEnabled(&self, enabled: bool);
223
224        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
225        #[unsafe(method(highlightMode))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn highlightMode(&self) -> bool;
228
229        /// Setter for [`highlightMode`][Self::highlightMode].
230        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
231        #[unsafe(method(setHighlightMode:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn setHighlightMode(&self, highlight_mode: bool);
234
235        #[deprecated = "Use the receiver's button.toolTip instead"]
236        #[unsafe(method(toolTip))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
239
240        /// Setter for [`toolTip`][Self::toolTip].
241        #[deprecated = "Use the receiver's button.toolTip instead"]
242        #[unsafe(method(setToolTip:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
245
246        #[cfg(feature = "NSEvent")]
247        #[deprecated = "Use the receiver's button's -sendActionOn: instead"]
248        #[unsafe(method(sendActionOn:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn sendActionOn(&self, mask: NSEventMask) -> NSInteger;
251
252        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
253        #[deprecated = "Use the standard button property instead"]
254        #[unsafe(method(view))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
257
258        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
259        /// Setter for [`view`][Self::view].
260        #[deprecated = "Use the standard button property instead"]
261        #[unsafe(method(setView:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn setView(&self, view: Option<&NSView>);
264
265        #[deprecated = "Use the standard button instead which handles highlight drawing, making this method obsolete"]
266        #[unsafe(method(drawStatusBarBackgroundInRect:withHighlight:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn drawStatusBarBackgroundInRect_withHighlight(
269            &self,
270            rect: NSRect,
271            highlight: bool,
272        );
273
274        #[cfg(feature = "NSMenu")]
275        #[deprecated = "Use the menu property instead"]
276        #[unsafe(method(popUpStatusItemMenu:))]
277        #[unsafe(method_family = none)]
278        pub unsafe fn popUpStatusItemMenu(&self, menu: &NSMenu);
279    );
280}