objc2_app_kit/generated/
NSStatusItem.rs1use 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
12pub type NSStatusItemAutosaveName = NSString;
14
15#[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 #[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 #[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 #[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 #[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 #[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 #[unsafe(method(setAutosaveName:))]
114 #[unsafe(method_family = none)]
115 pub fn setAutosaveName(&self, autosave_name: Option<&NSStatusItemAutosaveName>);
116 );
117}
118
119impl 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
139impl 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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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}