1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

pub type NSStatusItemAutosaveName = NSString;

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSStatusItemBehavior(pub NSUInteger);
impl NSStatusItemBehavior {
    #[doc(alias = "NSStatusItemBehaviorRemovalAllowed")]
    pub const RemovalAllowed: Self = Self(1 << 1);
    #[doc(alias = "NSStatusItemBehaviorTerminationOnRemoval")]
    pub const TerminationOnRemoval: Self = Self(1 << 2);
}

unsafe impl Encode for NSStatusItemBehavior {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSStatusItemBehavior {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSStatusItem;

    unsafe impl ClassType for NSStatusItem {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSStatusItem {}

extern_methods!(
    unsafe impl NSStatusItem {
        #[cfg(feature = "NSStatusBar")]
        #[method_id(@__retain_semantics Other statusBar)]
        pub unsafe fn statusBar(&self) -> Option<Id<NSStatusBar>>;

        #[method(length)]
        pub unsafe fn length(&self) -> CGFloat;

        #[method(setLength:)]
        pub unsafe fn setLength(&self, length: CGFloat);

        #[cfg(feature = "NSMenu")]
        #[method_id(@__retain_semantics Other menu)]
        pub unsafe fn menu(&self, mtm: MainThreadMarker) -> Option<Id<NSMenu>>;

        #[cfg(feature = "NSMenu")]
        #[method(setMenu:)]
        pub unsafe fn setMenu(&self, menu: Option<&NSMenu>);

        #[cfg(all(
            feature = "NSButton",
            feature = "NSControl",
            feature = "NSResponder",
            feature = "NSStatusBarButton",
            feature = "NSView"
        ))]
        #[method_id(@__retain_semantics Other button)]
        pub unsafe fn button(&self, mtm: MainThreadMarker) -> Option<Id<NSStatusBarButton>>;

        #[method(behavior)]
        pub unsafe fn behavior(&self) -> NSStatusItemBehavior;

        #[method(setBehavior:)]
        pub unsafe fn setBehavior(&self, behavior: NSStatusItemBehavior);

        #[method(isVisible)]
        pub unsafe fn isVisible(&self) -> bool;

        #[method(setVisible:)]
        pub unsafe fn setVisible(&self, visible: bool);

        #[method_id(@__retain_semantics Other autosaveName)]
        pub unsafe fn autosaveName(&self) -> Id<NSStatusItemAutosaveName>;

        #[method(setAutosaveName:)]
        pub unsafe fn setAutosaveName(&self, autosave_name: Option<&NSStatusItemAutosaveName>);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSStatusItem {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_methods!(
    /// NSStatusItemDeprecated
    unsafe impl NSStatusItem {
        #[deprecated = "Use the receiver's button.action instead"]
        #[method(action)]
        pub unsafe fn action(&self) -> Option<Sel>;

        #[deprecated = "Use the receiver's button.action instead"]
        #[method(setAction:)]
        pub unsafe fn setAction(&self, action: Option<Sel>);

        #[deprecated = "Use the receiver's button.doubleAction instead"]
        #[method(doubleAction)]
        pub unsafe fn doubleAction(&self) -> Option<Sel>;

        #[deprecated = "Use the receiver's button.doubleAction instead"]
        #[method(setDoubleAction:)]
        pub unsafe fn setDoubleAction(&self, double_action: Option<Sel>);

        #[deprecated = "Use the receiver's button.target instead"]
        #[method_id(@__retain_semantics Other target)]
        pub unsafe fn target(&self) -> Option<Id<AnyObject>>;

        #[deprecated = "Use the receiver's button.target instead"]
        #[method(setTarget:)]
        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);

        #[deprecated = "Use the receiver's button.title instead"]
        #[method_id(@__retain_semantics Other title)]
        pub unsafe fn title(&self) -> Option<Id<NSString>>;

        #[deprecated = "Use the receiver's button.title instead"]
        #[method(setTitle:)]
        pub unsafe fn setTitle(&self, title: Option<&NSString>);

        #[deprecated = "Use the receiver's button.attributedTitle instead"]
        #[method_id(@__retain_semantics Other attributedTitle)]
        pub unsafe fn attributedTitle(&self) -> Option<Id<NSAttributedString>>;

        #[deprecated = "Use the receiver's button.attributedTitle instead"]
        #[method(setAttributedTitle:)]
        pub unsafe fn setAttributedTitle(&self, attributed_title: Option<&NSAttributedString>);

        #[cfg(feature = "NSImage")]
        #[deprecated = "Use the receiver's button.image instead"]
        #[method_id(@__retain_semantics Other image)]
        pub unsafe fn image(&self) -> Option<Id<NSImage>>;

        #[cfg(feature = "NSImage")]
        #[deprecated = "Use the receiver's button.image instead"]
        #[method(setImage:)]
        pub unsafe fn setImage(&self, image: Option<&NSImage>);

        #[cfg(feature = "NSImage")]
        #[deprecated = "Use the receiver's button.alternateImage instead"]
        #[method_id(@__retain_semantics Other alternateImage)]
        pub unsafe fn alternateImage(&self) -> Option<Id<NSImage>>;

        #[cfg(feature = "NSImage")]
        #[deprecated = "Use the receiver's button.alternateImage instead"]
        #[method(setAlternateImage:)]
        pub unsafe fn setAlternateImage(&self, alternate_image: Option<&NSImage>);

        #[deprecated = "Use the receiver's button.enabled instead"]
        #[method(isEnabled)]
        pub unsafe fn isEnabled(&self) -> bool;

        #[deprecated = "Use the receiver's button.enabled instead"]
        #[method(setEnabled:)]
        pub unsafe fn setEnabled(&self, enabled: bool);

        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
        #[method(highlightMode)]
        pub unsafe fn highlightMode(&self) -> bool;

        #[deprecated = "Use the receiver's button.cell.highlightsBy instead"]
        #[method(setHighlightMode:)]
        pub unsafe fn setHighlightMode(&self, highlight_mode: bool);

        #[deprecated = "Use the receiver's button.toolTip instead"]
        #[method_id(@__retain_semantics Other toolTip)]
        pub unsafe fn toolTip(&self) -> Option<Id<NSString>>;

        #[deprecated = "Use the receiver's button.toolTip instead"]
        #[method(setToolTip:)]
        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);

        #[cfg(feature = "NSEvent")]
        #[deprecated = "Use the receiver's button's -sendActionOn: instead"]
        #[method(sendActionOn:)]
        pub unsafe fn sendActionOn(&self, mask: NSEventMask) -> NSInteger;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use the standard button property instead"]
        #[method_id(@__retain_semantics Other view)]
        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Id<NSView>>;

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use the standard button property instead"]
        #[method(setView:)]
        pub unsafe fn setView(&self, view: Option<&NSView>);

        #[deprecated = "Use the standard button instead which handles highlight drawing, making this method obsolete"]
        #[method(drawStatusBarBackgroundInRect:withHighlight:)]
        pub unsafe fn drawStatusBarBackgroundInRect_withHighlight(
            &self,
            rect: NSRect,
            highlight: bool,
        );

        #[cfg(feature = "NSMenu")]
        #[deprecated = "Use the menu property instead"]
        #[method(popUpStatusItemMenu:)]
        pub unsafe fn popUpStatusItemMenu(&self, menu: &NSMenu);
    }
);