//! 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/uigraphicspdfdrawingactions?language=objc)
#[cfg(all(feature = "UIGraphicsRenderer", feature = "block2"))]
pub type UIGraphicsPDFDrawingActions =
    *mut block2::DynBlock<dyn Fn(NonNull<UIGraphicsPDFRendererContext>)>;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicspdfrendererformat?language=objc)
    #[unsafe(super(UIGraphicsRendererFormat, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsPDFRendererFormat;
);

#[cfg(feature = "UIGraphicsRenderer")]
extern_conformance!(
    unsafe impl NSCopying for UIGraphicsPDFRendererFormat {}
);

#[cfg(feature = "UIGraphicsRenderer")]
unsafe impl CopyingHelper for UIGraphicsPDFRendererFormat {
    type Result = Self;
}

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

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRendererFormat {
    extern_methods!(
        #[unsafe(method(documentInfo))]
        #[unsafe(method_family = none)]
        pub fn documentInfo(&self) -> Retained<NSDictionary<NSString, AnyObject>>;

        /// Setter for [`documentInfo`][Self::documentInfo].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        ///
        /// # Safety
        ///
        /// `document_info` generic should be of the correct type.
        #[unsafe(method(setDocumentInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDocumentInfo(&self, document_info: &NSDictionary<NSString, AnyObject>);
    );
}

/// Methods declared on superclass `UIGraphicsRendererFormat`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRendererFormat {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(defaultFormat))]
        #[unsafe(method_family = none)]
        pub fn defaultFormat() -> Retained<Self>;

        #[unsafe(method(preferredFormat))]
        #[unsafe(method_family = none)]
        pub fn preferredFormat() -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRendererFormat {
    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() -> Retained<Self>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsPDFRendererFormat {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicspdfrenderercontext?language=objc)
    #[unsafe(super(UIGraphicsRendererContext, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsPDFRendererContext;
);

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

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRendererContext {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(pdfContextBounds))]
        #[unsafe(method_family = none)]
        pub fn pdfContextBounds(&self) -> CGRect;

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

        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// `page_info` generic should be of the correct type.
        #[unsafe(method(beginPageWithBounds:pageInfo:))]
        #[unsafe(method_family = none)]
        pub unsafe fn beginPageWithBounds_pageInfo(
            &self,
            bounds: CGRect,
            page_info: &NSDictionary<NSString, AnyObject>,
        );

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(setURL:forRect:))]
        #[unsafe(method_family = none)]
        pub fn setURL_forRect(&self, url: &NSURL, rect: CGRect);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(addDestinationWithName:atPoint:))]
        #[unsafe(method_family = none)]
        pub fn addDestinationWithName_atPoint(&self, name: &NSString, point: CGPoint);

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(setDestinationWithName:forRect:))]
        #[unsafe(method_family = none)]
        pub fn setDestinationWithName_forRect(&self, name: &NSString, rect: CGRect);
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRendererContext {
    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() -> Retained<Self>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsPDFRendererContext {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uigraphicspdfrenderer?language=objc)
    #[unsafe(super(UIGraphicsRenderer, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "UIGraphicsRenderer")]
    pub struct UIGraphicsPDFRenderer;
);

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

#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRenderer {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithBounds:format:))]
        #[unsafe(method_family = init)]
        pub fn initWithBounds_format(
            this: Allocated<Self>,
            bounds: CGRect,
            format: &UIGraphicsPDFRendererFormat,
        ) -> Retained<Self>;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `actions` must be a valid pointer.
        #[unsafe(method(writePDFToURL:withActions:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn writePDFToURL_withActions_error(
            &self,
            url: &NSURL,
            actions: UIGraphicsPDFDrawingActions,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "block2")]
        /// # Safety
        ///
        /// `actions` must be a valid pointer.
        #[unsafe(method(PDFDataWithActions:))]
        #[unsafe(method_family = none)]
        pub unsafe fn PDFDataWithActions(
            &self,
            actions: UIGraphicsPDFDrawingActions,
        ) -> Retained<NSData>;
    );
}

/// Methods declared on superclass `UIGraphicsRenderer`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRenderer {
    extern_methods!(
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithBounds:))]
        #[unsafe(method_family = init)]
        pub fn initWithBounds(this: Allocated<Self>, bounds: CGRect) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "UIGraphicsRenderer")]
impl UIGraphicsPDFRenderer {
    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() -> Retained<Self>;
    );
}

#[cfg(feature = "UIGraphicsRenderer")]
impl DefaultRetained for UIGraphicsPDFRenderer {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}
