objc2_app_kit/generated/
NSImageRep.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-graphics")]
9#[cfg(target_vendor = "apple")]
10use objc2_core_graphics::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15pub type NSImageHintKey = NSString;
18
19pub const NSImageRepMatchesDevice: c_uint = 0;
21
22#[repr(transparent)]
25#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
26pub struct NSImageLayoutDirection(pub NSInteger);
27impl NSImageLayoutDirection {
28 #[doc(alias = "NSImageLayoutDirectionUnspecified")]
29 pub const Unspecified: Self = Self(-1);
30 #[doc(alias = "NSImageLayoutDirectionLeftToRight")]
31 pub const LeftToRight: Self = Self(2);
32 #[doc(alias = "NSImageLayoutDirectionRightToLeft")]
33 pub const RightToLeft: Self = Self(3);
34}
35
36unsafe impl Encode for NSImageLayoutDirection {
37 const ENCODING: Encoding = NSInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSImageLayoutDirection {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44extern_class!(
45 #[unsafe(super(NSObject))]
47 #[derive(Debug, PartialEq, Eq, Hash)]
48 pub struct NSImageRep;
49);
50
51unsafe impl NSCoding for NSImageRep {}
52
53unsafe impl NSCopying for NSImageRep {}
54
55unsafe impl CopyingHelper for NSImageRep {
56 type Result = Self;
57}
58
59unsafe impl NSObjectProtocol for NSImageRep {}
60
61impl NSImageRep {
62 extern_methods!(
63 #[unsafe(method(init))]
64 #[unsafe(method_family = init)]
65 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
66
67 #[unsafe(method(initWithCoder:))]
68 #[unsafe(method_family = init)]
69 pub unsafe fn initWithCoder(
70 this: Allocated<Self>,
71 coder: &NSCoder,
72 ) -> Option<Retained<Self>>;
73
74 #[unsafe(method(draw))]
75 #[unsafe(method_family = none)]
76 pub unsafe fn draw(&self) -> bool;
77
78 #[unsafe(method(drawAtPoint:))]
79 #[unsafe(method_family = none)]
80 pub unsafe fn drawAtPoint(&self, point: NSPoint) -> bool;
81
82 #[unsafe(method(drawInRect:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn drawInRect(&self, rect: NSRect) -> bool;
85
86 #[cfg(all(feature = "NSGraphics", feature = "objc2-core-foundation"))]
87 #[unsafe(method(drawInRect:fromRect:operation:fraction:respectFlipped:hints:))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints(
90 &self,
91 dst_space_portion_rect: NSRect,
92 src_space_portion_rect: NSRect,
93 op: NSCompositingOperation,
94 requested_alpha: CGFloat,
95 respect_context_is_flipped: bool,
96 hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
97 ) -> bool;
98
99 #[unsafe(method(size))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn size(&self) -> NSSize;
102
103 #[unsafe(method(setSize:))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn setSize(&self, size: NSSize);
107
108 #[unsafe(method(hasAlpha))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn hasAlpha(&self) -> bool;
111
112 #[unsafe(method(setAlpha:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn setAlpha(&self, alpha: bool);
116
117 #[unsafe(method(isOpaque))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn isOpaque(&self) -> bool;
120
121 #[unsafe(method(setOpaque:))]
123 #[unsafe(method_family = none)]
124 pub unsafe fn setOpaque(&self, opaque: bool);
125
126 #[cfg(feature = "NSGraphics")]
127 #[unsafe(method(colorSpaceName))]
128 #[unsafe(method_family = none)]
129 pub unsafe fn colorSpaceName(&self) -> Retained<NSColorSpaceName>;
130
131 #[cfg(feature = "NSGraphics")]
132 #[unsafe(method(setColorSpaceName:))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn setColorSpaceName(&self, color_space_name: &NSColorSpaceName);
136
137 #[unsafe(method(bitsPerSample))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn bitsPerSample(&self) -> NSInteger;
140
141 #[unsafe(method(setBitsPerSample:))]
143 #[unsafe(method_family = none)]
144 pub unsafe fn setBitsPerSample(&self, bits_per_sample: NSInteger);
145
146 #[unsafe(method(pixelsWide))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn pixelsWide(&self) -> NSInteger;
149
150 #[unsafe(method(setPixelsWide:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn setPixelsWide(&self, pixels_wide: NSInteger);
154
155 #[unsafe(method(pixelsHigh))]
156 #[unsafe(method_family = none)]
157 pub unsafe fn pixelsHigh(&self) -> NSInteger;
158
159 #[unsafe(method(setPixelsHigh:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn setPixelsHigh(&self, pixels_high: NSInteger);
163
164 #[unsafe(method(layoutDirection))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn layoutDirection(&self) -> NSImageLayoutDirection;
167
168 #[unsafe(method(setLayoutDirection:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn setLayoutDirection(&self, layout_direction: NSImageLayoutDirection);
172
173 #[unsafe(method(registerImageRepClass:))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn registerImageRepClass(image_rep_class: &AnyClass);
176
177 #[unsafe(method(unregisterImageRepClass:))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn unregisterImageRepClass(image_rep_class: &AnyClass);
180
181 #[unsafe(method(registeredImageRepClasses))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn registeredImageRepClasses() -> Retained<NSArray<AnyClass>>;
184
185 #[deprecated = "Use +imageRepClassForType: instead"]
186 #[unsafe(method(imageRepClassForFileType:))]
187 #[unsafe(method_family = none)]
188 pub unsafe fn imageRepClassForFileType(r#type: &NSString) -> Option<&'static AnyClass>;
189
190 #[cfg(feature = "NSPasteboard")]
191 #[deprecated = "Use +imageRepClassForType: instead"]
192 #[unsafe(method(imageRepClassForPasteboardType:))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn imageRepClassForPasteboardType(
195 r#type: &NSPasteboardType,
196 ) -> Option<&'static AnyClass>;
197
198 #[unsafe(method(imageRepClassForType:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn imageRepClassForType(r#type: &NSString) -> Option<&'static AnyClass>;
201
202 #[unsafe(method(imageRepClassForData:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn imageRepClassForData(data: &NSData) -> Option<&'static AnyClass>;
205
206 #[unsafe(method(canInitWithData:))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn canInitWithData(data: &NSData) -> bool;
209
210 #[deprecated = "Use +imageUnfilteredTypes instead"]
211 #[unsafe(method(imageUnfilteredFileTypes))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn imageUnfilteredFileTypes() -> Retained<NSArray<NSString>>;
214
215 #[cfg(feature = "NSPasteboard")]
216 #[deprecated = "Use +imageUnfilteredTypes instead"]
217 #[unsafe(method(imageUnfilteredPasteboardTypes))]
218 #[unsafe(method_family = none)]
219 pub unsafe fn imageUnfilteredPasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
220
221 #[deprecated = "Use +imageTypes instead"]
222 #[unsafe(method(imageFileTypes))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn imageFileTypes() -> Retained<NSArray<NSString>>;
225
226 #[cfg(feature = "NSPasteboard")]
227 #[deprecated = "Use +imageTypes instead"]
228 #[unsafe(method(imagePasteboardTypes))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn imagePasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
231
232 #[unsafe(method(imageUnfilteredTypes))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn imageUnfilteredTypes() -> Retained<NSArray<NSString>>;
235
236 #[unsafe(method(imageTypes))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn imageTypes() -> Retained<NSArray<NSString>>;
239
240 #[cfg(feature = "NSPasteboard")]
241 #[unsafe(method(canInitWithPasteboard:))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
244
245 #[unsafe(method(imageRepsWithContentsOfFile:))]
246 #[unsafe(method_family = none)]
247 pub unsafe fn imageRepsWithContentsOfFile(
248 filename: &NSString,
249 ) -> Option<Retained<NSArray<NSImageRep>>>;
250
251 #[unsafe(method(imageRepWithContentsOfFile:))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn imageRepWithContentsOfFile(
254 filename: &NSString,
255 ) -> Option<Retained<NSImageRep>>;
256
257 #[unsafe(method(imageRepsWithContentsOfURL:))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn imageRepsWithContentsOfURL(
260 url: &NSURL,
261 ) -> Option<Retained<NSArray<NSImageRep>>>;
262
263 #[unsafe(method(imageRepWithContentsOfURL:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn imageRepWithContentsOfURL(url: &NSURL) -> Option<Retained<NSImageRep>>;
266
267 #[cfg(feature = "NSPasteboard")]
268 #[unsafe(method(imageRepsWithPasteboard:))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn imageRepsWithPasteboard(
271 pasteboard: &NSPasteboard,
272 ) -> Option<Retained<NSArray<NSImageRep>>>;
273
274 #[cfg(feature = "NSPasteboard")]
275 #[unsafe(method(imageRepWithPasteboard:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn imageRepWithPasteboard(
278 pasteboard: &NSPasteboard,
279 ) -> Option<Retained<NSImageRep>>;
280
281 #[cfg(all(feature = "NSGraphicsContext", feature = "objc2-core-graphics"))]
282 #[cfg(target_vendor = "apple")]
283 #[unsafe(method(CGImageForProposedRect:context:hints:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn CGImageForProposedRect_context_hints(
286 &self,
287 proposed_dest_rect: *mut NSRect,
288 context: Option<&NSGraphicsContext>,
289 hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
290 ) -> Option<Retained<CGImage>>;
291 );
292}
293
294impl NSImageRep {
296 extern_methods!(
297 #[unsafe(method(new))]
298 #[unsafe(method_family = new)]
299 pub unsafe fn new() -> Retained<Self>;
300 );
301}
302
303extern "C" {
304 pub static NSImageRepRegistryDidChangeNotification: &'static NSNotificationName;
306}