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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

#[cfg(feature = "block2")]
pub type UIPrintInteractionCompletionHandler =
    *mut block2::Block<dyn Fn(NonNull<UIPrintInteractionController>, Bool, *mut NSError)>;

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UIPrinterCutterBehavior(pub NSInteger);
impl UIPrinterCutterBehavior {
    #[doc(alias = "UIPrinterCutterBehaviorNoCut")]
    pub const NoCut: Self = Self(0);
    #[doc(alias = "UIPrinterCutterBehaviorPrinterDefault")]
    pub const PrinterDefault: Self = Self(1);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachPage")]
    pub const CutAfterEachPage: Self = Self(2);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachCopy")]
    pub const CutAfterEachCopy: Self = Self(3);
    #[doc(alias = "UIPrinterCutterBehaviorCutAfterEachJob")]
    pub const CutAfterEachJob: Self = Self(4);
}

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

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

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

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

unsafe impl NSObjectProtocol for UIPrintInteractionController {}

extern_methods!(
    unsafe impl UIPrintInteractionController {
        #[method(isPrintingAvailable)]
        pub unsafe fn isPrintingAvailable(mtm: MainThreadMarker) -> bool;

        #[method_id(@__retain_semantics Other printableUTIs)]
        pub unsafe fn printableUTIs(mtm: MainThreadMarker) -> Retained<NSSet<NSString>>;

        #[method(canPrintURL:)]
        pub unsafe fn canPrintURL(url: &NSURL, mtm: MainThreadMarker) -> bool;

        #[method(canPrintData:)]
        pub unsafe fn canPrintData(data: &NSData, mtm: MainThreadMarker) -> bool;

        #[method_id(@__retain_semantics Other sharedPrintController)]
        pub unsafe fn sharedPrintController(
            mtm: MainThreadMarker,
        ) -> Retained<UIPrintInteractionController>;

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

        #[cfg(feature = "UIPrintInfo")]
        #[method(setPrintInfo:)]
        pub unsafe fn setPrintInfo(&self, print_info: Option<&UIPrintInfo>);

        #[method_id(@__retain_semantics Other delegate)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn UIPrintInteractionControllerDelegate>>>;

        #[method(setDelegate:)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn UIPrintInteractionControllerDelegate>>,
        );

        #[deprecated = "Pages can be removed from the print preview, so page range is always shown."]
        #[method(showsPageRange)]
        pub unsafe fn showsPageRange(&self) -> bool;

        #[deprecated = "Pages can be removed from the print preview, so page range is always shown."]
        #[method(setShowsPageRange:)]
        pub unsafe fn setShowsPageRange(&self, shows_page_range: bool);

        #[method(showsNumberOfCopies)]
        pub unsafe fn showsNumberOfCopies(&self) -> bool;

        #[method(setShowsNumberOfCopies:)]
        pub unsafe fn setShowsNumberOfCopies(&self, shows_number_of_copies: bool);

        #[method(showsPaperSelectionForLoadedPapers)]
        pub unsafe fn showsPaperSelectionForLoadedPapers(&self) -> bool;

        #[method(setShowsPaperSelectionForLoadedPapers:)]
        pub unsafe fn setShowsPaperSelectionForLoadedPapers(
            &self,
            shows_paper_selection_for_loaded_papers: bool,
        );

        #[method(showsPaperOrientation)]
        pub unsafe fn showsPaperOrientation(&self) -> bool;

        #[method(setShowsPaperOrientation:)]
        pub unsafe fn setShowsPaperOrientation(&self, shows_paper_orientation: bool);

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

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

        #[cfg(feature = "UIPrintPageRenderer")]
        #[method(setPrintPageRenderer:)]
        pub unsafe fn setPrintPageRenderer(
            &self,
            print_page_renderer: Option<&UIPrintPageRenderer>,
        );

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

        #[cfg(feature = "UIPrintFormatter")]
        #[method(setPrintFormatter:)]
        pub unsafe fn setPrintFormatter(&self, print_formatter: Option<&UIPrintFormatter>);

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

        #[method(setPrintingItem:)]
        pub unsafe fn setPrintingItem(&self, printing_item: Option<&AnyObject>);

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

        #[method(setPrintingItems:)]
        pub unsafe fn setPrintingItems(&self, printing_items: Option<&NSArray>);

        #[cfg(feature = "block2")]
        #[method(presentAnimated:completionHandler:)]
        pub unsafe fn presentAnimated_completionHandler(
            &self,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(feature = "UIResponder", feature = "UIView", feature = "block2"))]
        #[method(presentFromRect:inView:animated:completionHandler:)]
        pub unsafe fn presentFromRect_inView_animated_completionHandler(
            &self,
            rect: CGRect,
            view: &UIView,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(feature = "UIBarButtonItem", feature = "UIBarItem", feature = "block2"))]
        #[method(presentFromBarButtonItem:animated:completionHandler:)]
        pub unsafe fn presentFromBarButtonItem_animated_completionHandler(
            &self,
            item: &UIBarButtonItem,
            animated: bool,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[cfg(all(feature = "UIPrinter", feature = "block2"))]
        #[method(printToPrinter:completionHandler:)]
        pub unsafe fn printToPrinter_completionHandler(
            &self,
            printer: &UIPrinter,
            completion: UIPrintInteractionCompletionHandler,
        ) -> bool;

        #[method(dismissAnimated:)]
        pub unsafe fn dismissAnimated(&self, animated: bool);
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl UIPrintInteractionController {
        #[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_protocol!(
    pub unsafe trait UIPrintInteractionControllerDelegate:
        NSObjectProtocol + IsMainThreadOnly
    {
        #[cfg(all(feature = "UIResponder", feature = "UIViewController"))]
        #[optional]
        #[method_id(@__retain_semantics Other printInteractionControllerParentViewController:)]
        unsafe fn printInteractionControllerParentViewController(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        ) -> Option<Retained<UIViewController>>;

        #[cfg(feature = "UIPrintPaper")]
        #[optional]
        #[method_id(@__retain_semantics Other printInteractionController:choosePaper:)]
        unsafe fn printInteractionController_choosePaper(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            paper_list: &NSArray<UIPrintPaper>,
        ) -> Retained<UIPrintPaper>;

        #[optional]
        #[method(printInteractionControllerWillPresentPrinterOptions:)]
        unsafe fn printInteractionControllerWillPresentPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[method(printInteractionControllerDidPresentPrinterOptions:)]
        unsafe fn printInteractionControllerDidPresentPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[method(printInteractionControllerWillDismissPrinterOptions:)]
        unsafe fn printInteractionControllerWillDismissPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[method(printInteractionControllerDidDismissPrinterOptions:)]
        unsafe fn printInteractionControllerDidDismissPrinterOptions(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[method(printInteractionControllerWillStartJob:)]
        unsafe fn printInteractionControllerWillStartJob(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[optional]
        #[method(printInteractionControllerDidFinishJob:)]
        unsafe fn printInteractionControllerDidFinishJob(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
        );

        #[cfg(feature = "UIPrintPaper")]
        #[optional]
        #[method(printInteractionController:cutLengthForPaper:)]
        unsafe fn printInteractionController_cutLengthForPaper(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            paper: &UIPrintPaper,
        ) -> CGFloat;

        #[optional]
        #[method(printInteractionController:chooseCutterBehavior:)]
        unsafe fn printInteractionController_chooseCutterBehavior(
            &self,
            print_interaction_controller: &UIPrintInteractionController,
            available_behaviors: &NSArray,
        ) -> UIPrinterCutterBehavior;
    }

    unsafe impl ProtocolType for dyn UIPrintInteractionControllerDelegate {}
);