objc2-pdf-kit 0.3.2

Bindings to the PDFKit framework
Documentation
//! 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-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfareaofinterest?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFAreaOfInterest(pub NSInteger);
bitflags::bitflags! {
    impl PDFAreaOfInterest: NSInteger {
        #[doc(alias = "kPDFNoArea")]
        const NoArea = 0;
        #[doc(alias = "kPDFPageArea")]
        const PageArea = 1<<0;
        #[doc(alias = "kPDFTextArea")]
        const TextArea = 1<<1;
        #[doc(alias = "kPDFAnnotationArea")]
        const AnnotationArea = 1<<2;
        #[doc(alias = "kPDFLinkArea")]
        const LinkArea = 1<<3;
        #[doc(alias = "kPDFControlArea")]
        const ControlArea = 1<<4;
        #[doc(alias = "kPDFTextFieldArea")]
        const TextFieldArea = 1<<5;
        #[doc(alias = "kPDFIconArea")]
        const IconArea = 1<<6;
        #[doc(alias = "kPDFPopupArea")]
        const PopupArea = 1<<7;
        #[doc(alias = "kPDFImageArea")]
        const ImageArea = 1<<8;
        #[doc(alias = "kPDFAnyArea")]
        const AnyArea = NSIntegerMax as _;
    }
}

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

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

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfdisplaybox?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFDisplayBox(pub NSInteger);
impl PDFDisplayBox {
    #[doc(alias = "kPDFDisplayBoxMediaBox")]
    pub const MediaBox: Self = Self(0);
    #[doc(alias = "kPDFDisplayBoxCropBox")]
    pub const CropBox: Self = Self(1);
    #[doc(alias = "kPDFDisplayBoxBleedBox")]
    pub const BleedBox: Self = Self(2);
    #[doc(alias = "kPDFDisplayBoxTrimBox")]
    pub const TrimBox: Self = Self(3);
    #[doc(alias = "kPDFDisplayBoxArtBox")]
    pub const ArtBox: Self = Self(4);
}

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

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

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

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

extern_conformance!(
    unsafe impl NSCopying for PDFPage {}
);

unsafe impl CopyingHelper for PDFPage {
    type Result = Self;
}

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

impl PDFPage {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// # Safety
        ///
        /// `options` generic should be of the correct type.
        #[unsafe(method(initWithImage:options:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage_options(
            this: Allocated<Self>,
            image: &NSImage,
            options: &NSDictionary<PDFPageImageInitializationOption, AnyObject>,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(initWithImage:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithImage(
            this: Allocated<Self>,
            image: &NSImage,
        ) -> Option<Retained<Self>>;

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

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(pageRef))]
        #[unsafe(method_family = none)]
        pub unsafe fn pageRef(&self) -> Option<Retained<CGPDFPage>>;

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

        #[unsafe(method(boundsForBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn boundsForBox(&self, r#box: PDFDisplayBox) -> NSRect;

        #[unsafe(method(setBounds:forBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBounds_forBox(&self, bounds: NSRect, r#box: PDFDisplayBox);

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

        /// Setter for [`rotation`][Self::rotation].
        #[unsafe(method(setRotation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRotation(&self, rotation: NSInteger);

        #[cfg(feature = "PDFAnnotation")]
        #[unsafe(method(annotations))]
        #[unsafe(method_family = none)]
        pub unsafe fn annotations(&self) -> Retained<NSArray<PDFAnnotation>>;

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

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

        #[cfg(feature = "PDFAnnotation")]
        #[unsafe(method(addAnnotation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addAnnotation(&self, annotation: &PDFAnnotation);

        #[cfg(feature = "PDFAnnotation")]
        #[unsafe(method(removeAnnotation:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAnnotation(&self, annotation: &PDFAnnotation);

        #[cfg(feature = "PDFAnnotation")]
        #[unsafe(method(annotationAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn annotationAtPoint(&self, point: NSPoint) -> Option<Retained<PDFAnnotation>>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(transformForBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn transformForBox(&self, r#box: PDFDisplayBox) -> CGAffineTransform;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(drawWithBox:toContext:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawWithBox_toContext(&self, r#box: PDFDisplayBox, context: &CGContext);

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(transformContext:forBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn transformContext_forBox(&self, context: &CGContext, r#box: PDFDisplayBox);

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(thumbnailOfSize:forBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn thumbnailOfSize_forBox(
            &self,
            size: NSSize,
            r#box: PDFDisplayBox,
        ) -> Retained<NSImage>;

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

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

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

        #[unsafe(method(characterBoundsAtIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn characterBoundsAtIndex(&self, index: NSInteger) -> NSRect;

        #[unsafe(method(characterIndexAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn characterIndexAtPoint(&self, point: NSPoint) -> NSInteger;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionForRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionForRect(&self, rect: NSRect) -> Option<Retained<PDFSelection>>;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionForWordAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionForWordAtPoint(
            &self,
            point: NSPoint,
        ) -> Option<Retained<PDFSelection>>;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionForLineAtPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionForLineAtPoint(
            &self,
            point: NSPoint,
        ) -> Option<Retained<PDFSelection>>;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionFromPoint:toPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionFromPoint_toPoint(
            &self,
            start_point: NSPoint,
            end_point: NSPoint,
        ) -> Option<Retained<PDFSelection>>;

        #[cfg(feature = "PDFSelection")]
        #[unsafe(method(selectionForRange:))]
        #[unsafe(method_family = none)]
        pub unsafe fn selectionForRange(&self, range: NSRange) -> Option<Retained<PDFSelection>>;

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

/// Methods declared on superclass `NSObject`.
impl PDFPage {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

/// PDFPageDeprecated.
impl PDFPage {
    extern_methods!(
        #[deprecated]
        #[unsafe(method(drawWithBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawWithBox(&self, r#box: PDFDisplayBox);

        #[deprecated]
        #[unsafe(method(transformContextForBox:))]
        #[unsafe(method_family = none)]
        pub unsafe fn transformContextForBox(&self, r#box: PDFDisplayBox);
    );
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfpageimageinitializationoptionmediabox?language=objc)
    pub static PDFPageImageInitializationOptionMediaBox: &'static PDFPageImageInitializationOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfpageimageinitializationoptionrotation?language=objc)
    pub static PDFPageImageInitializationOptionRotation: &'static PDFPageImageInitializationOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfpageimageinitializationoptionupscaleifsmaller?language=objc)
    pub static PDFPageImageInitializationOptionUpscaleIfSmaller:
        &'static PDFPageImageInitializationOption;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfpageimageinitializationoptioncompressionquality?language=objc)
    pub static PDFPageImageInitializationOptionCompressionQuality:
        &'static PDFPageImageInitializationOption;
}