//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanelmode?language=objc)
// 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);
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpaneloptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSColorPanelOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSColorPanelOptions: NSUInteger {
        #[doc(alias = "NSColorPanelGrayModeMask")]
        const GrayModeMask = 0x00000001;
        #[doc(alias = "NSColorPanelRGBModeMask")]
        const RGBModeMask = 0x00000002;
        #[doc(alias = "NSColorPanelCMYKModeMask")]
        const CMYKModeMask = 0x00000004;
        #[doc(alias = "NSColorPanelHSBModeMask")]
        const HSBModeMask = 0x00000008;
        #[doc(alias = "NSColorPanelCustomPaletteModeMask")]
        const CustomPaletteModeMask = 0x00000010;
        #[doc(alias = "NSColorPanelColorListModeMask")]
        const ColorListModeMask = 0x00000020;
        #[doc(alias = "NSColorPanelWheelModeMask")]
        const WheelModeMask = 0x00000040;
        #[doc(alias = "NSColorPanelCrayonModeMask")]
        const CrayonModeMask = 0x00000080;
        #[doc(alias = "NSColorPanelAllModesMask")]
        const AllModesMask = 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!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanel?language=objc)
    #[unsafe(super(NSPanel, NSWindow, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
    pub struct NSColorPanel;
);

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

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

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

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

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

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

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

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

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

#[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
impl NSColorPanel {
    extern_methods!(
        #[unsafe(method(sharedColorPanel))]
        #[unsafe(method_family = none)]
        pub fn sharedColorPanel(mtm: MainThreadMarker) -> Retained<NSColorPanel>;

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

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

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

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

        #[cfg(feature = "NSView")]
        #[unsafe(method(accessoryView))]
        #[unsafe(method_family = none)]
        pub fn accessoryView(&self) -> Option<Retained<NSView>>;

        #[cfg(feature = "NSView")]
        /// Setter for [`accessoryView`][Self::accessoryView].
        #[unsafe(method(setAccessoryView:))]
        #[unsafe(method_family = none)]
        pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);

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

        /// Setter for [`isContinuous`][Self::isContinuous].
        #[unsafe(method(setContinuous:))]
        #[unsafe(method_family = none)]
        pub fn setContinuous(&self, continuous: bool);

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

        /// Setter for [`showsAlpha`][Self::showsAlpha].
        #[unsafe(method(setShowsAlpha:))]
        #[unsafe(method_family = none)]
        pub fn setShowsAlpha(&self, shows_alpha: bool);

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

        /// Setter for [`mode`][Self::mode].
        #[unsafe(method(setMode:))]
        #[unsafe(method_family = none)]
        pub fn setMode(&self, mode: NSColorPanelMode);

        #[cfg(feature = "NSColor")]
        #[unsafe(method(color))]
        #[unsafe(method_family = none)]
        pub fn color(&self) -> Retained<NSColor>;

        #[cfg(feature = "NSColor")]
        /// Setter for [`color`][Self::color].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setColor:))]
        #[unsafe(method_family = none)]
        pub fn setColor(&self, color: &NSColor);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(alpha))]
        #[unsafe(method_family = none)]
        pub fn alpha(&self) -> CGFloat;

        /// # Safety
        ///
        /// `selector` must be a valid selector.
        #[unsafe(method(setAction:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAction(&self, selector: Option<Sel>);

        /// # Safety
        ///
        /// `target` should be of the correct type.
        #[unsafe(method(setTarget:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTarget(&self, target: Option<&AnyObject>);

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

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

        #[cfg(feature = "objc2-core-foundation")]
        /// 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.
        #[unsafe(method(maximumLinearExposure))]
        #[unsafe(method_family = none)]
        pub fn maximumLinearExposure(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`maximumLinearExposure`][Self::maximumLinearExposure].
        #[unsafe(method(setMaximumLinearExposure:))]
        #[unsafe(method_family = none)]
        pub fn setMaximumLinearExposure(&self, maximum_linear_exposure: CGFloat);
    );
}

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

        #[cfg(all(feature = "NSGraphics", feature = "NSScreen"))]
        #[unsafe(method(initWithContentRect:styleMask:backing:defer:screen:))]
        #[unsafe(method_family = init)]
        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>,
        ) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(this: Allocated<Self>, coder: &NSCoder) -> Retained<Self>;

        #[cfg(feature = "NSViewController")]
        /// 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].
        #[unsafe(method(windowWithContentViewController:))]
        #[unsafe(method_family = none)]
        pub fn windowWithContentViewController(
            content_view_controller: &NSViewController,
        ) -> Retained<Self>;
    );
}

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

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

/// NSColorPanel.
#[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
impl NSApplication {
    extern_methods!(
        /// # Safety
        ///
        /// `sender` should be of the correct type.
        #[unsafe(method(orderFrontColorPanel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn orderFrontColorPanel(&self, sender: Option<&AnyObject>);
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorchanging?language=objc)
    pub unsafe trait NSColorChanging: NSObjectProtocol {
        #[cfg(all(feature = "NSPanel", feature = "NSResponder", feature = "NSWindow"))]
        #[unsafe(method(changeColor:))]
        #[unsafe(method_family = none)]
        fn changeColor(&self, sender: Option<&NSColorPanel>);
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorpanelcolordidchangenotification?language=objc)
    pub static NSColorPanelColorDidChangeNotification: &'static NSNotificationName;
}

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsnomodecolorpanel?language=objc)
#[deprecated]
pub static NSNoModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::None.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgraymodecolorpanel?language=objc)
#[deprecated]
pub static NSGrayModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Gray.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsrgbmodecolorpanel?language=objc)
#[deprecated]
pub static NSRGBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::RGB.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscmykmodecolorpanel?language=objc)
#[deprecated]
pub static NSCMYKModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::CMYK.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nshsbmodecolorpanel?language=objc)
#[deprecated]
pub static NSHSBModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::HSB.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscustompalettemodecolorpanel?language=objc)
#[deprecated]
pub static NSCustomPaletteModeColorPanel: NSColorPanelMode =
    NSColorPanelMode(NSColorPanelMode::CustomPalette.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorlistmodecolorpanel?language=objc)
#[deprecated]
pub static NSColorListModeColorPanel: NSColorPanelMode =
    NSColorPanelMode(NSColorPanelMode::ColorList.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nswheelmodecolorpanel?language=objc)
#[deprecated]
pub static NSWheelModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Wheel.0);

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscrayonmodecolorpanel?language=objc)
#[deprecated]
pub static NSCrayonModeColorPanel: NSColorPanelMode = NSColorPanelMode(NSColorPanelMode::Crayon.0);
