objc2-quartz 0.3.2

Bindings to the Quartz framework
Documentation
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
#[cfg(feature = "objc2-core-image")]
use objc2_core_image::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-quartz-core")]
use objc2_quartz_core::*;

use crate::*;

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodenone?language=objc)
    pub static IKToolModeNone: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodemove?language=objc)
    pub static IKToolModeMove: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodeselect?language=objc)
    pub static IKToolModeSelect: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodeselectrect?language=objc)
    pub static IKToolModeSelectRect: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodeselectellipse?language=objc)
    pub static IKToolModeSelectEllipse: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodeselectlasso?language=objc)
    pub static IKToolModeSelectLasso: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodecrop?language=objc)
    pub static IKToolModeCrop: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmoderotate?language=objc)
    pub static IKToolModeRotate: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/iktoolmodeannotate?language=objc)
    pub static IKToolModeAnnotate: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/ikoverlaytypebackground?language=objc)
    pub static IKOverlayTypeBackground: Option<&'static NSString>;
}

extern "C" {
    /// [Apple's documentation](https://developer.apple.com/documentation/quartz/ikoverlaytypeimage?language=objc)
    pub static IKOverlayTypeImage: Option<&'static NSString>;
}

extern_class!(
    /// The IKImageView class provides an efficient way to display images in a view while at the same time supporting a number of image editing operations.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/quartz/ikimageview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct IKImageView;
);

extern_conformance!(
    unsafe impl NSAccessibility for IKImageView {}
);

extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for IKImageView {}
);

extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for IKImageView {}
);

extern_conformance!(
    unsafe impl NSAppearanceCustomization for IKImageView {}
);

extern_conformance!(
    unsafe impl NSCoding for IKImageView {}
);

extern_conformance!(
    unsafe impl NSDraggingDestination for IKImageView {}
);

extern_conformance!(
    unsafe impl NSObjectProtocol for IKImageView {}
);

extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for IKImageView {}
);

impl IKImageView {
    extern_methods!(
        /// Specifies the delegate object of the receiver.
        ///
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(&self) -> Option<Retained<AnyObject>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// # Safety
        ///
        /// - `delegate` should be of the correct type.
        /// - `delegate` might not allow `None`.
        /// - This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(&self, delegate: Option<&AnyObject>);

        #[cfg(feature = "objc2-core-foundation")]
        /// Specifies the zoom factor for the image view.
        #[unsafe(method(zoomFactor))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomFactor(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`zoomFactor`][Self::zoomFactor].
        #[unsafe(method(setZoomFactor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setZoomFactor(&self, zoom_factor: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        /// Specifies the rotation angle for the image view.
        #[unsafe(method(rotationAngle))]
        #[unsafe(method_family = none)]
        pub unsafe fn rotationAngle(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`rotationAngle`][Self::rotationAngle].
        #[unsafe(method(setRotationAngle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRotationAngle(&self, rotation_angle: CGFloat);

        /// Specifies the current tool mode for the image view.
        #[unsafe(method(currentToolMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn currentToolMode(&self) -> Retained<NSString>;

        /// Setter for [`currentToolMode`][Self::currentToolMode].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setCurrentToolMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCurrentToolMode(&self, current_tool_mode: Option<&NSString>);

        /// Specifies the automatic resizing state for the image view.
        #[unsafe(method(autoresizes))]
        #[unsafe(method_family = none)]
        pub unsafe fn autoresizes(&self) -> bool;

        /// Setter for [`autoresizes`][Self::autoresizes].
        #[unsafe(method(setAutoresizes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutoresizes(&self, autoresizes: bool);

        /// Specifies the horizontal scroll bar state for the image view.
        #[unsafe(method(hasHorizontalScroller))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasHorizontalScroller(&self) -> bool;

        /// Setter for [`hasHorizontalScroller`][Self::hasHorizontalScroller].
        #[unsafe(method(setHasHorizontalScroller:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHasHorizontalScroller(&self, has_horizontal_scroller: bool);

        /// Specifies the vertical scroll bar state for the image view.
        #[unsafe(method(hasVerticalScroller))]
        #[unsafe(method_family = none)]
        pub unsafe fn hasVerticalScroller(&self) -> bool;

        /// Setter for [`hasVerticalScroller`][Self::hasVerticalScroller].
        #[unsafe(method(setHasVerticalScroller:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setHasVerticalScroller(&self, has_vertical_scroller: bool);

        /// Specifies the automatic-hiding scroll bar state for the image view.
        #[unsafe(method(autohidesScrollers))]
        #[unsafe(method_family = none)]
        pub unsafe fn autohidesScrollers(&self) -> bool;

        /// Setter for [`autohidesScrollers`][Self::autohidesScrollers].
        #[unsafe(method(setAutohidesScrollers:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAutohidesScrollers(&self, autohides_scrollers: bool);

        /// Specifies the drag-and-drop support state for the image view.
        #[unsafe(method(supportsDragAndDrop))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportsDragAndDrop(&self) -> bool;

        /// Setter for [`supportsDragAndDrop`][Self::supportsDragAndDrop].
        #[unsafe(method(setSupportsDragAndDrop:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSupportsDragAndDrop(&self, supports_drag_and_drop: bool);

        /// Specifies the editable state for the image view.
        #[unsafe(method(editable))]
        #[unsafe(method_family = none)]
        pub unsafe fn editable(&self) -> bool;

        /// Setter for [`editable`][Self::editable].
        #[unsafe(method(setEditable:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setEditable(&self, editable: bool);

        /// Specifies the image-opening state of the editing pane in the image view.
        #[unsafe(method(doubleClickOpensImageEditPanel))]
        #[unsafe(method_family = none)]
        pub unsafe fn doubleClickOpensImageEditPanel(&self) -> bool;

        /// Setter for [`doubleClickOpensImageEditPanel`][Self::doubleClickOpensImageEditPanel].
        #[unsafe(method(setDoubleClickOpensImageEditPanel:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDoubleClickOpensImageEditPanel(
            &self,
            double_click_opens_image_edit_panel: bool,
        );

