objc2_pencil_kit/generated/PKDrawing.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5#[cfg(feature = "objc2-app-kit")]
6#[cfg(target_os = "macos")]
7use objc2_app_kit::*;
8#[cfg(feature = "objc2-core-foundation")]
9use objc2_core_foundation::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14extern "C" {
15 /// The UTType for storing drawing data.
16 ///
17 /// See also [Apple's documentation](https://developer.apple.com/documentation/pencilkit/pkappledrawingtypeidentifier?language=objc)
18 #[cfg(feature = "objc2-core-foundation")]
19 pub static PKAppleDrawingTypeIdentifier: &'static CFString;
20}
21
22extern_class!(
23 /// The data model object for storing drawing data created from PKCanvasView.
24 ///
25 /// See also [Apple's documentation](https://developer.apple.com/documentation/pencilkit/pkdrawing?language=objc)
26 #[unsafe(super(NSObject))]
27 #[derive(Debug, PartialEq, Eq, Hash)]
28 pub struct PKDrawing;
29);
30
31unsafe impl Send for PKDrawing {}
32
33unsafe impl Sync for PKDrawing {}
34
35extern_conformance!(
36 unsafe impl NSCoding for PKDrawing {}
37);
38
39extern_conformance!(
40 unsafe impl NSCopying for PKDrawing {}
41);
42
43unsafe impl CopyingHelper for PKDrawing {
44 type Result = Self;
45}
46
47extern_conformance!(
48 unsafe impl NSObjectProtocol for PKDrawing {}
49);
50
51extern_conformance!(
52 unsafe impl NSSecureCoding for PKDrawing {}
53);
54
55impl PKDrawing {
56 extern_methods!(
57 /// Initializes and returns a blank drawing.
58 #[unsafe(method(init))]
59 #[unsafe(method_family = init)]
60 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
61
62 #[cfg(feature = "PKStroke")]
63 /// Initializes a drawing with an array of strokes.
64 #[unsafe(method(initWithStrokes:))]
65 #[unsafe(method_family = init)]
66 pub unsafe fn initWithStrokes(
67 this: Allocated<Self>,
68 strokes: &NSArray<PKStroke>,
69 ) -> Retained<Self>;
70
71 /// Initializes and returns the drawing with the specified data.
72 ///
73 ///
74 /// Parameter `data`: The data containing the drawing data.
75 ///
76 /// Parameter `error`: If an error occurs, upon return the NSError object describes the error.
77 /// Set to NULL to ignore errors.
78 ///
79 /// Returns: On success, an initialized PKDrawing object. If nil, the outError parameter
80 /// contains an NSError instance describing the problem.
81 #[unsafe(method(initWithData:error:_))]
82 #[unsafe(method_family = init)]
83 pub unsafe fn initWithData_error(
84 this: Allocated<Self>,
85 data: &NSData,
86 ) -> Result<Retained<Self>, Retained<NSError>>;
87
88 /// Generate a data representation of the drawing.
89 ///
90 ///
91 /// Returns: A NSData object containing a representation of the drawing.
92 #[unsafe(method(dataRepresentation))]
93 #[unsafe(method_family = none)]
94 pub unsafe fn dataRepresentation(&self) -> Retained<NSData>;
95
96 #[cfg(feature = "PKStroke")]
97 /// The strokes that this drawing contains.
98 ///
99 /// This property is not atomic.
100 ///
101 /// # Safety
102 ///
103 /// This might not be thread-safe.
104 #[unsafe(method(strokes))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn strokes(&self) -> Retained<NSArray<PKStroke>>;
107
108 #[cfg(feature = "objc2-core-foundation")]
109 /// The bounds of the drawing's contents, taking into account the rendered width of all content.
110 /// If these bounds are used to render an image with `imageFromRect:scale:`, no contents will be cropped.
111 ///
112 /// This property is not atomic.
113 ///
114 /// # Safety
115 ///
116 /// This might not be thread-safe.
117 #[unsafe(method(bounds))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn bounds(&self) -> CGRect;
120
121 #[cfg(feature = "PKContentVersion")]
122 /// The PencilKit version required to use this drawing.
123 ///
124 /// This property is not atomic.
125 ///
126 /// # Safety
127 ///
128 /// This might not be thread-safe.
129 #[unsafe(method(requiredContentVersion))]
130 #[unsafe(method_family = none)]
131 pub unsafe fn requiredContentVersion(&self) -> PKContentVersion;
132
133 #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
134 #[cfg(target_os = "macos")]
135 #[unsafe(method(imageFromRect:scale:))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn imageFromRect_scale(&self, rect: CGRect, scale: CGFloat)
138 -> Retained<NSImage>;
139
140 #[cfg(feature = "objc2-core-foundation")]
141 /// Returns a new drawing with `transform` applied.
142 ///
143 ///
144 /// Parameter `transform`: The transform to apply to this drawing.
145 ///
146 /// Returns: A new copy of this drawing with `transform` applied.
147 #[unsafe(method(drawingByApplyingTransform:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn drawingByApplyingTransform(
150 &self,
151 transform: CGAffineTransform,
152 ) -> Retained<PKDrawing>;
153
154 /// Returns a new drawing by appending the contents of `drawing` on top of the receiver’s contents.
155 ///
156 ///
157 /// Parameter `drawing`: The drawing to append.
158 ///
159 /// Returns: A new copy of this drawing with `drawing` appended onto it.
160 #[unsafe(method(drawingByAppendingDrawing:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn drawingByAppendingDrawing(&self, drawing: &PKDrawing) -> Retained<PKDrawing>;
163
164 #[cfg(feature = "PKStroke")]
165 /// Create a new drawing by appending an array of strokes to this drawing.
166 /// This is a convenience method, to quickly add strokes to a drawing.
167 ///
168 ///
169 /// Parameter `strokes`: The strokes to append.
170 ///
171 /// Returns: A new copy of this drawing with `strokes` appended onto it.
172 #[unsafe(method(drawingByAppendingStrokes:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn drawingByAppendingStrokes(
175 &self,
176 strokes: &NSArray<PKStroke>,
177 ) -> Retained<PKDrawing>;
178 );
179}
180
181/// Methods declared on superclass `NSObject`.
182impl PKDrawing {
183 extern_methods!(
184 #[unsafe(method(new))]
185 #[unsafe(method_family = new)]
186 pub unsafe fn new() -> Retained<Self>;
187 );
188}