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
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSColorPanelMode(pub NSInteger);
impl NSColorPanelMode {
    #[doc(alias = "NSColorPanelModeNone")]
    pub const None: Self = Self(-1);
    #[doc(alias = "NSColorPanelModeGray")]
    pub const Gray: Self = Self(0);
    #[doc(alias = "NSColorPanelModeRGB")]
    pub const RGB: Self = Self(1);
    #[doc(alias = "NSColorPanelModeCMYK")]
    pub const CMYK: Self = Self(2);
    #[doc(alias = "NSColorPanelModeHSB")]
    pub const HSB: Self = Self(3);
    #[doc(alias = "NSColorPanelModeCustomPalette")]
    pub const CustomPalette: Self = Self(4);
    #[doc(alias = "NSColorPanelModeColorList")]
    pub const ColorList: Self = Self(5);
    #[doc(alias = "NSColorPanelModeWheel")]
    pub const Wheel: Self = Self(6);
    #[doc(alias = "NSColorPanelModeCrayon")]
    pub const Crayon: Self = Self(7);
}

unsafe impl Encode for NSColorPanelMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSColorPanelOptions(pub NSUInteger);
impl NSColorPanelOptions {
    pub const NSColorPanelGrayModeMask: Self = Self(0x00000001);
    pub const NSColorPanelRGBModeMask: Self = Self(0x00000002);
    pub const NSColorPanelCMYKModeMask: Self = Self(0x00000004);
    pub const NSColorPanelHSBModeMask: Self = Self(0x00000008);
    pub const NSColorPanelCustomPaletteModeMask: Self = Self(0x00000010);
    pub const NSColorPanelColorListModeMask: Self = Self(0x00000020);
    pub const NSColorPanelWheelModeMask: Self = Self(0x00000040);
    pub const NSColorPanelCrayonModeMask: Self = Self(0x00000080);
    pub const NSColorPanelAllModesMask: Self = Self(0x0000ffff);
}

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

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

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    pub struct NSColorPanel;

    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl ClassType for NSColorPanel {
        #[inherits(NSWindow, NSResponder, NSObject)]
        type Super = NSPanel;
        type Mutability = MainThreadOnly;
    }
);

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSWindow"
))]
unsafe impl NSAccessibility for NSColorPanel {}

#[cfg(all(
    feature = "NSAccessibilityProtocols",
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSWindow"
))]
unsafe impl NSAccessibilityElementProtocol for NSColorPanel {}

#[cfg(all(
    feature = "NSAnimation",
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSWindow"
))]
unsafe impl NSAnimatablePropertyContainer for NSColorPanel {}

#[cfg(all(
    feature = "NSAppearance",
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSWindow"
))]
unsafe impl NSAppearanceCustomization for NSColorPanel {}

#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
unsafe impl NSCoding for NSColorPanel {}

#[cfg(all(
    feature = "NSMenu",
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSWindow"
))]
unsafe impl NSMenuItemValidation for NSColorPanel {}

#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
unsafe impl NSObjectProtocol for NSColorPanel {}

#[cfg(all(
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSUserInterfaceItemIdentification",
    feature = "NSWindow"
))]
unsafe impl NSUserInterfaceItemIdentification for NSColorPanel {}

#[cfg(all(
    feature = "NSPanel",
    feature = "NSResponder",
    feature = "NSUserInterfaceValidation",
    feature = "NSWindow"
))]
unsafe impl NSUserInterfaceValidations for NSColorPanel {}

