1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
//! 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);
    }
);