objc2-app-kit 0.2.2

Bindings to the AppKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPrintPanelResult(pub NSInteger);
impl NSPrintPanelResult {
    #[doc(alias = "NSPrintPanelResultCancelled")]
    pub const Cancelled: Self = Self(0);
    #[doc(alias = "NSPrintPanelResultPrinted")]
    pub const Printed: Self = Self(1);
}

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

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

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSPrintPanelOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSPrintPanelOptions: NSUInteger {
        const NSPrintPanelShowsCopies = 1<<0;
        const NSPrintPanelShowsPageRange = 1<<1;
        const NSPrintPanelShowsPaperSize = 1<<2;
        const NSPrintPanelShowsOrientation = 1<<3;
        const NSPrintPanelShowsScaling = 1<<4;
        const NSPrintPanelShowsPrintSelection = 1<<5;
        const NSPrintPanelShowsPageSetupAccessory = 1<<8;
        const NSPrintPanelShowsPreview = 1<<17;
    }
}

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

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

// NS_TYPED_ENUM
pub type NSPrintPanelJobStyleHint = NSString;

extern "C" {
    pub static NSPrintPhotoJobStyleHint: &'static NSPrintPanelJobStyleHint;
}

extern "C" {
    pub static NSPrintAllPresetsJobStyleHint: &'static NSPrintPanelJobStyleHint;
}

extern "C" {
    pub static NSPrintNoPresetsJobStyleHint: &'static NSPrintPanelJobStyleHint;
}

// NS_TYPED_ENUM
pub type NSPrintPanelAccessorySummaryKey = NSString;

extern "C" {
    pub static NSPrintPanelAccessorySummaryItemNameKey: &'static NSPrintPanelAccessorySummaryKey;
}

extern "C" {
    pub static NSPrintPanelAccessorySummaryItemDescriptionKey:
        &'static NSPrintPanelAccessorySummaryKey;
}

extern_protocol!(
    pub unsafe trait NSPrintPanelAccessorizing: IsMainThreadOnly {
        #[method_id(@__retain_semantics Other localizedSummaryItems)]
        unsafe fn localizedSummaryItems(
            &self,
        ) -> Retained<NSArray<NSDictionary<NSPrintPanelAccessorySummaryKey, NSString>>>;

        #[optional]
        #[method_id(@__retain_semantics Other keyPathsForValuesAffectingPreview)]
        unsafe fn keyPathsForValuesAffectingPreview(&self) -> Retained<NSSet<NSString>>;
    }

    unsafe impl ProtocolType for dyn NSPrintPanelAccessorizing {}
);

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSPrintPanel;

    unsafe impl ClassType for NSPrintPanel {
        type Super = NSObject;
        type Mutability = MainThreadOnly;
    }
);

unsafe impl NSObjectProtocol for NSPrintPanel {}

extern_methods!(
    unsafe impl NSPrintPanel {
        #[method_id(@__retain_semantics Other printPanel)]
        pub unsafe fn printPanel(mtm: MainThreadMarker) -> Retained<NSPrintPanel>;

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[method(addAccessoryController:)]
        pub unsafe fn addAccessoryController(&self, accessory_controller: &NSViewController);

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[method(removeAccessoryController:)]
        pub unsafe fn removeAccessoryController(&self, accessory_controller: &NSViewController);

        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
        #[method_id(@__retain_semantics Other accessoryControllers)]
        pub unsafe fn accessoryControllers(&self) -> Retained<NSArray<NSViewController>>;

        #[method(options)]
        pub unsafe fn options(&self) -> NSPrintPanelOptions;

        #[method(setOptions:)]
        pub unsafe fn setOptions(&self, options: NSPrintPanelOptions);

        #[method(setDefaultButtonTitle:)]
        pub unsafe fn setDefaultButtonTitle(&self, default_button_title: Option<&NSString>);

        #[method_id(@__retain_semantics Other defaultButtonTitle)]
        pub unsafe fn defaultButtonTitle(&self) -> Option<Retained<NSString>>;

        #[cfg(feature = "NSHelpManager")]
        #[method_id(@__retain_semantics Other helpAnchor)]
        pub unsafe fn helpAnchor(&self) -> Option<Retained<NSHelpAnchorName>>;

        #[cfg(feature = "NSHelpManager")]
        #[method(setHelpAnchor:)]
        pub unsafe fn setHelpAnchor(&self, help_anchor: Option<&NSHelpAnchorName>);

        #[method_id(@__retain_semantics Other jobStyleHint)]
        pub unsafe fn jobStyleHint(&self) -> Option<Retained<NSPrintPanelJobStyleHint>>;

        #[method(setJobStyleHint:)]
        pub unsafe fn setJobStyleHint(&self, job_style_hint: Option<&NSPrintPanelJobStyleHint>);

        #[cfg(all(
            feature = "NSPrintInfo",
            feature = "NSResponder",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[method(beginSheetUsingPrintInfo:onWindow:completionHandler:)]
        pub unsafe fn beginSheetUsingPrintInfo_onWindow_completionHandler(
            &self,
            print_info: &NSPrintInfo,
            parent_window: &NSWindow,
            handler: Option<&block2::Block<dyn Fn(NSPrintPanelResult)>>,
        );

        #[cfg(all(feature = "NSPrintInfo", feature = "NSResponder", feature = "NSWindow"))]
        #[deprecated]
        #[method(beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:)]
        pub unsafe fn beginSheetWithPrintInfo_modalForWindow_delegate_didEndSelector_contextInfo(
            &self,
            print_info: &NSPrintInfo,
            doc_window: &NSWindow,
            delegate: Option<&AnyObject>,
            did_end_selector: Option<Sel>,
            context_info: *mut c_void,
        );

        #[cfg(feature = "NSPrintInfo")]
        #[method(runModalWithPrintInfo:)]
        pub unsafe fn runModalWithPrintInfo(&self, print_info: &NSPrintInfo) -> NSInteger;

        #[method(runModal)]
        pub unsafe fn runModal(&self) -> NSInteger;

        #[cfg(feature = "NSPrintInfo")]
        #[method_id(@__retain_semantics Other printInfo)]
        pub unsafe fn printInfo(&self) -> Retained<NSPrintInfo>;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSPrintPanel {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    }
);

extern_methods!(
    /// NSDeprecated
    unsafe impl NSPrintPanel {
        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -addAccessoryController instead"]
        #[method(setAccessoryView:)]
        pub unsafe fn setAccessoryView(&self, accessory_view: Option<&NSView>);

        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
        #[deprecated = "Use -accessoryControllers instead. For compatibility this returns the view of the first accessory controller, or nil"]
        #[method_id(@__retain_semantics Other accessoryView)]
        pub unsafe fn accessoryView(&self) -> Option<Retained<NSView>>;

        #[deprecated]
        #[method(updateFromPrintInfo)]
        pub unsafe fn updateFromPrintInfo(&self);

        #[deprecated]
        #[method(finalWritePrintInfo)]
        pub unsafe fn finalWritePrintInfo(&self);
    }
);