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

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/pdfkit/pdfselectiongranularity?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PDFSelectionGranularity(pub NSUInteger);
impl PDFSelectionGranularity {
    #[doc(alias = "PDFSelectionGranularityCharacter")]
    pub const Character: Self = Self(0);
    #[doc(alias = "PDFSelectionGranularityWord")]
    pub const Word: Self = Self(1);
    #[doc(alias = "PDFSelectionGranularityLine")]
    pub const Line: Self = Self(2);
}

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

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

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

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

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

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

impl PDFSelection {
    extern_methods!(
        #[cfg(feature = "PDFDocument")]
        #[unsafe(method(initWithDocument:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithDocument(
            this: Allocated<Self>,
            document: &PDFDocument,
        ) -> Retained<Self>;

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

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        #[unsafe(method(color))]
        #[unsafe(method_family = none)]
        pub unsafe fn color(&self) -> Option<Retained<NSColor>>;

        #[cfg(feature = "objc2-app-kit")]
        #[cfg(target_os = "macos")]
        /// Setter for [`color`][Self::color].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setColor(&self, color: Option<&NSColor>);

        #[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>>;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(boundsForPage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn boundsForPage(&self, page: &PDFPage) -> NSRect;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(numberOfTextRangesOnPage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfTextRangesOnPage(&self, page: &PDFPage) -> NSUInteger;

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(rangeAtIndex:onPage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn rangeAtIndex_onPage(&self, index: NSUInteger, page: &PDFPage) -> NSRange;

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

        #[unsafe(method(addSelection:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addSelection(&self, selection: &PDFSelection);

        #[unsafe(method(addSelections:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addSelections(&self, selections: &NSArray<PDFSelection>);

        #[unsafe(method(extendSelectionAtEnd:))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendSelectionAtEnd(&self, succeed: NSInteger);

        #[unsafe(method(extendSelectionAtStart:))]
        #[unsafe(method_family = none)]
        pub unsafe fn extendSelectionAtStart(&self, precede: NSInteger);

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

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(drawForPage:active:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawForPage_active(&self, page: &PDFPage, active: bool);

        #[cfg(feature = "PDFPage")]
        #[unsafe(method(drawForPage:withBox:active:))]
        #[unsafe(method_family = none)]
        pub unsafe fn drawForPage_withBox_active(
            &self,
            page: &PDFPage,
            r#box: PDFDisplayBox,
            active: bool,
        );
    );
}

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

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