objc2_app_kit/generated/
NSColorPanel.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/nscolorpanelmode?language=objc)
13// NS_ENUM
14#[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/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpaneloptions?language=objc)
47// NS_OPTIONS
48#[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    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanel?language=objc)
84    #[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))]
96unsafe impl NSAccessibility for NSColorPanel {}
97
98#[cfg(all(
99    feature = "NSAccessibilityProtocols",
100    feature = "NSPanel",
101    feature = "NSResponder",
102    feature = "NSWindow"
103))]
104unsafe impl NSAccessibilityElementProtocol for NSColorPanel {}
105
106#[cfg(all(
107    feature = "NSAnimation",
108    feature = "NSPanel",
109    feature = "NSResponder",
110    feature = "NSWindow"
111))]
112unsafe impl NSAnimatablePropertyContainer for NSColorPanel {}
113
114#[cfg(all(
115    feature = "NSAppearance",
116    feature = "NSPanel",
117    feature = "NSResponder",
118    feature = "NSWindow"
119))]
120unsafe impl NSAppearanceCustomization for NSColorPanel {}
121
122#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
123unsafe impl NSCoding for NSColorPanel {}
124
125#[cfg(all(
126    feature = "NSMenu",
127    feature = "NSPanel",
128    feature = "NSResponder",
129    feature = "NSWindow"
130))]
131unsafe impl NSMenuItemValidation for NSColorPanel {}
132
133#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
134unsafe impl NSObjectProtocol for NSColorPanel {}
135
136#[cfg(all(
137    feature = "NSPanel",
138    feature = "NSResponder",
139    feature = "NSUserInterfaceItemIdentification",
140    feature = "NSWindow"
141))]
142unsafe impl NSUserInterfaceItemIdentification for NSColorPanel {}
143
144#[cfg(all(
145    feature = "NSPanel",
146    feature = "NSResponder",
147    feature = "NSUserInterfaceValidation",
148    feature = "NSWindow"
149))]
150unsafe impl NSUserInterfaceValidations for NSColorPanel {}
151
152#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
153impl NSColorPanel {
154    extern_methods!(
155        #[unsafe(method(sharedColorPanel))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn sharedColorPanel(mtm: MainThreadMarker) -> Retained<NSColorPanel>;
158
159        #[unsafe(method(sharedColorPanelExists))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn sharedColorPanelExists(mtm: MainThreadMarker) -> bool;
162
163        #[cfg(all(feature = "NSColor", feature = "NSEvent", feature = "NSView"))]
164        #[unsafe(method(dragColor:withEvent:fromView:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn dragColor_withEvent_fromView(
167            color: &NSColor,
168            event: &NSEvent,
169            source_view: &NSView,
170        ) -> bool;
171
172        #[unsafe(method(setPickerMask:))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn setPickerMask(mask: NSColorPanelOptions, mtm: MainThreadMarker);
175
176        #[unsafe(method(setPickerMode:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setPickerMode(mode: NSColorPanelMode, mtm: MainThreadMarker);
179
180        #[cfg(feature = "NSView")]
181        #[unsafe(method(accessoryView))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn accessoryView(&self) -> Option<Retained<NSView>>;
184
185        #[cfg(feature = "NSView")]
186        /// Setter for [`accessoryView`][Self::accessoryView].
187        #[unsafe(method(setAccessoryView:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);
190
191        #[unsafe(method(isContinuous))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn isContinuous(&self) -> bool;
194
195        /// Setter for [`isContinuous`][Self::isContinuous].
196        #[unsafe(method(setContinuous:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn setContinuous(&self, continuous: bool);
199
200        #[unsafe(method(showsAlpha))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn showsAlpha(&self) -> bool;
203
204        /// Setter for [`showsAlpha`][Self::showsAlpha].
205        #[unsafe(method(setShowsAlpha:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn setShowsAlpha(&self, shows_alpha: bool);
208
209        #[unsafe(method(mode))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn mode(&self) -> NSColorPanelMode;
212
213        /// Setter for [`mode`][Self::mode].
214        #[unsafe(method(setMode:))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn setMode(&self, mode: NSColorPanelMode);
217
218        #[cfg(feature = "NSColor")]
219        #[unsafe(method(color))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn color(&self) -> Retained<NSColor>;
222
223        #[cfg(feature = "NSColor")]
224        /// Setter for [`color`][Self::color].
225        #[unsafe(method(setColor:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn setColor(&self, color: &NSColor);
228
229        #[cfg(feature = "objc2-core-foundation")]
230        #[unsafe(method(alpha))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn alpha(&self) -> CGFloat;
233
234        #[unsafe(method(setAction:))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn setAction(&self, selector: Option<Sel>);
237
238        #[unsafe(method(setTarget:))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);
241
242        #[cfg(feature = "NSColorList")]
243        #[unsafe(method(attachColorList:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn attachColorList(&self, color_list: &NSColorList);
246
247        #[cfg(feature = "NSColorList")]
248        #[unsafe(method(detachColorList:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn detachColorList(&self, color_list: &NSColorList);
251    );
252}
253
254/// Methods declared on superclass `NSWindow`.
255#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
256impl NSColorPanel {
257    extern_methods!(
258        #[cfg(feature = "NSGraphics")]
259        #[unsafe(method(initWithContentRect:styleMask:backing:defer:))]
260        #[unsafe(method_family = init)]
261        pub unsafe fn initWithContentRect_styleMask_backing_defer(
262            this: Allocated<Self>,
263            content_rect: NSRect,
264            style: NSWindowStyleMask,
265            backing_store_type: NSBackingStoreType,
266            flag: bool,
267        ) -> Retained<Self>;
268
269        #[cfg(all(feature = "NSGraphics", feature = "NSScreen"))]
270        #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
271        #[unsafe(method_family = init)]
272        pub unsafe fn initWithContentRect_styleMask_backing_defer_screen(
273            this: Allocated<Self>,
274            content_rect: NSRect,
275            style: NSWindowStyleMask,
276            backing_store_type: NSBackingStoreType,
277            flag: bool,
278            screen: Option<&NSScreen>,
279        ) -> Retained<Self>;
280
281        #[unsafe(method(initWithCoder:))]
282        #[unsafe(method_family = init)]
283        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;
284
285        #[cfg(feature = "NSViewController")]
286        /// Convenience method for creating an autoreleased titled window with the given contentViewController. A basic NSWindow with the following attributes is made: titled, closable, resizable, miniaturizable. The window's title is automatically bound to the contentViewController's title. The size of the window can easily be controlled by utilizing autolayout and applying size constraints to the view (or its subviews). The window has isReleasedWhenClosed set to NO, and it must be explicitly retained to keep the window instance alive. To have it automatically be freed when it is closed, do the following: [window retain] and [window setReleasedWhenClosed:YES].
287        #[unsafe(method(windowWithContentViewController:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn windowWithContentViewController(
290            content_view_controller: &NSViewController,
291        ) -> Retained<Self>;
292    );
293}
294
295/// Methods declared on superclass `NSResponder`.
296#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
297impl NSColorPanel {
298    extern_methods!(
299        #[unsafe(method(init))]
300        #[unsafe(method_family = init)]
301        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
302    );
303}
304
305/// Methods declared on superclass `NSObject`.
306#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
307impl NSColorPanel {
308    extern_methods!(
309        #[unsafe(method(new))]
310        #[unsafe(method_family = new)]
311        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
312    );
313}
314
315/// NSColorPanel.
316#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
317impl NSApplication {
318    extern_methods!(
319        #[unsafe(method(orderFrontColorPanel:))]
320        #[unsafe(method_family = none)]
321        pub unsafe fn orderFrontColorPanel(&self, sender: Option<&AnyObject>);
322    );
323}
324
325extern_protocol!(
326    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorchanging?language=objc)
327    pub unsafe trait NSColorChanging: NSObjectProtocol {
328        #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
329        #[unsafe(method(changeColor:))]
330        #[unsafe(method_family = none)]
331        unsafe fn changeColor(&self, sender: Option<&NSColorPanel>);
332    }
333);
334
335extern "C" {
336    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanelcolordidchangenotification?language=objc)
337    pub static NSColorPanelColorDidChangeNotification: &'static NSNotificationName;
338}
339
340/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsnomodecolorpanel?language=objc)
341pub static NSNoModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::None.0);
342
343/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraymodecolorpanel?language=objc)
344pub static NSGrayModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Gray.0);
345
346/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrgbmodecolorpanel?language=objc)
347pub static NSRGBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::RGB.0);
348
349/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscmykmodecolorpanel?language=objc)
350pub static NSCMYKModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::CMYK.0);
351
352/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshsbmodecolorpanel?language=objc)
353pub static NSHSBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::HSB.0);
354
355/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscustompalettemodecolorpanel?language=objc)
356pub static NSCustomPaletteModeColorPanel: NSColorPanelMode =
357    NSColorPanelMode(NSColorPanelMode::CustomPalette.0);
358
359/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorlistmodecolorpanel?language=objc)
360pub static NSColorListModeColorPanel: NSColorPanelMode =
361    NSColorPanelMode(NSColorPanelMode::ColorList.0);
362
363/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nswheelmodecolorpanel?language=objc)
364pub static NSWheelModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Wheel.0);
365
366/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscrayonmodecolorpanel?language=objc)
367pub static NSCrayonModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Crayon.0);