Skip to main content

image_capture_core/
scanner_functional_units.rs

1use cocoa::base::{id, BOOL};
2use cocoa::foundation::{NSRect, NSSize, NSUInteger};
3use crate::constants::ICEXIFOrientationType;
4use core_graphics::base::CGFloat;
5use core_graphics::image::CGImageRef;
6use libc::c_uchar;
7use objc::*;
8
9/// Scanner Functional Unit Types
10#[repr(u64)]
11#[derive(Clone, Copy, Debug, PartialEq)]
12pub enum ICScannerFunctionalUnitType {
13    /// Flatbed functional unit.
14    ICScannerFunctionalUnitTypeFlatbed = 0,
15    /// Transparency functional unit for scanning positives.
16    ICScannerFunctionalUnitTypePositiveTransparency = 1,
17    /// Transparency functional unit for scanning negatives.
18    ICScannerFunctionalUnitTypeNegativeTransparency = 2,
19    /// Document feeder functional unit.
20    ICScannerFunctionalUnitTypeDocumentFeeder = 3,
21}
22
23/// Unit of measurement used by the scanner.
24/// This corresponds to values used for ICAP_UNITS as defined in the TWAIN Specification.
25#[repr(u64)]
26#[derive(Clone, Copy, Debug, PartialEq)]
27pub enum ICScannerMeasurementUnit {
28    ICScannerMeasurementUnitInches = 0,
29    ICScannerMeasurementUnitCentimeters = 1,
30    ICScannerMeasurementUnitPicas = 2,
31    ICScannerMeasurementUnitPoints = 3,
32    ICScannerMeasurementUnitTwips = 4,
33    ICScannerMeasurementUnitPixels = 5,
34}
35
36/// Bits per channel in the scanned image.
37/// This corresponds to values used for ICAP_UNITS as defined in the TWAIN Specification.
38#[repr(u64)]
39#[derive(Clone, Copy, Debug, PartialEq)]
40pub enum ICScannerBitDepth {
41    ICScannerBitDepth1Bit = 1,
42    ICScannerBitDepth8Bits = 8,
43    ICScannerBitDepth16Bits = 16,
44}
45
46/// Bits per channel in the scanned image.
47/// This corresponds to values used for ICAP_UNITS as defined in the TWAIN Specification.
48#[repr(u64)]
49#[derive(Clone, Copy, Debug, PartialEq)]
50pub enum ICScannerColorDataFormatType {
51    /// For multi-channel data (e.g., RGB) data from all channels are interleaved.
52    ICScannerColorDataFormatTypeChunky = 0,
53    /// For multi-channel data (e.g., RGB) each channel is transferred sequentially.
54    ICScannerColorDataFormatTypePlanar = 1,
55}
56
57/// Pixel data types.
58/// Corresponds to "ICAP_PIXELTYPE" of the TWAIN Specification.
59#[repr(u64)]
60#[derive(Clone, Copy, Debug, PartialEq)]
61pub enum ICScannerPixelDataType {
62    /// Monochrome 1 bit pixel image.
63    ICScannerPixelDataTypeBW = 0,
64    /// 8 bit pixel Gray color space.
65    ICScannerPixelDataTypeGray = 1,
66    /// Color image RGB color space.
67    ICScannerPixelDataTypeRGB = 2,
68    /// Indexed Color image.
69    ICScannerPixelDataTypePalette = 3,
70    /// Color image in CMY color space.
71    ICScannerPixelDataTypeCMY = 4,
72    /// Color image in CMYK color space.
73    ICScannerPixelDataTypeCMYK = 5,
74    /// Color image in YUV color space.
75    ICScannerPixelDataTypeYUV = 6,
76    /// Color image in YUVK color space.
77    ICScannerPixelDataTypeYUVK = 7,
78    /// Color image in CIEXYZ color space.
79    ICScannerPixelDataTypeCIEXYZ = 8,
80}
81
82/// Document size types.
83/// Corresponds to "ICAP_SUPPORTEDSIZES" used by the Image Catpure scanner modules.
84#[repr(u64)]
85#[derive(Clone, Copy, Debug, PartialEq)]
86pub enum ICScannerDocumentType {
87    ICScannerDocumentTypeDefault = 0,
88    ICScannerDocumentTypeA4 = 1,
89    ICScannerDocumentTypeB5 = 2,
90    ICScannerDocumentTypeUSLetter = 3,
91    ICScannerDocumentTypeUSLegal = 4,
92    ICScannerDocumentTypeA5 = 5,
93    ICScannerDocumentTypeISOB4 = 6,
94    ICScannerDocumentTypeISOB6 = 7,
95    ICScannerDocumentTypeUSLedger = 9,
96    ICScannerDocumentTypeUSExecutive = 10,
97    ICScannerDocumentTypeA3 = 11,
98    ICScannerDocumentTypeISOB3 = 12,
99    ICScannerDocumentTypeA6 = 13,
100    ICScannerDocumentTypeC4 = 14,
101    ICScannerDocumentTypeC5 = 15,
102    ICScannerDocumentTypeC6 = 16,
103    ICScannerDocumentType4A0 = 17,
104    ICScannerDocumentType2A0 = 18,
105    ICScannerDocumentTypeA0 = 19,
106    ICScannerDocumentTypeA1 = 20,
107    ICScannerDocumentTypeA2 = 21,
108    ICScannerDocumentTypeA7 = 22,
109    ICScannerDocumentTypeA8 = 23,
110    ICScannerDocumentTypeA9 = 24,
111    ICScannerDocumentType10 = 25,
112    ICScannerDocumentTypeISOB0 = 26,
113    ICScannerDocumentTypeISOB1 = 27,
114    ICScannerDocumentTypeISOB2 = 28,
115    ICScannerDocumentTypeISOB5 = 29,
116    ICScannerDocumentTypeISOB7 = 30,
117    ICScannerDocumentTypeISOB8 = 31,
118    ICScannerDocumentTypeISOB9 = 32,
119    ICScannerDocumentTypeISOB10 = 33,
120    ICScannerDocumentTypeJISB0 = 34,
121    ICScannerDocumentTypeJISB1 = 35,
122    ICScannerDocumentTypeJISB2 = 36,
123    ICScannerDocumentTypeJISB3 = 37,
124    ICScannerDocumentTypeJISB4 = 38,
125    ICScannerDocumentTypeJISB6 = 39,
126    ICScannerDocumentTypeJISB7 = 40,
127    ICScannerDocumentTypeJISB8 = 41,
128    ICScannerDocumentTypeJISB9 = 42,
129    ICScannerDocumentTypeJISB10 = 43,
130    ICScannerDocumentTypeC0 = 44,
131    ICScannerDocumentTypeC1 = 45,
132    ICScannerDocumentTypeC2 = 46,
133    ICScannerDocumentTypeC3 = 47,
134    ICScannerDocumentTypeC7 = 48,
135    ICScannerDocumentTypeC8 = 49,
136    ICScannerDocumentTypeC9 = 50,
137    ICScannerDocumentTypeC10 = 51,
138    ICScannerDocumentTypeUSStatement = 52,
139    ICScannerDocumentTypeBusinessCard = 53,
140    ICScannerDocumentTypeE = 60,
141    ICScannerDocumentType3R = 61,
142    ICScannerDocumentType4R = 62,
143    ICScannerDocumentType5R = 63,
144    ICScannerDocumentType6R = 64,
145    ICScannerDocumentType8R = 65,
146    ICScannerDocumentTypeS8R = 66,
147    ICScannerDocumentType10R = 67,
148    ICScannerDocumentTypeS10R = 68,
149    ICScannerDocumentType11R = 69,
150    ICScannerDocumentType12R = 70,
151    ICScannerDocumentTypeS12R = 71,
152    ICScannerDocumentType110 = 72,
153    ICScannerDocumentTypeAPSH = 73,
154    ICScannerDocumentTypeAPSC = 74,
155    ICScannerDocumentTypeAPSP = 75,
156    ICScannerDocumentType135 = 76,
157    ICScannerDocumentTypeMF = 77,
158    ICScannerDocumentTypeLF = 78,
159}
160
161/// A flag to indicate the scanner functional unit's state
162#[repr(u64)]
163#[derive(Clone, Copy, Debug, PartialEq)]
164pub enum ICScannerFunctionalUnitState {
165    /// The scanner functional unit is ready for operation.
166    ICScannerFunctionalUnitStateReady = (1 << 0),
167    /// The scanner functional unit is performing a scan.
168    ICScannerFunctionalUnitStateScanInProgress = (1 << 1),
169    /// The scanner functional unit is performing an overview scan.
170    ICScannerFunctionalUnitStateOverviewScanInProgress = (1 << 2),
171}
172
173/// Scanner Feature Types
174#[repr(u64)]
175#[derive(Clone, Copy, Debug, PartialEq)]
176pub enum ICScannerFeatureType {
177    /// This feature can have one of several discrete values, strings or numbers.
178    ICScannerFeatureTypeEnumeration = 0,
179    /// This value of this feature lies within a range.
180    ICScannerFeatureTypeRange = 1,
181    /// The value of this feature can be YES or NO.
182    ICScannerFeatureTypeBoolean = 2,
183    ICScannerFeatureTypeTemplate = 3,
184}
185
186/// ICScannerFeature class is an abstract base class used to describe a scanner feature.
187pub trait ICScannerFeature: Sized {
188    /// Scanner feature type.
189    unsafe fn type_(self) -> ICScannerFeatureType;
190    /// The internal name of this feature.
191    unsafe fn internalName(self) -> id;
192    /// The human readable name of this feature.
193    unsafe fn humanReadableName(self) -> id;
194    /// Tooltip text describing the feature.
195    unsafe fn tooltip(self) -> id;
196}
197
198impl ICScannerFeature for id {
199    unsafe fn type_(self) -> ICScannerFeatureType {
200        msg_send![self, type]
201    }
202
203    unsafe fn internalName(self) -> id {
204        msg_send![self, internalName]
205    }
206    unsafe fn humanReadableName(self) -> id {
207        msg_send![self, humanReadableName]
208    }
209    unsafe fn tooltip(self) -> id {
210        msg_send![self, tooltip]
211    }
212}
213
214/// ICScannerFeature class is an abstract base class used to describe a scanner feature.
215pub trait ICScannerFeatureEnumeration: Sized {
216    /// The current value. The current value can be set to one of the possible values in the "values" property below.
217    unsafe fn currentValue(self) -> id;
218    /// Set the current value
219    unsafe fn setCurrentValue(self, currentValue: id);
220    /// The default value. The default value can be set to one of the possible values in the "values" property below.
221    unsafe fn defaultValue(self) -> id;
222    /// An array of possible values. All items in this array must be of same type.
223    unsafe fn values(self) -> id;
224    /// The human readable menu item labels to be used in a menu to allow the user to select the current value from an array of possible values.
225    unsafe fn menuItemLabels(self) -> id;
226    /// Tooltip text associated with the menu items.
227    unsafe fn menuItemLabelsTooltips(self) -> id;
228}
229
230impl ICScannerFeatureEnumeration for id {
231    unsafe fn currentValue(self) -> id {
232        msg_send![self, currentValue]
233    }
234
235    unsafe fn setCurrentValue(self, currentValue: id) {
236        msg_send![self, setCurrentValue: currentValue]
237    }
238
239    unsafe fn defaultValue(self) -> id {
240        msg_send![self, defaultValue]
241    }
242
243    unsafe fn values(self) -> id {
244        msg_send![self, values]
245    }
246
247    unsafe fn menuItemLabels(self) -> id {
248        msg_send![self, menuItemLabels]
249    }
250
251    unsafe fn menuItemLabelsTooltips(self) -> id {
252        msg_send![self, menuItemLabelsTooltips]
253    }
254}
255
256/// ICScannerFeatureRange object is used to represent a property of a scanner functional unit whose value lies within a range.
257pub trait ICScannerFeatureRange: Sized {
258    /// The current value. Attempting to set the current value to a value that is not coincident with a step will result in a value corresponding to the nearest step being assigned to the current value.
259    unsafe fn currentValue(self) -> CGFloat;
260    /// Set the current value
261    unsafe fn setCurrentValue(self, currentValue: CGFloat);
262    /// The default value. Attempting to set the default value to a value that is not coincident with a step will result in a value corresponding to the nearest step being assigned to the default value.
263    unsafe fn defaultValue(self) -> CGFloat;
264    /// The minimum value.
265    unsafe fn minValue(self) -> CGFloat;
266    /// The maximum value.
267    unsafe fn maxValue(self) -> CGFloat;
268    ///  The step size.
269    unsafe fn stepSize(self) -> CGFloat;
270}
271
272impl ICScannerFeatureRange for id {
273    unsafe fn currentValue(self) -> CGFloat {
274        msg_send![self, currentValue]
275    }
276
277    unsafe fn setCurrentValue(self, currentValue: CGFloat) {
278        msg_send![self, setCurrentValue: currentValue]
279    }
280
281    unsafe fn defaultValue(self) -> CGFloat {
282        msg_send![self, defaultValue]
283    }
284
285    unsafe fn minValue(self) -> CGFloat {
286        msg_send![self, minValue]
287    }
288
289    unsafe fn maxValue(self) -> CGFloat {
290        msg_send![self, maxValue]
291    }
292
293    unsafe fn stepSize(self) -> CGFloat {
294        msg_send![self, stepSize]
295    }
296}
297
298/// ICScannerFeatureBoolean object is used to represent a property of a scanner functional unit whose value can be YES or NO.
299pub trait ICScannerFeatureBoolean: Sized {
300    /// The value of this feature.
301    unsafe fn value(self) -> BOOL;
302    /// Set the value of this feature.
303    unsafe fn setValue(self, value: BOOL);
304}
305
306impl ICScannerFeatureBoolean for id {
307    unsafe fn value(self) -> BOOL {
308        msg_send![self, value]
309    }
310
311    unsafe fn setValue(self, value: BOOL) {
312        msg_send![self, setValue: value]
313    }
314}
315
316/// ICScannerFeatureTemplate object is used to define a group of one or more rectangular scan areas that can be used with a scanner functional unit.
317pub trait ICScannerFeatureTemplate: Sized {
318    unsafe fn targets(self) -> id;
319}
320
321impl ICScannerFeatureTemplate for id {
322    unsafe fn targets(self) -> id {
323        msg_send![self, targets]
324    }
325}
326
327/// ICScannerFunctionalUnit is an abstract class that represents a scanner functiona unit.
328/// ImageCaptureCore defines three concrete subclasses of ICScannerFunctionalUnit: ICScannerFunctionalUnitFlatbed, ICScannerFunctionalUnitPositiveTransparency, ICScannerFunctionalUnitNegativeTransparency and ICScannerFunctionalUnitDocumentFeeder.
329/// ICScannerDevice creates instances of these concrete subclasses.
330pub trait ICScannerFunctionalUnit: Sized {
331    /// Functional unit type.
332    unsafe fn type_(self) -> ICScannerFunctionalUnitType;
333    /// The pixel data type.
334    unsafe fn pixelDataType(self) -> ICScannerPixelDataType;
335    /// Set the pixel data type.
336    unsafe fn setPixelDataType(self, pixelDataType: ICScannerPixelDataType);
337    /// Supported bit depths. The values in this set are valid values defined by ICScannerBitDepth.
338    unsafe fn supportedBitDepths(self) -> id;
339    /// The bit depth to use when performing the final scan. This will always be one of the supported bit depths.
340    unsafe fn bitDepth(self) -> ICScannerBitDepth;
341    /// Set the bit depth to use when performing the final scan.
342    unsafe fn setBitDepth(self, bitDepth: ICScannerBitDepth);
343    /// Supported measurement units. The values in this set are valid values defined by ICScannerMeasurementUnit.
344    unsafe fn supportedMeasurementUnits(self) -> id;
345    /// Current measurement unit. This will always be one of the supported measurement units.
346    unsafe fn measurementUnit(self) -> ICScannerMeasurementUnit;
347    /// Set current measurement unit.
348    unsafe fn setMeasurementUnit(self, measurementUnit: ICScannerMeasurementUnit);
349    /// Supported scan resolutions in DPI.
350    unsafe fn supportedResolutions(self) -> id;
351    /// Preferred scan resolutions in DPI.
352    unsafe fn preferredResolutions(self) -> id;
353    /// Current scan resolution. This will always be one of the supported resolution values.
354    unsafe fn resolution(self) -> NSUInteger;
355    /// Set the current scan resolution.
356    unsafe fn setResolution(self, resolution: NSUInteger);
357    /// Optical resolution along the X axis.
358    unsafe fn nativeXResolution(self) -> NSUInteger;
359    /// Optical resolution along the Y axis.
360    unsafe fn nativeYResolution(self) -> NSUInteger;
361    /// Supported scale factors in percentage.
362    unsafe fn supportedScaleFactors(self) -> id;
363    /// Preferred scale factors in percentage.
364    unsafe fn preferredScaleFactors(self) -> id;
365    /// Current scale factor. This will always be one of the supported scale factor values.
366    unsafe fn scaleFactor(self) -> NSUInteger;
367    /// Set the current scale factor.
368    unsafe fn setScaleFactor(self, scaleFactor: NSUInteger);
369    /// An array of objects of type ICScannerFeatureTemplate.
370    unsafe fn templates(self) -> id;
371    /// An array of objects of type ICScannerFeature.
372    unsafe fn vendorFeatures(self) -> id;
373    /// Physical size of the scan area in current measurement unit.
374    unsafe fn physicalSize(self) -> NSSize;
375    /// This property along with scanAreaOrientation describes the area to be scanned.
376    unsafe fn scanArea(self) -> NSRect;
377    /// Set the area to be scanned.
378    unsafe fn setScanArea(self, scanArea: NSRect);
379    /// Desired orientation of the scan area. This property along with scanArea describes the area to be scanned.
380    unsafe fn scanAreaOrientation(self) -> ICEXIFOrientationType;
381    /// Set the orientation of the scan area.
382    unsafe fn setScanAreaOrientation(self, scanAreaOrientation: ICEXIFOrientationType);
383    /// Indicates if this functional unit accepts threshold value to be used when performing a scan in black & white.
384    unsafe fn acceptsThresholdForBlackAndWhiteScanning(self) -> BOOL;
385    /// Indicates if this functional unit uses threshold value to be used when performing a scan in black & white.
386    unsafe fn usesThresholdForBlackAndWhiteScanning(self) -> BOOL;
387    /// Indicate if this functional unit uses threshold value to be used when performing a scan in black & white.
388    unsafe fn setUsesThresholdForBlackAndWhiteScanning(
389        self,
390        usesThresholdForBlackAndWhiteScanning: BOOL,
391    );
392    /// Default threshold value used when performing a scan in black & white. This value is from 0 to 255.
393    unsafe fn defaultThresholdForBlackAndWhiteScanning(self) -> c_uchar;
394    /// Threshold value to be used when performing a scan in black & white. This value should be from 0 to 255.
395    unsafe fn thresholdForBlackAndWhiteScanning(self) -> c_uchar;
396    /// Set the threshold value to be used when performing a scan in black & white.
397    unsafe fn setThresholdForBlackAndWhiteScanning(
398        self,
399        thresholdForBlackAndWhiteScanning: c_uchar,
400    );
401    /// Indicates the current state of the functional unit.
402    unsafe fn state(self) -> ICScannerFunctionalUnitState;
403    /// Indicates if a scan is in progress.
404    unsafe fn scanInProgress(self) -> BOOL;
405    /// Indicates percentage of scan completed.
406    unsafe fn scanProgressPercentDone(self) -> CGFloat;
407    /// Indicates if this functional unit can perfrom an overview scan. Not all functional units can perform an overview scan. For example, a document feeder or a sheet feeder unit cannot perform an overview scan.
408    unsafe fn canPerformOverviewScan(self) -> BOOL;
409    /// Indicates if an overview scan is in progress.
410    unsafe fn overviewScanInProgress(self) -> BOOL;
411    /// Overview scan image. This property will be NULL for functional units that do not support overview scans.
412    unsafe fn overviewImage(self) -> CGImageRef;
413    /// Overview image resolution. Value assigned to this will be contrained by resolutions allowed by the device.
414    unsafe fn overviewResolution(self) -> NSUInteger;
415    /// Set the overview image resolution.
416    unsafe fn setOverviewResolution(self, overviewResolution: NSUInteger);
417}
418
419impl ICScannerFunctionalUnit for id {
420    unsafe fn type_(self) -> ICScannerFunctionalUnitType {
421        msg_send![self, type]
422    }
423
424    unsafe fn pixelDataType(self) -> ICScannerPixelDataType {
425        msg_send![self, pixelDataType]
426    }
427
428    unsafe fn setPixelDataType(self, pixelDataType: ICScannerPixelDataType) {
429        msg_send![self, setPixelDataType: pixelDataType]
430    }
431
432    unsafe fn supportedBitDepths(self) -> id {
433        msg_send![self, supportedBitDepths]
434    }
435
436    unsafe fn bitDepth(self) -> ICScannerBitDepth {
437        msg_send![self, bitDepth]
438    }
439
440    unsafe fn setBitDepth(self, bitDepth: ICScannerBitDepth) {
441        msg_send![self, setBitDepth: bitDepth]
442    }
443
444    unsafe fn supportedMeasurementUnits(self) -> id {
445        msg_send![self, supportedMeasurementUnits]
446    }
447
448    unsafe fn measurementUnit(self) -> ICScannerMeasurementUnit {
449        msg_send![self, measurementUnit]
450    }
451
452    unsafe fn setMeasurementUnit(self, measurementUnit: ICScannerMeasurementUnit) {
453        msg_send![self, setMeasurementUnit: measurementUnit]
454    }
455
456    unsafe fn supportedResolutions(self) -> id {
457        msg_send![self, supportedResolutions]
458    }
459
460    unsafe fn preferredResolutions(self) -> id {
461        msg_send![self, preferredResolutions]
462    }
463
464    unsafe fn resolution(self) -> NSUInteger {
465        msg_send![self, resolution]
466    }
467
468    unsafe fn setResolution(self, resolution: NSUInteger) {
469        msg_send![self, setResolution: resolution]
470    }
471
472    unsafe fn nativeXResolution(self) -> NSUInteger {
473        msg_send![self, nativeXResolution]
474    }
475
476    unsafe fn nativeYResolution(self) -> NSUInteger {
477        msg_send![self, nativeYResolution]
478    }
479
480    unsafe fn supportedScaleFactors(self) -> id {
481        msg_send![self, supportedScaleFactors]
482    }
483
484    unsafe fn preferredScaleFactors(self) -> id {
485        msg_send![self, preferredScaleFactors]
486    }
487
488    unsafe fn scaleFactor(self) -> NSUInteger {
489        msg_send![self, scaleFactor]
490    }
491
492    unsafe fn setScaleFactor(self, scaleFactor: NSUInteger) {
493        msg_send![self, setScaleFactor: scaleFactor]
494    }
495
496    unsafe fn templates(self) -> id {
497        msg_send![self, templates]
498    }
499
500    unsafe fn vendorFeatures(self) -> id {
501        msg_send![self, vendorFeatures]
502    }
503
504    unsafe fn physicalSize(self) -> NSSize {
505        msg_send![self, physicalSize]
506    }
507
508    unsafe fn scanArea(self) -> NSRect {
509        msg_send![self, scanArea]
510    }
511
512    unsafe fn setScanArea(self, scanArea: NSRect) {
513        msg_send![self, setScanArea: scanArea]
514    }
515
516    unsafe fn scanAreaOrientation(self) -> ICEXIFOrientationType {
517        msg_send![self, scanAreaOrientation]
518    }
519
520    unsafe fn setScanAreaOrientation(self, scanAreaOrientation: ICEXIFOrientationType) {
521        msg_send![self, setScanAreaOrientation: scanAreaOrientation]
522    }
523
524    unsafe fn acceptsThresholdForBlackAndWhiteScanning(self) -> BOOL {
525        msg_send![self, acceptsThresholdForBlackAndWhiteScanning]
526    }
527
528    unsafe fn usesThresholdForBlackAndWhiteScanning(self) -> BOOL {
529        msg_send![self, usesThresholdForBlackAndWhiteScanning]
530    }
531
532    unsafe fn setUsesThresholdForBlackAndWhiteScanning(
533        self,
534        usesThresholdForBlackAndWhiteScanning: BOOL,
535    ) {
536        msg_send![
537            self,
538            setUsesThresholdForBlackAndWhiteScanning: usesThresholdForBlackAndWhiteScanning
539        ]
540    }
541
542    unsafe fn defaultThresholdForBlackAndWhiteScanning(self) -> c_uchar {
543        msg_send![self, defaultThresholdForBlackAndWhiteScanning]
544    }
545
546    unsafe fn thresholdForBlackAndWhiteScanning(self) -> c_uchar {
547        msg_send![self, thresholdForBlackAndWhiteScanning]
548    }
549
550    unsafe fn setThresholdForBlackAndWhiteScanning(
551        self,
552        thresholdForBlackAndWhiteScanning: c_uchar,
553    ) {
554        msg_send![
555            self,
556            setThresholdForBlackAndWhiteScanning: thresholdForBlackAndWhiteScanning
557        ]
558    }
559
560    unsafe fn state(self) -> ICScannerFunctionalUnitState {
561        msg_send![self, state]
562    }
563
564    unsafe fn scanInProgress(self) -> BOOL {
565        msg_send![self, scanInProgress]
566    }
567
568    unsafe fn scanProgressPercentDone(self) -> CGFloat {
569        msg_send![self, scanProgressPercentDone]
570    }
571
572    unsafe fn canPerformOverviewScan(self) -> BOOL {
573        msg_send![self, canPerformOverviewScan]
574    }
575
576    unsafe fn overviewScanInProgress(self) -> BOOL {
577        msg_send![self, overviewScanInProgress]
578    }
579
580    unsafe fn overviewImage(self) -> CGImageRef {
581        msg_send![self, overviewImage]
582    }
583
584    unsafe fn overviewResolution(self) -> NSUInteger {
585        msg_send![self, overviewResolution]
586    }
587
588    unsafe fn setOverviewResolution(self, overviewResolution: NSUInteger) {
589        msg_send![self, setOverviewResolution: overviewResolution]
590    }
591}
592
593/// ICScannerFunctionalUnitFlatbed is a concrete subclass of ICScannerFunctionalUnit class.
594/// ICScannerDevice creates instances of this class.
595pub trait ICScannerFunctionalUnitFlatbed: Sized {
596    /// Supported document types. The values in this set are valid values defined by ICScannerDocumentType.
597    unsafe fn supportedDocumentTypes(self) -> id;
598    /// Current document type. This will always be one of the supported document types.
599    unsafe fn documentType(self) -> ICScannerDocumentType;
600    /// Set the current document type.
601    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType);
602    /// Document size of the current document type expressed in current measurement unit.
603    unsafe fn documentSize(self) -> NSSize;
604}
605
606impl ICScannerFunctionalUnitFlatbed for id {
607    unsafe fn supportedDocumentTypes(self) -> id {
608        msg_send![self, supportedDocumentTypes]
609    }
610
611    unsafe fn documentType(self) -> ICScannerDocumentType {
612        msg_send![self, documentType]
613    }
614
615    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType) {
616        msg_send![self, setDocumentType: documentType]
617    }
618
619    unsafe fn documentSize(self) -> NSSize {
620        msg_send![self, documentSize]
621    }
622}
623
624/// ICScannerFunctionalUnitPositiveTransparency is a concrete subclass of ICScannerFunctionalUnit class.
625/// ICScannerDevice creates instances of this class.
626pub trait ICScannerFunctionalUnitPositiveTransparency: Sized {
627    /// Supported document types. The values in this set are valid values defined by ICScannerDocumentType.
628    unsafe fn supportedDocumentTypes(self) -> id;
629    /// Current document type. This will always be one of the supported document types.
630    unsafe fn documentType(self) -> ICScannerDocumentType;
631    /// Set the current document type.
632    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType);
633    /// Document size of the current document type expressed in current measurement unit.
634    unsafe fn documentSize(self) -> NSSize;
635}
636
637impl ICScannerFunctionalUnitPositiveTransparency for id {
638    unsafe fn supportedDocumentTypes(self) -> id {
639        msg_send![self, supportedDocumentTypes]
640    }
641
642    unsafe fn documentType(self) -> ICScannerDocumentType {
643        msg_send![self, documentType]
644    }
645
646    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType) {
647        msg_send![self, setDocumentType: documentType]
648    }
649
650    unsafe fn documentSize(self) -> NSSize {
651        msg_send![self, documentSize]
652    }
653}
654
655/// ICScannerFunctionalUnitNegativeTransparency is a concrete subclass of ICScannerFunctionalUnit class.
656/// ICScannerDevice creates instances of this class.
657pub trait ICScannerFunctionalUnitNegativeTransparency: Sized {
658    /// Supported document types. The values in this set are valid values defined by ICScannerDocumentType.
659    unsafe fn supportedDocumentTypes(self) -> id;
660    /// Current document type. This will always be one of the supported document types.
661    unsafe fn documentType(self) -> ICScannerDocumentType;
662    /// Set the current document type.
663    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType);
664    /// Document size of the current document type expressed in current measurement unit.
665    unsafe fn documentSize(self) -> NSSize;
666}
667
668impl ICScannerFunctionalUnitNegativeTransparency for id {
669    unsafe fn supportedDocumentTypes(self) -> id {
670        msg_send![self, supportedDocumentTypes]
671    }
672
673    unsafe fn documentType(self) -> ICScannerDocumentType {
674        msg_send![self, documentType]
675    }
676
677    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType) {
678        msg_send![self, setDocumentType: documentType]
679    }
680
681    unsafe fn documentSize(self) -> NSSize {
682        msg_send![self, documentSize]
683    }
684}
685
686/// ICScannerFunctionalUnitDocumentFeeder is a concrete subclass of ICScannerFunctionalUnit class.
687/// ICScannerDevice creates instances of this class.
688pub trait ICScannerFunctionalUnitDocumentFeeder: Sized {
689    /// Supported document types. The values in this set are valid values defined by ICScannerDocumentType.
690    unsafe fn supportedDocumentTypes(self) -> id;
691    /// Current document type. This will always be one of the supported document types.
692    unsafe fn documentType(self) -> ICScannerDocumentType;
693    /// Set the current document type.
694    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType);
695    /// Document size of the current document type expressed in current measurement unit.
696    unsafe fn documentSize(self) -> NSSize;
697    /// Indicates whether duplex scanning is supported.
698    unsafe fn supportsDuplexScanning(self) -> BOOL;
699    /// Indicates whether duplex scanning is enabled.
700    unsafe fn duplexScanningEnabled(self) -> BOOL;
701    /// Set whether duplex scanning is enabled.
702    unsafe fn setDuplexScanningEnabled(self, duplexScanningEnabled: BOOL);
703    /// Indicates whether the feeder has documents to scan.
704    /// This value will change when the document is loaded or removed from the feeder, if the scanner module has the capability to detect this state.
705    unsafe fn documentLoaded(self) -> BOOL;
706    /// Desired orientation of the odd pages of the scanned document.
707    unsafe fn oddPageOrientation(self) -> ICEXIFOrientationType;
708    /// Set the desired orientation of the odd pages of the scanned document.
709    unsafe fn setOddPageOrientation(self, oddPageOrientation: ICEXIFOrientationType);
710    /// Desired orientation of the even pages of the scanned document.
711    unsafe fn evenPageOrientation(self) -> ICEXIFOrientationType;
712    /// Set the desired orientation of the even pages of the scanned document.
713    unsafe fn setEvenPageOrientation(self, evenPageOrientation: ICEXIFOrientationType);
714    /// Indicates whether the document feeder reads pages from back to front.
715    unsafe fn reverseFeederPageOrder(self) -> BOOL;
716}
717
718impl ICScannerFunctionalUnitDocumentFeeder for id {
719    unsafe fn supportedDocumentTypes(self) -> id {
720        msg_send![self, supportedDocumentTypes]
721    }
722
723    unsafe fn documentType(self) -> ICScannerDocumentType {
724        msg_send![self, documentType]
725    }
726
727    unsafe fn setDocumentType(self, documentType: ICScannerDocumentType) {
728        msg_send![self, setDocumentType: documentType]
729    }
730
731    unsafe fn documentSize(self) -> NSSize {
732        msg_send![self, documentSize]
733    }
734
735    unsafe fn supportsDuplexScanning(self) -> BOOL {
736        msg_send![self, supportsDuplexScanning]
737    }
738
739    unsafe fn duplexScanningEnabled(self) -> BOOL {
740        msg_send![self, duplexScanningEnabled]
741    }
742
743    unsafe fn setDuplexScanningEnabled(self, duplexScanningEnabled: BOOL) {
744        msg_send![self, setDuplexScanningEnabled: duplexScanningEnabled]
745    }
746
747    unsafe fn documentLoaded(self) -> BOOL {
748        msg_send![self, documentLoaded]
749    }
750
751    unsafe fn oddPageOrientation(self) -> ICEXIFOrientationType {
752        msg_send![self, oddPageOrientation]
753    }
754
755    unsafe fn setOddPageOrientation(self, oddPageOrientation: ICEXIFOrientationType) {
756        msg_send![self, setOddPageOrientation: oddPageOrientation]
757    }
758
759    unsafe fn evenPageOrientation(self) -> ICEXIFOrientationType {
760        msg_send![self, evenPageOrientation]
761    }
762
763    unsafe fn setEvenPageOrientation(self, evenPageOrientation: ICEXIFOrientationType) {
764        msg_send![self, setEvenPageOrientation: evenPageOrientation]
765    }
766
767    unsafe fn reverseFeederPageOrder(self) -> BOOL {
768        msg_send![self, reverseFeederPageOrder]
769    }
770}