        #[cfg(feature = "objc2-core-image")]
        /// Specifies a Core Image filter for image correction.
        ///
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(imageCorrection))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageCorrection(&self) -> Option<Retained<CIFilter>>;

        #[cfg(feature = "objc2-core-image")]
        /// Setter for [`imageCorrection`][Self::imageCorrection].
        ///
        /// # Safety
        ///
        /// - `image_correction` might not allow `None`.
        /// - This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setImageCorrection:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImageCorrection(&self, image_correction: Option<&CIFilter>);

        /// Specifies the background color for the image view.
        ///
        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(backgroundColor))]
        #[unsafe(method_family = none)]
        pub unsafe fn backgroundColor(&self) -> Option<Retained<NSColor>>;

        /// Setter for [`backgroundColor`][Self::backgroundColor].
        ///
        /// # Safety
        ///
        /// - `background_color` might not allow `None`.
        /// - This is unretained, you must ensure the object is kept alive while in use.
        #[unsafe(method(setBackgroundColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBackgroundColor(&self, background_color: Option<&NSColor>);

        #[cfg(feature = "objc2-core-graphics")]
        /// Sets the image
        /// &
        /// metadata (both retrieved from ImageIO).
        ///
        /// # Safety
        ///
        /// - `image` might not allow `None`.
        /// - `meta_data` generic should be of the correct type.
        /// - `meta_data` might not allow `None`.
        #[unsafe(method(setImage:imageProperties:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImage_imageProperties(
            &self,
            image: Option<&CGImage>,
            meta_data: Option<&NSDictionary>,
        );

        /// Initializes an image view with the image specified by a URL.
        ///
        /// # Safety
        ///
        /// `url` might not allow `None`.
        #[unsafe(method(setImageWithURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImageWithURL(&self, url: Option<&NSURL>);

        #[cfg(feature = "objc2-core-graphics")]
        /// Returns the image associated with the view, after any image corrections.
        #[unsafe(method(image))]
        #[unsafe(method_family = none)]
        pub unsafe fn image(&self) -> Option<Retained<CGImage>>;

        /// Returns the size of the image in the image view.
        #[unsafe(method(imageSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageSize(&self) -> NSSize;

        /// Returns the metadata for the image in the view.
        #[unsafe(method(imageProperties))]
        #[unsafe(method_family = none)]
        pub unsafe fn imageProperties(&self) -> Option<Retained<NSDictionary>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// Sets the rotation angle at the provided origin.
        #[unsafe(method(setRotationAngle:centerPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setRotationAngle_centerPoint(
            &self,
            rotation_angle: CGFloat,
            center_point: NSPoint,
        );

        /// Rotates the image left.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(rotateImageLeft:))]
        #[unsafe(method_family = none)]
        pub unsafe fn rotateImageLeft(&self, sender: Option<&AnyObject>);

        /// Rotates the image right.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(rotateImageRight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn rotateImageRight(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "objc2-core-foundation")]
        /// Sets the zoom factor at the provided origin.
        #[unsafe(method(setImageZoomFactor:centerPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setImageZoomFactor_centerPoint(
            &self,
            zoom_factor: CGFloat,
            center_point: NSPoint,
        );

        /// Zooms the image so that it fits in the specified rectangle.
        #[unsafe(method(zoomImageToRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomImageToRect(&self, rect: NSRect);

        /// Zooms the image so that it fits in the image view.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(zoomImageToFit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomImageToFit(&self, sender: Option<&AnyObject>);

        /// Zooms the image so that it is displayed using its true size.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(zoomImageToActualSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomImageToActualSize(&self, sender: Option<&AnyObject>);

        /// Zooms the image in.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(zoomIn:))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomIn(&self, sender: Option<&AnyObject>);

        /// Zooms the image out.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(zoomOut:))]
        #[unsafe(method_family = none)]
        pub unsafe fn zoomOut(&self, sender: Option<&AnyObject>);

        /// Flips an image along the horizontal axis.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(flipImageHorizontal:))]
        #[unsafe(method_family = none)]
        pub unsafe fn flipImageHorizontal(&self, sender: Option<&AnyObject>);

        /// Flips an image along the vertical axis.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(flipImageVertical:))]
        #[unsafe(method_family = none)]
        pub unsafe fn flipImageVertical(&self, sender: Option<&AnyObject>);

        /// Crops the image using the current selection.
        ///
        /// # Safety
        ///
        /// - `sender` should be of the correct type.
        /// - `sender` might not allow `None`.
        #[unsafe(method(crop:))]
        #[unsafe(method_family = none)]
        pub unsafe fn crop(&self, sender: Option<&AnyObject>);

        #[cfg(feature = "objc2-quartz-core")]
        /// Sets an overlay (Core Animation layer) for the image or the image background.
        ///
        /// # Safety
        ///
        /// - `layer` might not allow `None`.
        /// - `layer_type` might not allow `None`.
        #[unsafe(method(setOverlay:forType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOverlay_forType(
            &self,
            layer: Option<&CALayer>,
            layer_type: Option<&NSString>,
        );

        #[cfg(feature = "objc2-quartz-core")]
        /// Returns the overlay (Core Animation layer) for the image or the image background.
        ///
        /// # Safety
        ///
        /// `layer_type` might not allow `None`.
        #[unsafe(method(overlayForType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn overlayForType(
            &self,
            layer_type: Option<&NSString>,
        ) -> Option<Retained<CALayer>>;

        /// Scrolls the view to the specified point.
        #[unsafe(method(scrollToPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn scrollToPoint(&self, point: NSPoint);

        /// Scrolls the view so that it includes the provided rectangular area.
        #[unsafe(method(scrollToRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn scrollToRect(&self, rect: NSRect);

        /// Converts an image view coordinate to an image coordinate.
        #[unsafe(method(convertViewPointToImagePoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertViewPointToImagePoint(&self, view_point: NSPoint) -> NSPoint;

        /// Converts an image view rectangle to an image rectangle.
        #[unsafe(method(convertViewRectToImageRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertViewRectToImageRect(&self, view_rect: NSRect) -> NSRect;

        /// Converts an image coordinate to an image view coordinate.
        #[unsafe(method(convertImagePointToViewPoint:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertImagePointToViewPoint(&self, image_point: NSPoint) -> NSPoint;

        /// Converts an image rectangle to an image view rectangle.
        #[unsafe(method(convertImageRectToViewRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn convertImageRectToViewRect(&self, image_rect: NSRect) -> NSRect;
    );
}

/// Methods declared on superclass `NSView`.
impl IKImageView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
impl IKImageView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl IKImageView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}