//! 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/nsdrawerstate?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSDrawerState(pub NSUInteger);
impl NSDrawerState {
    #[doc(alias = "NSDrawerClosedState")]
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub const ClosedState: Self = Self(0);
    #[doc(alias = "NSDrawerOpeningState")]
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub const OpeningState: Self = Self(1);
    #[doc(alias = "NSDrawerOpenState")]
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub const OpenState: Self = Self(2);
    #[doc(alias = "NSDrawerClosingState")]
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub const ClosingState: Self = Self(3);
}

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

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

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawer?language=objc)
    #[unsafe(super(NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSResponder")]
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub struct NSDrawer;
);

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

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

#[cfg(feature = "NSResponder")]
extern_conformance!(
    unsafe impl NSCoding for NSDrawer {}
);

#[cfg(feature = "NSResponder")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSDrawer {}
);

#[cfg(feature = "NSResponder")]
impl NSDrawer {
    extern_methods!(
        #[unsafe(method(initWithContentSize:preferredEdge:))]
        #[unsafe(method_family = init)]
        pub fn initWithContentSize_preferredEdge(
            this: Allocated<Self>,
            content_size: NSSize,
            edge: NSRectEdge,
        ) -> Retained<Self>;

        #[cfg(feature = "NSWindow")]
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(parentWindow))]
        #[unsafe(method_family = none)]
        pub unsafe fn parentWindow(&self) -> Option<Retained<NSWindow>>;

        #[cfg(feature = "NSWindow")]
        /// Setter for [`parentWindow`][Self::parentWindow].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setParentWindow:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setParentWindow(&self, parent_window: Option<&NSWindow>);

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

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

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

        /// Setter for [`preferredEdge`][Self::preferredEdge].
        #[unsafe(method(setPreferredEdge:))]
        #[unsafe(method_family = none)]
        pub fn setPreferredEdge(&self, preferred_edge: NSRectEdge);

        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSDrawerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// # Safety
        ///
        /// This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSDrawerDelegate>>);

        #[unsafe(method(open))]
        #[unsafe(method_family = none)]
        pub fn open(&self);

        #[unsafe(method(openOnEdge:))]
        #[unsafe(method_family = none)]
        pub fn openOnEdge(&self, edge: NSRectEdge);

        #[unsafe(method(close))]
        #[unsafe(method_family = none)]
        pub fn close(&self);

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

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

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

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

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

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

        /// Setter for [`contentSize`][Self::contentSize].
        #[unsafe(method(setContentSize:))]
        #[unsafe(method_family = none)]
        pub fn setContentSize(&self, content_size: NSSize);

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

        /// Setter for [`minContentSize`][Self::minContentSize].
        #[unsafe(method(setMinContentSize:))]
        #[unsafe(method_family = none)]
        pub fn setMinContentSize(&self, min_content_size: NSSize);

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

        /// Setter for [`maxContentSize`][Self::maxContentSize].
        #[unsafe(method(setMaxContentSize:))]
        #[unsafe(method_family = none)]
        pub fn setMaxContentSize(&self, max_content_size: NSSize);

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

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

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

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

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

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

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

/// NSDrawers.
#[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
impl NSWindow {
    extern_methods!(
        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[unsafe(method(drawers))]
        #[unsafe(method_family = none)]
        pub fn drawers(&self) -> Option<Retained<NSArray<NSDrawer>>>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawerdelegate?language=objc)
    pub unsafe trait NSDrawerDelegate: NSObjectProtocol {
        #[cfg(feature = "NSResponder")]
        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerShouldOpen:))]
        #[unsafe(method_family = none)]
        fn drawerShouldOpen(&self, sender: &NSDrawer) -> bool;

        #[cfg(feature = "NSResponder")]
        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerShouldClose:))]
        #[unsafe(method_family = none)]
        fn drawerShouldClose(&self, sender: &NSDrawer) -> bool;

        #[cfg(feature = "NSResponder")]
        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerWillResizeContents:toSize:))]
        #[unsafe(method_family = none)]
        fn drawerWillResizeContents_toSize(
            &self,
            sender: &NSDrawer,
            content_size: NSSize,
        ) -> NSSize;

        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerWillOpen:))]
        #[unsafe(method_family = none)]
        fn drawerWillOpen(&self, notification: &NSNotification);

        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerDidOpen:))]
        #[unsafe(method_family = none)]
        fn drawerDidOpen(&self, notification: &NSNotification);

        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerWillClose:))]
        #[unsafe(method_family = none)]
        fn drawerWillClose(&self, notification: &NSNotification);

        #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
        #[optional]
        #[unsafe(method(drawerDidClose:))]
        #[unsafe(method_family = none)]
        fn drawerDidClose(&self, notification: &NSNotification);
    }
);

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawerwillopennotification?language=objc)
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub static NSDrawerWillOpenNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawerdidopennotification?language=objc)
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub static NSDrawerDidOpenNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawerwillclosenotification?language=objc)
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub static NSDrawerWillCloseNotification: &'static NSNotificationName;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsdrawerdidclosenotification?language=objc)
    #[deprecated = "Drawers are deprecated; consider using NSSplitViewController"]
    pub static NSDrawerDidCloseNotification: &'static NSNotificationName;
}
