objc2_quartz/generated/ImageKit/
IKScannerDeviceView.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_app_kit::*;
7use objc2_foundation::*;
8#[cfg(feature = "objc2-image-capture-core")]
9use objc2_image_capture_core::*;
10
11use crate::*;
12
13extern_protocol!(
14    /// A delegate of IKScannerDeviceView must conform to IKScannerDeviceViewDelegate protocol.
15    ///
16    /// See also [Apple's documentation](https://developer.apple.com/documentation/quartz/ikscannerdeviceviewdelegate?language=objc)
17    pub unsafe trait IKScannerDeviceViewDelegate {
18        /// This message is sent for each image that gets scanned.
19        ///
20        /// Based on the IKScannerDeviceViewTransferMode the downloaded file will be saved on disk using the 'url', or returned in memory as NSData
21        ///
22        /// # Safety
23        ///
24        /// - `scanner_device_view` might not allow `None`.
25        /// - `url` might not allow `None`.
26        /// - `data` might not allow `None`.
27        /// - `error` might not allow `None`.
28        #[optional]
29        #[unsafe(method(scannerDeviceView:didScanToURL:fileData:error:))]
30        #[unsafe(method_family = none)]
31        unsafe fn scannerDeviceView_didScanToURL_fileData_error(
32            &self,
33            scanner_device_view: Option<&IKScannerDeviceView>,
34            url: Option<&NSURL>,
35            data: Option<&NSData>,
36            error: Option<&NSError>,
37        );
38
39        /// For file based transfer this message is sent for each image that gets scanned.
40        ///
41        /// Based on the IKScannerDeviceViewTransferMode the downloaded file will be saved on disk using the 'url', or returned in memory as NSData
42        ///
43        /// # Safety
44        ///
45        /// - `scanner_device_view` might not allow `None`.
46        /// - `url` might not allow `None`.
47        /// - `error` might not allow `None`.
48        #[optional]
49        #[unsafe(method(scannerDeviceView:didScanToURL:error:))]
50        #[unsafe(method_family = none)]
51        unsafe fn scannerDeviceView_didScanToURL_error(
52            &self,
53            scanner_device_view: Option<&IKScannerDeviceView>,
54            url: Option<&NSURL>,
55            error: Option<&NSError>,
56        );
57
58        #[cfg(feature = "objc2-image-capture-core")]
59        /// For memory a based transfer this message is sent for every time an image band of data was scanned.
60        ///
61        /// The 'data' parameter describes the scanned image data. Note that rotation/cropping/image adjustments are not applied yet. The 'scanInfo' parameter contains additional information (rotation angle, ...) that should be applied once the scan is completed.
62        ///
63        /// # Safety
64        ///
65        /// - `scanner_device_view` might not allow `None`.
66        /// - `data` might not allow `None`.
67        /// - `scan_info` generic should be of the correct type.
68        /// - `scan_info` might not allow `None`.
69        /// - `error` might not allow `None`.
70        #[optional]
71        #[unsafe(method(scannerDeviceView:didScanToBandData:scanInfo:error:))]
72        #[unsafe(method_family = none)]
73        unsafe fn scannerDeviceView_didScanToBandData_scanInfo_error(
74            &self,
75            scanner_device_view: Option<&IKScannerDeviceView>,
76            data: Option<&ICScannerBandData>,
77            scan_info: Option<&NSDictionary>,
78            error: Option<&NSError>,
79        );
80
81        /// This message is sent every time the scanner device reports an error.
82        ///
83        /// # Safety
84        ///
85        /// - `scanner_device_view` might not allow `None`.
86        /// - `error` might not allow `None`.
87        #[optional]
88        #[unsafe(method(scannerDeviceView:didEncounterError:))]
89        #[unsafe(method_family = none)]
90        unsafe fn scannerDeviceView_didEncounterError(
91            &self,
92            scanner_device_view: Option<&IKScannerDeviceView>,
93            error: Option<&NSError>,
94        );
95    }
96);
97
98/// [Apple's documentation](https://developer.apple.com/documentation/quartz/ikscannerdeviceviewtransfermode?language=objc)
99// NS_CLOSED_ENUM
100#[repr(isize)] // NSInteger
101#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
102pub enum IKScannerDeviceViewTransferMode {
103    #[doc(alias = "IKScannerDeviceViewTransferModeFileBased")]
104    FileBased = 0,
105    #[doc(alias = "IKScannerDeviceViewTransferModeMemoryBased")]
106    MemoryBased = 1,
107}
108
109unsafe impl Encode for IKScannerDeviceViewTransferMode {
110    const ENCODING: Encoding = NSInteger::ENCODING;
111}
112
113unsafe impl RefEncode for IKScannerDeviceViewTransferMode {
114    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
115}
116
117/// [Apple's documentation](https://developer.apple.com/documentation/quartz/ikscannerdeviceviewdisplaymode?language=objc)
118// NS_CLOSED_ENUM
119#[repr(isize)] // NSInteger
120#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
121pub enum IKScannerDeviceViewDisplayMode {
122    #[doc(alias = "IKScannerDeviceViewDisplayModeNone")]
123    None = -1,
124    #[doc(alias = "IKScannerDeviceViewDisplayModeSimple")]
125    Simple = 0,
126    #[doc(alias = "IKScannerDeviceViewDisplayModeAdvanced")]
127    Advanced = 1,
128}
129
130unsafe impl Encode for IKScannerDeviceViewDisplayMode {
131    const ENCODING: Encoding = NSInteger::ENCODING;
132}
133
134unsafe impl RefEncode for IKScannerDeviceViewDisplayMode {
135    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
136}
137
138extern_class!(
139    /// IKScannerDeviceView displays a UI to work with Image Capture supported scanners.
140    ///
141    /// See also [Apple's documentation](https://developer.apple.com/documentation/quartz/ikscannerdeviceview?language=objc)
142    #[unsafe(super(NSView, NSResponder, NSObject))]
143    #[derive(Debug, PartialEq, Eq, Hash)]
144    pub struct IKScannerDeviceView;
145);
146
147extern_conformance!(
148    unsafe impl NSAccessibility for IKScannerDeviceView {}
149);
150
151extern_conformance!(
152    unsafe impl NSAccessibilityElementProtocol for IKScannerDeviceView {}
153);
154
155extern_conformance!(
156    unsafe impl NSAnimatablePropertyContainer for IKScannerDeviceView {}
157);
158
159extern_conformance!(
160    unsafe impl NSAppearanceCustomization for IKScannerDeviceView {}
161);
162
163extern_conformance!(
164    unsafe impl NSCoding for IKScannerDeviceView {}
165);
166
167extern_conformance!(
168    unsafe impl NSDraggingDestination for IKScannerDeviceView {}
169);
170
171extern_conformance!(
172    unsafe impl NSObjectProtocol for IKScannerDeviceView {}
173);
174
175extern_conformance!(
176    unsafe impl NSUserInterfaceItemIdentification for IKScannerDeviceView {}
177);
178
179impl IKScannerDeviceView {
180    extern_methods!(
181        /// delegate of the IKScannerDeviceView.
182        ///
183        /// # Safety
184        ///
185        /// This is not retained internally, you must ensure the object is still alive.
186        #[unsafe(method(delegate))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn delegate(
189            &self,
190        ) -> Option<Retained<ProtocolObject<dyn IKScannerDeviceViewDelegate>>>;
191
192        /// Setter for [`delegate`][Self::delegate].
193        ///
194        /// # Safety
195        ///
196        /// - `delegate` might not allow `None`.
197        /// - This is unretained, you must ensure the object is kept alive while in use.
198        #[unsafe(method(setDelegate:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn setDelegate(
201            &self,
202            delegate: Option<&ProtocolObject<dyn IKScannerDeviceViewDelegate>>,
203        );
204
205        #[cfg(feature = "objc2-image-capture-core")]
206        /// the scanner device.
207        ///
208        /// # Safety
209        ///
210        /// This is not retained internally, you must ensure the object is still alive.
211        #[unsafe(method(scannerDevice))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn scannerDevice(&self) -> Option<Retained<ICScannerDevice>>;
214
215        #[cfg(feature = "objc2-image-capture-core")]
216        /// Setter for [`scannerDevice`][Self::scannerDevice].
217        ///
218        /// # Safety
219        ///
220        /// - `scanner_device` might not allow `None`.
221        /// - This is unretained, you must ensure the object is kept alive while in use.
222        #[unsafe(method(setScannerDevice:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setScannerDevice(&self, scanner_device: Option<&ICScannerDevice>);
225
226        /// current display mode.
227        #[unsafe(method(mode))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn mode(&self) -> IKScannerDeviceViewDisplayMode;
230
231        /// Setter for [`mode`][Self::mode].
232        #[unsafe(method(setMode:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setMode(&self, mode: IKScannerDeviceViewDisplayMode);
235
236        /// support a simple scanning UI.
237        #[unsafe(method(hasDisplayModeSimple))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn hasDisplayModeSimple(&self) -> bool;
240
241        /// Setter for [`hasDisplayModeSimple`][Self::hasDisplayModeSimple].
242        #[unsafe(method(setHasDisplayModeSimple:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setHasDisplayModeSimple(&self, has_display_mode_simple: bool);
245
246        /// support advanced scanning UI.
247        #[unsafe(method(hasDisplayModeAdvanced))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn hasDisplayModeAdvanced(&self) -> bool;
250
251        /// Setter for [`hasDisplayModeAdvanced`][Self::hasDisplayModeAdvanced].
252        #[unsafe(method(setHasDisplayModeAdvanced:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn setHasDisplayModeAdvanced(&self, has_display_mode_advanced: bool);
255
256        /// transfer mode either file based - or - in memory.
257        #[unsafe(method(transferMode))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn transferMode(&self) -> IKScannerDeviceViewTransferMode;
260
261        /// Setter for [`transferMode`][Self::transferMode].
262        #[unsafe(method(setTransferMode:))]
263        #[unsafe(method_family = none)]
264        pub unsafe fn setTransferMode(&self, transfer_mode: IKScannerDeviceViewTransferMode);
265
266        /// label for the 'Scan' control.
267        #[unsafe(method(scanControlLabel))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn scanControlLabel(&self) -> Retained<NSString>;
270
271        /// Setter for [`scanControlLabel`][Self::scanControlLabel].
272        ///
273        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
274        #[unsafe(method(setScanControlLabel:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn setScanControlLabel(&self, scan_control_label: Option<&NSString>);
277
278        /// label for the 'Overview' control.
279        #[unsafe(method(overviewControlLabel))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn overviewControlLabel(&self) -> Retained<NSString>;
282
283        /// Setter for [`overviewControlLabel`][Self::overviewControlLabel].
284        ///
285        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
286        #[unsafe(method(setOverviewControlLabel:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn setOverviewControlLabel(&self, overview_control_label: Option<&NSString>);
289
290        /// show a downloads directory control.
291        #[unsafe(method(displaysDownloadsDirectoryControl))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn displaysDownloadsDirectoryControl(&self) -> bool;
294
295        /// Setter for [`displaysDownloadsDirectoryControl`][Self::displaysDownloadsDirectoryControl].
296        #[unsafe(method(setDisplaysDownloadsDirectoryControl:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn setDisplaysDownloadsDirectoryControl(
299            &self,
300            displays_downloads_directory_control: bool,
301        );
302
303        /// downloads directory.
304        #[unsafe(method(downloadsDirectory))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn downloadsDirectory(&self) -> Option<Retained<NSURL>>;
307
308        /// Setter for [`downloadsDirectory`][Self::downloadsDirectory].
309        ///
310        /// # Safety
311        ///
312        /// `downloads_directory` might not allow `None`.
313        #[unsafe(method(setDownloadsDirectory:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn setDownloadsDirectory(&self, downloads_directory: Option<&NSURL>);
316
317        /// document name.
318        #[unsafe(method(documentName))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn documentName(&self) -> Retained<NSString>;
321
322        /// Setter for [`documentName`][Self::documentName].
323        ///
324        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
325        #[unsafe(method(setDocumentName:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn setDocumentName(&self, document_name: Option<&NSString>);
328
329        /// show a postprocessing application control.
330        #[unsafe(method(displaysPostProcessApplicationControl))]
331        #[unsafe(method_family = none)]
332        pub unsafe fn displaysPostProcessApplicationControl(&self) -> bool;
333
334        /// Setter for [`displaysPostProcessApplicationControl`][Self::displaysPostProcessApplicationControl].
335        #[unsafe(method(setDisplaysPostProcessApplicationControl:))]
336        #[unsafe(method_family = none)]
337        pub unsafe fn setDisplaysPostProcessApplicationControl(
338            &self,
339            displays_post_process_application_control: bool,
340        );
341
342        /// postprocessing application.
343        #[unsafe(method(postProcessApplication))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn postProcessApplication(&self) -> Option<Retained<NSURL>>;
346
347        /// Setter for [`postProcessApplication`][Self::postProcessApplication].
348        ///
349        /// # Safety
350        ///
351        /// `post_process_application` might not allow `None`.
352        #[unsafe(method(setPostProcessApplication:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setPostProcessApplication(&self, post_process_application: Option<&NSURL>);
355    );
356}
357
358/// Methods declared on superclass `NSView`.
359impl IKScannerDeviceView {
360    extern_methods!(
361        #[unsafe(method(initWithFrame:))]
362        #[unsafe(method_family = init)]
363        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
364
365        /// # Safety
366        ///
367        /// `coder` possibly has further requirements.
368        #[unsafe(method(initWithCoder:))]
369        #[unsafe(method_family = init)]
370        pub unsafe fn initWithCoder(
371            this: Allocated<Self>,
372            coder: &NSCoder,
373        ) -> Option<Retained<Self>>;
374    );
375}
376
377/// Methods declared on superclass `NSResponder`.
378impl IKScannerDeviceView {
379    extern_methods!(
380        #[unsafe(method(init))]
381        #[unsafe(method_family = init)]
382        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
383    );
384}
385
386/// Methods declared on superclass `NSObject`.
387impl IKScannerDeviceView {
388    extern_methods!(
389        #[unsafe(method(new))]
390        #[unsafe(method_family = new)]
391        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
392    );
393}