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))]
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        /// Setter for [`accessoryView`][Self::accessoryView].
205        #[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        /// Setter for [`isContinuous`][Self::isContinuous].
214        #[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        /// Setter for [`showsAlpha`][Self::showsAlpha].
223        #[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        /// Setter for [`mode`][Self::mode].
232        #[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        /// Setter for [`color`][Self::color].
243        ///
244        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
245        #[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        /// # Safety
255        ///
256        /// `selector` must be a valid selector.
257        #[unsafe(method(setAction:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn setAction(&self, selector: Option<Sel>);
260
261        /// # Safety
262        ///
263        /// `target` should be of the correct type.
264        #[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        /// The maximum linear exposure that can be set on a color picked in the color panel. Defaults to 1 and ignores any value less than 1. If set to a value >= 2, the color picked by the panel may have a linear exposure applied to it.
280        #[unsafe(method(maximumLinearExposure))]
281        #[unsafe(method_family = none)]
282        pub fn maximumLinearExposure(&self) -> CGFloat;
283
284        #[cfg(feature = "objc2-core-foundation")]
285        /// Setter for [`maximumLinearExposure`][Self::maximumLinearExposure].
286        #[unsafe(method(setMaximumLinearExposure:))]
287        #[unsafe(method_family = none)]
288        pub fn setMaximumLinearExposure(&self, maximum_linear_exposure: CGFloat);
289    );
290}
291
292/// Methods declared on superclass `NSWindow`.
293#[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        /// # Safety
320        ///
321        /// `coder` possibly has further requirements.
322        #[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        /// 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].
328        #[unsafe(method(windowWithContentViewController:))]
329        #[unsafe(method_family = none)]
330        pub fn windowWithContentViewController(
331            content_view_controller: &NSViewController,
332        ) -> Retained<Self>;
333    );
334}
335
336/// Methods declared on superclass `NSResponder`.
337#[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/// Methods declared on superclass `NSObject`.
347#[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/// NSColorPanel.
357#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
358impl NSApplication {
359    extern_methods!(
360        /// # Safety
361        ///
362        /// `sender` should be of the correct type.
363        #[unsafe(method(orderFrontColorPanel:))]
364        #[unsafe(method_family = none)]
365        pub unsafe fn orderFrontColorPanel(&self, sender: Option<&AnyObject>);
366    );
367}
368
369extern_protocol!(
370    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorchanging?language=objc)
371    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    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanelcolordidchangenotification?language=objc)
381    pub static NSColorPanelColorDidChangeNotification: &'static NSNotificationName;
382}
383
384/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsnomodecolorpanel?language=objc)
385#[deprecated]
386pub static NSNoModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::None.0);
387
388/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraymodecolorpanel?language=objc)
389#[deprecated]
390pub static NSGrayModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Gray.0);
391
392/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrgbmodecolorpanel?language=objc)
393#[deprecated]
394pub static NSRGBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::RGB.0);
395
396/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscmykmodecolorpanel?language=objc)
397#[deprecated]
398pub static NSCMYKModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::CMYK.0);
399
400/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshsbmodecolorpanel?language=objc)
401#[deprecated]
402pub static NSHSBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::HSB.0);
403
404/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscustompalettemodecolorpanel?language=objc)
405#[deprecated]
406pub static NSCustomPaletteModeColorPanel: NSColorPanelMode =
407    NSColorPanelMode(NSColorPanelMode::CustomPalette.0);
408
409/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorlistmodecolorpanel?language=objc)
410#[deprecated]
411pub static NSColorListModeColorPanel: NSColorPanelMode =
412    NSColorPanelMode(NSColorPanelMode::ColorList.0);
413
414/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nswheelmodecolorpanel?language=objc)
415#[deprecated]
416pub static NSWheelModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Wheel.0);
417
418/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscrayonmodecolorpanel?language=objc)
419#[deprecated]
420pub static NSCrayonModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Crayon.0);