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

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

        #[cfg(feature = "UIPrinter")]
        /// Use to filter out specific printers from the printer picker.
        /// Evaluate the UIPrinter object and returns YES if the printer should
        /// be shown, NO otherwise.
        /// This delegate can assume that all UIPrinter properties are available
        /// (the contactPrinter: method need not be called).
        /// This method may be called from threads other than the main thread,
        /// and may be called simultaneously from several different threads.
        #[optional]
        #[unsafe(method(printerPickerController:shouldShowPrinter:))]
        #[unsafe(method_family = none)]
        fn printerPickerController_shouldShowPrinter(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
            printer: &UIPrinter,
        ) -> bool;

        #[optional]
        #[unsafe(method(printerPickerControllerWillPresent:))]
        #[unsafe(method_family = none)]
        fn printerPickerControllerWillPresent(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
        );

        #[optional]
        #[unsafe(method(printerPickerControllerDidPresent:))]
        #[unsafe(method_family = none)]
        fn printerPickerControllerDidPresent(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
        );

        #[optional]
        #[unsafe(method(printerPickerControllerWillDismiss:))]
        #[unsafe(method_family = none)]
        fn printerPickerControllerWillDismiss(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
        );

        #[optional]
        #[unsafe(method(printerPickerControllerDidDismiss:))]
        #[unsafe(method_family = none)]
        fn printerPickerControllerDidDismiss(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
        );

        #[optional]
        #[unsafe(method(printerPickerControllerDidSelectPrinter:))]
        #[unsafe(method_family = none)]
        fn printerPickerControllerDidSelectPrinter(
            &self,
            printer_picker_controller: &UIPrinterPickerController,
        );
    }
);

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

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

impl UIPrinterPickerController {
    extern_methods!(
        #[cfg(feature = "UIPrinter")]
        /// This method returns a printer picker controller object for showing the
        /// UI that allows the user to select a printer. This is only used with the
        /// UIPrintInteractionController's printWithoutUIToPrinter: method.
        /// If no printer should be preselected, use a value of nil for the parameter.
        #[unsafe(method(printerPickerControllerWithInitiallySelectedPrinter:))]
        #[unsafe(method_family = none)]
        pub fn printerPickerControllerWithInitiallySelectedPrinter(
            printer: Option<&UIPrinter>,
            mtm: MainThreadMarker,
        ) -> Retained<UIPrinterPickerController>;

        #[cfg(feature = "UIPrinter")]
        /// The selected printer. Set this before presenting the UI to show the currently
        /// selected printer. Use this to determine which printer the user selected.
        #[unsafe(method(selectedPrinter))]
        #[unsafe(method_family = none)]
        pub fn selectedPrinter(&self) -> Option<Retained<UIPrinter>>;

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

        /// 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 UIPrinterPickerControllerDelegate>>,
        );

        #[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: UIPrinterPickerCompletionHandler,
        ) -> 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: UIPrinterPickerCompletionHandler,
        ) -> 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: UIPrinterPickerCompletionHandler,
        ) -> bool;

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

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