//! 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::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelresult?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPrintPanelResult(pub NSInteger);
impl NSPrintPanelResult {
    #[doc(alias = "NSPrintPanelResultCancelled")]
    pub const Cancelled: Self = Self(0);
    #[doc(alias = "NSPrintPanelResultPrinted")]
    pub const Printed: Self = Self(1);
}

unsafe impl Encode for NSPrintPanelResult {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpaneloptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPrintPanelOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSPrintPanelOptions: NSUInteger {
        #[doc(alias = "NSPrintPanelShowsCopies")]
        const ShowsCopies = 1<<0;
        #[doc(alias = "NSPrintPanelShowsPageRange")]
        const ShowsPageRange = 1<<1;
        #[doc(alias = "NSPrintPanelShowsPaperSize")]
        const ShowsPaperSize = 1<<2;
        #[doc(alias = "NSPrintPanelShowsOrientation")]
        const ShowsOrientation = 1<<3;
        #[doc(alias = "NSPrintPanelShowsScaling")]
        const ShowsScaling = 1<<4;
        #[doc(alias = "NSPrintPanelShowsPrintSelection")]
        const ShowsPrintSelection = 1<<5;
        #[doc(alias = "NSPrintPanelShowsPageSetupAccessory")]
        const ShowsPageSetupAccessory = 1<<8;
        #[doc(alias = "NSPrintPanelShowsPreview")]
        const ShowsPreview = 1<<17;
    }
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpaneljobstylehint?language=objc)
// NS_TYPED_ENUM
pub type NSPrintPanelJobStyleHint = NSString;

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

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorysummarykey?language=objc)
// NS_TYPED_ENUM
pub type NSPrintPanelAccessorySummaryKey = NSString;

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

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

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanelaccessorizing?language=objc)
    pub unsafe trait NSPrintPanelAccessorizing: MainThreadOnly {
        #[unsafe(method(localizedSummaryItems))]
        #[unsafe(method_family = none)]
        fn localizedSummaryItems(
            &self,
        ) -> Retained<NSArray<NSDictionary<NSPrintPanelAccessorySummaryKey, NSString>>>;

        #[optional]
        #[unsafe(method(keyPathsForValuesAffectingPreview))]
        #[unsafe(method_family = none)]
        fn keyPathsForValuesAffectingPreview(&self) -> Retained<NSSet<NSString>>;
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsprintpanel?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSPrintPanel;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSPrintPanel {}
);

impl NSPrintPanel {
    extern_methods!(
        #[unsafe(method(printPanel))]
        #[unsafe(method_family = none)]
        pub fn printPanel(mtm: MainThreadMarker) -> Retained<NSPrintPanel>;

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        /// # Safety
        ///
        /// `accessory_controller` must implement NSPrintPanelAccessorizing.
        #[unsafe(method(addAccessoryController:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addAccessoryController(&self, accessory_controller: &NSViewController);

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        /// # Safety
        ///
        /// `accessory_controller` must implement NSPrintPanelAccessorizing.
        #[unsafe(method(removeAccessoryController:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAccessoryController(&self, accessory_controller: &NSViewController);

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[unsafe(method(accessoryControllers))]
        #[unsafe(method_family = none)]
        pub fn accessoryControllers(&self) -> Retained<NSArray<NSViewController>>;

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

        /// Setter for [`options`][Self::options].
        #[unsafe(method(setOptions:))]
        #[unsafe(method_family = none)]
        pub fn setOptions(&self, options: NSPrintPanelOptions);

        #[unsafe(method(setDefaultButtonTitle:))]
        #[unsafe(method_family = none)]
        pub fn setDefaultButtonTitle(&self, default_button_title: Option<&NSString>);

        #[unsafe(method(defaultButtonTitle))]
        #[unsafe(method_family = none)]
        pub fn defaultButtonTitle(&self) -> Option<Retained<NSString>>;

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

        #[cfg(feature = "NSHelpManager")]
        /// Setter for [`helpAnchor`][Self::helpAnchor].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setHelpAnchor:))]
        #[unsafe(method_family = none)]
        pub fn setHelpAnchor(&self, help_anchor: Option<&NSHelpAnchorName>);

        #[unsafe(method(jobStyleHint))]
        #[unsafe(method_family = none)]
        pub fn jobStyleHint(&self) -> Option<Retained<NSPrintPanelJobStyleHint>>;

        /// Setter for [`jobStyleHint`][Self::jobStyleHint].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setJobStyleHint:))]
        #[unsafe(method_family = none)]
        pub fn setJobStyleHint(&self, job_style_hint: Option<&NSPrintPanelJobStyleHint>);

        #[cfg(all(
            feature = "NSPrintInfo",
            feature = "NSResponder",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[unsafe(method(beginSheetUsingPrintInfo:onWindow:completionHandler:))]
        #[unsafe(method_family = none)]
        pub fn beginSheetUsingPrintInfo_onWindow_completionHandler(
            &self,
            print_info: &NSPrintInfo,
            parent_window: &NSWindow,
            handler: Option<&block2::DynBlock<dyn Fn(NSPrintPanelResult)>>,
        );

        #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder", feature = "NSWindow"))]
        /// # Safety
        ///
        /// - `delegate` should be of the correct type.
        /// - `did_end_selector` must be a valid selector.
        /// - `context_info` must be a valid pointer or null.
        #[deprecated]
        #[unsafe(method(beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo(
            &self,
            print_info: &NSPrintInfo,
            doc_window: &NSWindow,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[cfg(feature = "NSPrintInfo")]
        #[unsafe(method(runModalWithPrintInfo:))]
        #[unsafe(method_family = none)]
        pub fn runModalWithPrintInfo(&self, print_info: &NSPrintInfo) -> NSInteger;

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

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

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

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// NSDeprecated.
impl NSPrintPanel {
    extern_methods!(
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -addAccessoryController instead"]
        #[unsafe(method(setAccessoryView:))]
        #[unsafe(method_family = none)]
        pub fn setAccessoryView(&self, accessory_view: Option<&NSView>);

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -accessoryControllers instead. For compatibility this returns the view of the first accessory controller, or nil"]
        #[unsafe(method(accessoryView))]
        #[unsafe(method_family = none)]
        pub fn accessoryView(&self) -> Option<Retained<NSView>>;

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

        #[deprecated]
        #[unsafe(method(finalWritePrintInfo))]
        #[unsafe(method_family = none)]
        pub fn finalWritePrintInfo(&self);
    );
}
