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