extern_methods!(
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl NSColorPanel {
        #[method_id(@__retain_semantics Other sharedColorPanel)]
        pub unsafe fn sharedColorPanel(mtm: MainThreadMarker) -> Id<NSColorPanel>;

        #[method(sharedColorPanelExists)]
        pub unsafe fn sharedColorPanelExists(mtm: MainThreadMarker) -> bool;

        #[cfg(all(feature = "NSColor", feature = "NSEvent", feature = "NSView"))]
        #[method(dragColor:withEvent:fromView:)]
        pub unsafe fn dragColor_withEvent_fromView(
            color: &NSColor,
            event: &NSEvent,
            source_view: &NSView,
        ) -> bool;

        #[method(setPickerMask:)]
        pub unsafe fn setPickerMask(mask: NSColorPanelOptions, mtm: MainThreadMarker);

        #[method(setPickerMode:)]
        pub unsafe fn setPickerMode(mode: NSColorPanelMode, mtm: MainThreadMarker);

        #[cfg(feature = "NSView")]
        #[method_id(@__retain_semantics Other accessoryView)]
        pub unsafe fn accessoryView(&self) -> Option<Id<NSView>>;

        #[cfg(feature = "NSView")]
        #[method(setAccessoryView:)]
        pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);

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

        #[method(setContinuous:)]
        pub unsafe fn setContinuous(&self, continuous: bool);

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

        #[method(setShowsAlpha:)]
        pub unsafe fn setShowsAlpha(&self, shows_alpha: bool);

        #[method(mode)]
        pub unsafe fn mode(&self) -> NSColorPanelMode;

        #[method(setMode:)]
        pub unsafe fn setMode(&self, mode: NSColorPanelMode);

        #[cfg(feature = "NSColor")]
        #[method_id(@__retain_semantics Other color)]
        pub unsafe fn color(&self) -> Id<NSColor>;

        #[cfg(feature = "NSColor")]
        #[method(setColor:)]
        pub unsafe fn setColor(&self, color: &NSColor);

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

        #[method(setAction:)]
        pub unsafe fn setAction(&self, selector: Option<Sel>);

        #[method(setTarget:)]
        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);

        #[cfg(feature = "NSColorList")]
        #[method(attachColorList:)]
        pub unsafe fn attachColorList(&self, color_list: &NSColorList);

        #[cfg(feature = "NSColorList")]
        #[method(detachColorList:)]
        pub unsafe fn detachColorList(&self, color_list: &NSColorList);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSWindow`
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl NSColorPanel {
        #[cfg(feature = "NSGraphics")]
        #[method_id(@__retain_semantics Init initWithContentRect:styleMask:backing:defer:)]
        pub unsafe fn initWithContentRect_styleMask_backing_defer(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
        ) -> Id<Self>;

        #[cfg(all(feature = "NSGraphics", feature = "NSScreen"))]
        #[method_id(@__retain_semantics Init initWithContentRect:styleMask:backing:defer:screen:)]
        pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
            this: Allocated<Self>,
            content_rect: NSRect,
            style: NSWindowStyleMask,
            backing_store_type: NSBackingStoreType,
            flag: bool,
            screen: Option<&NSScreen>,
        ) -> Id<Self>;

        #[method_id(@__retain_semantics Init initWithCoder:)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Id<Self>;

        #[cfg(feature = "NSViewController")]
        #[method_id(@__retain_semantics Other windowWithContentViewController:)]
        pub unsafe fn windowWithContentViewController(
            content_view_controller: &NSViewController,
        ) -> Id<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSResponder`
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl NSColorPanel {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl NSColorPanel {
        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Id<Self>;
    }
);

extern_methods!(
    /// NSColorPanel
    #[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
    unsafe impl NSApplication {
        #[method(orderFrontColorPanel:)]
        pub unsafe fn orderFrontColorPanel(&self, sender: Option<&AnyObject>);
    }
);

extern_protocol!(
    pub unsafe trait NSColorChanging: NSObjectProtocol {
        #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
        #[method(changeColor:)]
        unsafe fn changeColor(&self, sender: Option<&NSColorPanel>);
    }

    unsafe impl ProtocolType for dyn NSColorChanging {}
);

extern "C" {
    pub static NSColorPanelColorDidChangeNotification: &'static NSNotificationName;
}

pub static NSNoModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::None.0);

pub static NSGrayModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Gray.0);

pub static NSRGBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::RGB.0);

pub static NSCMYKModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::CMYK.0);

pub static NSHSBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::HSB.0);

pub static NSCustomPaletteModeColorPanel: NSColorPanelMode =
    NSColorPanelMode(NSColorPanelMode::CustomPalette.0);

pub static NSColorListModeColorPanel: NSColorPanelMode =
    NSColorPanelMode(NSColorPanelMode::ColorList.0);

pub static NSWheelModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Wheel.0);

pub static NSCrayonModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Crayon.0);