//! 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/uikit/uiprintinteractioncompletionhandler?language=objc)
#[cfg(feature = "block2")]
pub type UIPrintInteractionCompletionHandler =
    *mut block2::DynBlock<dyn Fn(NonNull<UIPrintInteractionController>, Bool, *mut NSError)>;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiprintercutterbehavior?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIPrinterCutterBehavior(pub NSInteger);
impl UIPrinterCutterBehavior {
    #[doc(alias = "UIPrinterCutterBehaviorNoCut")]
    pub const NoCut: Self = Self(0);
    #[doc(alias = "UIPrinterCutterBehaviorPrinterDefault")]
    pub const PrinterDefault: Self = Self(1);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachPage")]
    pub const CutAfterEachPage: Self = Self(2);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachCopy")]
    pub const CutAfterEachCopy: Self = Self(3);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachJob")]
    pub const CutAfterEachJob: Self = Self(4);
}

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

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

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

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

impl UIPrintInteractionController {
    extern_methods!(
        #[unsafe(method(isPrintingAvailable))]
        #[unsafe(method_family = none)]
        pub fn isPrintingAvailable(mtm: MainThreadMarker) -> bool;

        #[unsafe(method(printableUTIs))]
        #[unsafe(method_family = none)]
        pub fn printableUTIs(mtm: MainThreadMarker) -> Retained<NSSet<NSString>>;

        #[unsafe(method(canPrintURL:))]
        #[unsafe(method_family = none)]
        pub fn canPrintURL(url: &NSURL, mtm: MainThreadMarker) -> bool;

        #[unsafe(method(canPrintData:))]
        #[unsafe(method_family = none)]
        pub fn canPrintData(data: &NSData, mtm: MainThreadMarker) -> bool;

        #[unsafe(method(sharedPrintController))]
        #[unsafe(method_family = none)]
        pub fn sharedPrintController(
            mtm: MainThreadMarker,
        ) -> Retained<UIPrintInteractionController>;

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

        #[cfg(feature = "UIPrintInfo")]
        /// Setter for [`printInfo`][Self::printInfo].
        #[unsafe(method(setPrintInfo:))]
        #[unsafe(method_family = none)]
        pub fn setPrintInfo(&self, print_info: Option<&UIPrintInfo>);

        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIPrintInteractionControllerDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UIPrintInteractionControllerDelegate>>,
        );

        #[deprecated = "Pages can be removed from the print preview, so page range is always shown."]
        #[unsafe(method(showsPageRange))]
        #[unsafe(method_family = none)]
        pub fn showsPageRange(&self) -> bool;

        /// Setter for [`showsPageRange`][Self::showsPageRange].
        #[deprecated = "Pages can be removed from the print preview, so page range is always shown."]
        #[unsafe(method(setShowsPageRange:))]
        #[unsafe(method_family = none)]
        pub fn setShowsPageRange(&self, shows_page_range: bool);

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

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

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

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

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

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

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

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

        #[cfg(feature = "UIPrintPageRenderer")]
        /// Setter for [`printPageRenderer`][Self::printPageRenderer].
        #[unsafe(method(setPrintPageRenderer:))]
        #[unsafe(method_family = none)]
        pub fn setPrintPageRenderer(&self, print_page_renderer: Option<&UIPrintPageRenderer>);

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

        #[cfg(feature = "UIPrintFormatter")]
        /// Setter for [`printFormatter`][Self::printFormatter].
        #[unsafe(method(setPrintFormatter:))]
        #[unsafe(method_family = none)]
        pub fn setPrintFormatter(&self, print_formatter: Option<&UIPrintFormatter>);

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

        /// Setter for [`printingItem`][Self::printingItem].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `printing_item` should be of the correct type.
        #[unsafe(method(setPrintingItem:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPrintingItem(&self, printing_item: Option<&AnyObject>);

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

        /// Setter for [`printingItems`][Self::printingItems].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `printing_items` generic should be of the correct type.
        #[unsafe(method(setPrintingItems:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPrintingItems(&self, printing_items: Option<&NSArray>);

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `completion` must be a valid pointer or null.
        #[unsafe(method(presentAnimated:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentAnimated_completionHandler(
            &self,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(
            feature = "UIResponder",
            feature = "UIView",
            feature = "block2",
            feature = "objc2-core-foundation"
        ))]
        /// # Safety
        ///
        /// `completion` must be a valid pointer or null.
        #[unsafe(method(presentFromRect:inView:animated:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentFromRect_inView_animated_completionHandler(
            &self,
            rect: CGRect,
            view: &UIView,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem", feature = "block2"))]
        /// # Safety
        ///
        /// `completion` must be a valid pointer or null.
        #[unsafe(method(presentFromBarButtonItem:animated:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn presentFromBarButtonItem_animated_completionHandler(
            &self,
            item: &UIBarButtonItem,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(feature = "UIPrinter", feature = "block2"))]
        /// Use to print without showing the standard print panel. Use with a
        /// UIPrinter found using the UIPrinterPickerController.
        /// The value for the duplex property on printInfo will be ignored.
        ///
        /// # Safety
        ///
        /// `completion` must be a valid pointer or null.
        #[unsafe(method(printToPrinter:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn printToPrinter_completionHandler(
            &self,
            printer: &UIPrinter,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[unsafe(method(dismissAnimated:))]
        #[unsafe(method_family = none)]
        pub fn dismissAnimated(&self, animated: bool);
    );
}

/// Methods declared on superclass `NSObject`.
impl UIPrintInteractionController {
    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>;
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiprintinteractioncontrollerdelegate?language=objc)
    pub unsafe trait UIPrintInteractionControllerDelegate:
        NSObjectProtocol + MainThreadOnly
    {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[unsafe(method(printInteractionControllerParentViewController:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerParentViewController(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        ) -> Option<Retained<UIViewController>>;

        #[cfg(feature = "UIPrintPaper")]
        #[optional]
        #[unsafe(method(printInteractionController:choosePaper:))]
        #[unsafe(method_family = none)]
        fn printInteractionController_choosePaper(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            paper_list: &NSArray<UIPrintPaper>,
        ) -> Retained<UIPrintPaper>;

        #[optional]
        #[unsafe(method(printInteractionControllerWillPresentPrinterOptions:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerWillPresentPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[unsafe(method(printInteractionControllerDidPresentPrinterOptions:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerDidPresentPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[unsafe(method(printInteractionControllerWillDismissPrinterOptions:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerWillDismissPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[unsafe(method(printInteractionControllerDidDismissPrinterOptions:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerDidDismissPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[unsafe(method(printInteractionControllerWillStartJob:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerWillStartJob(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[unsafe(method(printInteractionControllerDidFinishJob:))]
        #[unsafe(method_family = none)]
        fn printInteractionControllerDidFinishJob(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[cfg(all(feature = "UIPrintPaper", feature = "objc2-core-foundation"))]
        #[optional]
        #[unsafe(method(printInteractionController:cutLengthForPaper:))]
        #[unsafe(method_family = none)]
        fn printInteractionController_cutLengthForPaper(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            paper: &UIPrintPaper,
        ) -> CGFloat;

        /// # Safety
        ///
        /// `available_behaviors` generic should be of the correct type.
        #[optional]
        #[unsafe(method(printInteractionController:chooseCutterBehavior:))]
        #[unsafe(method_family = none)]
        unsafe fn printInteractionController_chooseCutterBehavior(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            available_behaviors: &NSArray,
        ) -> UIPrinterCutterBehavior;
    }
);
