1use 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#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSColorPanelMode(pub NSInteger);
17impl NSColorPanelMode {
18 #[doc(alias = "NSColorPanelModeNone")]
19 pub const None: Self = Self(-1);
20 #[doc(alias = "NSColorPanelModeGray")]
21 pub const Gray: Self = Self(0);
22 #[doc(alias = "NSColorPanelModeRGB")]
23 pub const RGB: Self = Self(1);
24 #[doc(alias = "NSColorPanelModeCMYK")]
25 pub const CMYK: Self = Self(2);
26 #[doc(alias = "NSColorPanelModeHSB")]
27 pub const HSB: Self = Self(3);
28 #[doc(alias = "NSColorPanelModeCustomPalette")]
29 pub const CustomPalette: Self = Self(4);
30 #[doc(alias = "NSColorPanelModeColorList")]
31 pub const ColorList: Self = Self(5);
32 #[doc(alias = "NSColorPanelModeWheel")]
33 pub const Wheel: Self = Self(6);
34 #[doc(alias = "NSColorPanelModeCrayon")]
35 pub const Crayon: Self = Self(7);
36}
37
38unsafe impl Encode for NSColorPanelMode {
39 const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for NSColorPanelMode {
43 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46#[repr(transparent)]
49#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
50pub struct NSColorPanelOptions(pub NSUInteger);
51bitflags::bitflags! {
52 impl NSColorPanelOptions: NSUInteger {
53 #[doc(alias = "NSColorPanelGrayModeMask")]
54 const GrayModeMask = 0x00000001;
55 #[doc(alias = "NSColorPanelRGBModeMask")]
56 const RGBModeMask = 0x00000002;
57 #[doc(alias = "NSColorPanelCMYKModeMask")]
58 const CMYKModeMask = 0x00000004;
59 #[doc(alias = "NSColorPanelHSBModeMask")]
60 const HSBModeMask = 0x00000008;
61 #[doc(alias = "NSColorPanelCustomPaletteModeMask")]
62 const CustomPaletteModeMask = 0x00000010;
63 #[doc(alias = "NSColorPanelColorListModeMask")]
64 const ColorListModeMask = 0x00000020;
65 #[doc(alias = "NSColorPanelWheelModeMask")]
66 const WheelModeMask = 0x00000040;
67 #[doc(alias = "NSColorPanelCrayonModeMask")]
68 const CrayonModeMask = 0x00000080;
69 #[doc(alias = "NSColorPanelAllModesMask")]
70 const AllModesMask = 0x0000ffff;
71 }
72}
73
74unsafe impl Encode for NSColorPanelOptions {
75 const ENCODING: Encoding = NSUInteger::ENCODING;
76}
77
78unsafe impl RefEncode for NSColorPanelOptions {
79 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
80}
81
82extern_class!(
83 #[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
85 #[derive(Debug, PartialEq, Eq, Hash)]
86 #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
87 pub struct NSColorPanel;
88);
89
90#[cfg(all(
91 feature = "NSAccessibilityProtocols",
92 feature = "NSPanel",
93 feature = "NSResponder",
94 feature = "NSWindow"
95))]
96extern_conformance!(
97 unsafe impl NSAccessibility for NSColorPanel {}
98);
99
100#[cfg(all(
101 feature = "NSAccessibilityProtocols",
102 feature = "NSPanel",
103 feature = "NSResponder",
104 feature = "NSWindow"
105))]
106extern_conformance!(
107 unsafe impl NSAccessibilityElementProtocol for NSColorPanel {}
108);
109
110#[cfg(all(
111 feature = "NSAnimation",
112 feature = "NSPanel",
113 feature = "NSResponder",
114 feature = "NSWindow"
115))]
116extern_conformance!(
117 unsafe impl NSAnimatablePropertyContainer for NSColorPanel {}
118);
119
120#[cfg(all(
121 feature = "NSAppearance",
122 feature = "NSPanel",
123 feature = "NSResponder",
124 feature = "NSWindow"
125))]
126extern_conformance!(
127 unsafe impl NSAppearanceCustomization for NSColorPanel {}
128);
129
130#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
131extern_conformance!(
132 unsafe impl NSCoding for NSColorPanel {}
133);
134
135#[cfg(all(
136 feature = "NSMenu",
137 feature = "NSPanel",
138 feature = "NSResponder",
139 feature = "NSWindow"
140))]
141extern_conformance!(
142 unsafe impl NSMenuItemValidation for NSColorPanel {}
143);
144
145#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
146extern_conformance!(
147 unsafe impl NSObjectProtocol for NSColorPanel {}
148);
149
150#[cfg(all(
151 feature = "NSPanel",
152 feature = "NSResponder",
153 feature = "NSUserInterfaceItemIdentification",
154 feature = "NSWindow"
155))]
156extern_conformance!(
157 unsafe impl NSUserInterfaceItemIdentification for NSColorPanel {}
158);
159
160#[cfg(all(
161 feature = "NSPanel",
162 feature = "NSResponder",
163 feature = "NSUserInterfaceValidation",
164 feature = "NSWindow"
165))]
166extern_conformance!(
167 unsafe impl NSUserInterfaceValidations for NSColorPanel {}
168);
169
170#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
171impl NSColorPanel {
172 extern_methods!(
173 #[unsafe(method(sharedColorPanel))]
174 #[unsafe(method_family = none)]
175 pub fn sharedColorPanel(mtm: MainThreadMarker) -> Retained<NSColorPanel>;
176
177 #[unsafe(method(sharedColorPanelExists))]
178 #[unsafe(method_family = none)]
179 pub fn sharedColorPanelExists(mtm: MainThreadMarker) -> bool;
180
181 #[cfg(all(feature = "NSColor", feature = "NSEvent", feature = "NSView"))]
182 #[unsafe(method(dragColor:withEvent:fromView:))]
183 #[unsafe(method_family = none)]
184 pub fn dragColor_withEvent_fromView(
185 color: &NSColor,
186 event: &NSEvent,
187 source_view: &NSView,
188 ) -> bool;
189
190 #[unsafe(method(setPickerMask:))]
191 #[unsafe(method_family = none)]
192 pub fn setPickerMask(mask: NSColorPanelOptions, mtm: MainThreadMarker);
193
194 #[unsafe(method(setPickerMode:))]
195 #[unsafe(method_family = none)]
196 pub fn setPickerMode(mode: NSColorPanelMode, mtm: MainThreadMarker);
197
198 #[cfg(feature = "NSView")]
199 #[unsafe(method(accessoryView))]
200 #[unsafe(method_family = none)]
201 pub fn accessoryView(&self) -> Option<Retained<NSView>>;
202
203 #[cfg(feature = "NSView")]
204 #[unsafe(method(setAccessoryView:))]
206 #[unsafe(method_family = none)]
207 pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);
208
209 #[unsafe(method(isContinuous))]
210 #[unsafe(method_family = none)]
211 pub fn isContinuous(&self) -> bool;
212
213 #[unsafe(method(setContinuous:))]
215 #[unsafe(method_family = none)]
216 pub fn setContinuous(&self, continuous: bool);
217
218 #[unsafe(method(showsAlpha))]
219 #[unsafe(method_family = none)]
220 pub fn showsAlpha(&self) -> bool;
221
222 #[unsafe(method(setShowsAlpha:))]
224 #[unsafe(method_family = none)]
225 pub fn setShowsAlpha(&self, shows_alpha: bool);
226
227 #[unsafe(method(mode))]
228 #[unsafe(method_family = none)]
229 pub fn mode(&self) -> NSColorPanelMode;
230
231 #[unsafe(method(setMode:))]
233 #[unsafe(method_family = none)]
234 pub fn setMode(&self, mode: NSColorPanelMode);
235
236 #[cfg(feature = "NSColor")]
237 #[unsafe(method(color))]
238 #[unsafe(method_family = none)]
239 pub fn color(&self) -> Retained<NSColor>;
240
241 #[cfg(feature = "NSColor")]
242 #[unsafe(method(setColor:))]
246 #[unsafe(method_family = none)]
247 pub fn setColor(&self, color: &NSColor);
248
249 #[cfg(feature = "objc2-core-foundation")]
250 #[unsafe(method(alpha))]
251 #[unsafe(method_family = none)]
252 pub fn alpha(&self) -> CGFloat;
253
254 #[unsafe(method(setAction:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn setAction(&self, selector: Option<Sel>);
260
261 #[unsafe(method(setTarget:))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
267
268 #[cfg(feature = "NSColorList")]
269 #[unsafe(method(attachColorList:))]
270 #[unsafe(method_family = none)]
271 pub fn attachColorList(&self, color_list: &NSColorList);
272
273 #[cfg(feature = "NSColorList")]
274 #[unsafe(method(detachColorList:))]
275 #[unsafe(method_family = none)]
276 pub fn detachColorList(&self, color_list: &NSColorList);
277
278 #[cfg(feature = "objc2-core-foundation")]
279 #[unsafe(method(maximumLinearExposure))]
281 #[unsafe(method_family = none)]
282 pub fn maximumLinearExposure(&self) -> CGFloat;
283
284 #[cfg(feature = "objc2-core-foundation")]
285 #[unsafe(method(setMaximumLinearExposure:))]
287 #[unsafe(method_family = none)]
288 pub fn setMaximumLinearExposure(&self, maximum_linear_exposure: CGFloat);
289 );
290}
291
292#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
294impl NSColorPanel {
295 extern_methods!(
296 #[cfg(feature = "NSGraphics")]
297 #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
298 #[unsafe(method_family = init)]
299 pub unsafe fn initWithContentRect_styleMask_backing_defer(
300 this: Allocated<Self>,
301 content_rect: NSRect,
302 style: NSWindowStyleMask,
303 backing_store_type: NSBackingStoreType,
304 flag: bool,
305 ) -> Retained<Self>;
306
307 #[cfg(all(feature = "NSGraphics", feature = "NSScreen"))]
308 #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
309 #[unsafe(method_family = init)]
310 pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
311 this: Allocated<Self>,
312 content_rect: NSRect,
313 style: NSWindowStyleMask,
314 backing_store_type: NSBackingStoreType,
315 flag: bool,
316 screen: Option<&NSScreen>,
317 ) -> Retained<Self>;
318
319 #[unsafe(method(initWithCoder:))]
323 #[unsafe(method_family = init)]
324 pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
325
326 #[cfg(feature = "NSViewController")]
327 #[unsafe(method(windowWithContentViewController:))]
329 #[unsafe(method_family = none)]
330 pub fn windowWithContentViewController(
331 content_view_controller: &NSViewController,
332 ) -> Retained<Self>;
333 );
334}
335
336#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
338impl NSColorPanel {
339 extern_methods!(
340 #[unsafe(method(init))]
341 #[unsafe(method_family = init)]
342 pub fn init(this: Allocated<Self>) -> Retained<Self>;
343 );
344}
345
346#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
348impl NSColorPanel {
349 extern_methods!(
350 #[unsafe(method(new))]
351 #[unsafe(method_family = new)]
352 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
353 );
354}
355
356#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
358impl NSApplication {
359 extern_methods!(
360 #[unsafe(method(orderFrontColorPanel:))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn orderFrontColorPanel(&self, sender: Option<&AnyObject>);
366 );
367}
368
369extern_protocol!(
370 pub unsafe trait NSColorChanging: NSObjectProtocol {
372 #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
373 #[unsafe(method(changeColor:))]
374 #[unsafe(method_family = none)]
375 fn changeColor(&self, sender: Option<&NSColorPanel>);
376 }
377);
378
379extern "C" {
380 pub static NSColorPanelColorDidChangeNotification: &'static NSNotificationName;
382}
383
384#[deprecated]
386pub static NSNoModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::None.0);
387
388#[deprecated]
390pub static NSGrayModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Gray.0);
391
392#[deprecated]
394pub static NSRGBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::RGB.0);
395
396#[deprecated]
398pub static NSCMYKModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::CMYK.0);
399
400#[deprecated]
402pub static NSHSBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::HSB.0);
403
404#[deprecated]
406pub static NSCustomPaletteModeColorPanel: NSColorPanelMode =
407 NSColorPanelMode(NSColorPanelMode::CustomPalette.0);
408
409#[deprecated]
411pub static NSColorListModeColorPanel: NSColorPanelMode =
412 NSColorPanelMode(NSColorPanelMode::ColorList.0);
413
414#[deprecated]
416pub static NSWheelModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Wheel.0);
417
418#[deprecated]
420pub static NSCrayonModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Crayon.0);