objc2_app_kit/generated/
NSImageRep.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::*;
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
15/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagehintkey?language=objc)
16// NS_TYPED_ENUM
17pub type NSImageHintKey = NSString;
18
19/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagerepmatchesdevice?language=objc)
20pub const NSImageRepMatchesDevice: c_uint = 0;
21
22/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagelayoutdirection?language=objc)
23// NS_ENUM
24#[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    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagerep?language=objc)
46    #[unsafe(super(NSObject))]
47    #[derive(Debug, PartialEq, Eq, Hash)]
48    pub struct NSImageRep;
49);
50
51extern_conformance!(
52    unsafe impl NSCoding for NSImageRep {}
53);
54
55extern_conformance!(
56    unsafe impl NSCopying for NSImageRep {}
57);
58
59unsafe impl CopyingHelper for NSImageRep {
60    type Result = Self;
61}
62
63extern_conformance!(
64    unsafe impl NSObjectProtocol for NSImageRep {}
65);
66
67impl NSImageRep {
68    extern_methods!(
69        #[unsafe(method(init))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
72
73        #[unsafe(method(initWithCoder:))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn initWithCoder(
76            this: Allocated<Self>,
77            coder: &NSCoder,
78        ) -> Option<Retained<Self>>;
79
80        #[unsafe(method(draw))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn draw(&self) -> bool;
83
84        #[unsafe(method(drawAtPoint:))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn drawAtPoint(&self, point: NSPoint) -> bool;
87
88        #[unsafe(method(drawInRect:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn drawInRect(&self, rect: NSRect) -> bool;
91
92        #[cfg(all(feature = "NSGraphics", feature = "objc2-core-foundation"))]
93        #[unsafe(method(drawInRect:fromRect:operation:fraction:respectFlipped:hints:))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints(
96            &self,
97            dst_space_portion_rect: NSRect,
98            src_space_portion_rect: NSRect,
99            op: NSCompositingOperation,
100            requested_alpha: CGFloat,
101            respect_context_is_flipped: bool,
102            hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
103        ) -> bool;
104
105        #[unsafe(method(size))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn size(&self) -> NSSize;
108
109        /// Setter for [`size`][Self::size].
110        #[unsafe(method(setSize:))]
111        #[unsafe(method_family = none)]
112        pub unsafe fn setSize(&self, size: NSSize);
113
114        #[unsafe(method(hasAlpha))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn hasAlpha(&self) -> bool;
117
118        /// Setter for [`hasAlpha`][Self::hasAlpha].
119        #[unsafe(method(setAlpha:))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn setAlpha(&self, alpha: bool);
122
123        #[unsafe(method(isOpaque))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn isOpaque(&self) -> bool;
126
127        /// Setter for [`isOpaque`][Self::isOpaque].
128        #[unsafe(method(setOpaque:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setOpaque(&self, opaque: bool);
131
132        #[cfg(feature = "NSGraphics")]
133        #[unsafe(method(colorSpaceName))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn colorSpaceName(&self) -> Retained<NSColorSpaceName>;
136
137        #[cfg(feature = "NSGraphics")]
138        /// Setter for [`colorSpaceName`][Self::colorSpaceName].
139        #[unsafe(method(setColorSpaceName:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setColorSpaceName(&self, color_space_name: &NSColorSpaceName);
142
143        #[unsafe(method(bitsPerSample))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn bitsPerSample(&self) -> NSInteger;
146
147        /// Setter for [`bitsPerSample`][Self::bitsPerSample].
148        #[unsafe(method(setBitsPerSample:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setBitsPerSample(&self, bits_per_sample: NSInteger);
151
152        #[unsafe(method(pixelsWide))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn pixelsWide(&self) -> NSInteger;
155
156        /// Setter for [`pixelsWide`][Self::pixelsWide].
157        #[unsafe(method(setPixelsWide:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setPixelsWide(&self, pixels_wide: NSInteger);
160
161        #[unsafe(method(pixelsHigh))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn pixelsHigh(&self) -> NSInteger;
164
165        /// Setter for [`pixelsHigh`][Self::pixelsHigh].
166        #[unsafe(method(setPixelsHigh:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setPixelsHigh(&self, pixels_high: NSInteger);
169
170        #[unsafe(method(layoutDirection))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn layoutDirection(&self) -> NSImageLayoutDirection;
173
174        /// Setter for [`layoutDirection`][Self::layoutDirection].
175        #[unsafe(method(setLayoutDirection:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn setLayoutDirection(&self, layout_direction: NSImageLayoutDirection);
178
179        #[unsafe(method(registerImageRepClass:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn registerImageRepClass(image_rep_class: &AnyClass);
182
183        #[unsafe(method(unregisterImageRepClass:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn unregisterImageRepClass(image_rep_class: &AnyClass);
186
187        #[unsafe(method(registeredImageRepClasses))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn registeredImageRepClasses() -> Retained<NSArray<AnyClass>>;
190
191        #[deprecated = "Use +imageRepClassForType: instead"]
192        #[unsafe(method(imageRepClassForFileType:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn imageRepClassForFileType(r#type: &NSString) -> Option<&'static AnyClass>;
195
196        #[cfg(feature = "NSPasteboard")]
197        #[deprecated = "Use +imageRepClassForType: instead"]
198        #[unsafe(method(imageRepClassForPasteboardType:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn imageRepClassForPasteboardType(
201            r#type: &NSPasteboardType,
202        ) -> Option<&'static AnyClass>;
203
204        #[unsafe(method(imageRepClassForType:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn imageRepClassForType(r#type: &NSString) -> Option<&'static AnyClass>;
207
208        #[unsafe(method(imageRepClassForData:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn imageRepClassForData(data: &NSData) -> Option<&'static AnyClass>;
211
212        #[unsafe(method(canInitWithData:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn canInitWithData(data: &NSData) -> bool;
215
216        #[deprecated = "Use +imageUnfilteredTypes instead"]
217        #[unsafe(method(imageUnfilteredFileTypes))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn imageUnfilteredFileTypes() -> Retained<NSArray<NSString>>;
220
221        #[cfg(feature = "NSPasteboard")]
222        #[deprecated = "Use +imageUnfilteredTypes instead"]
223        #[unsafe(method(imageUnfilteredPasteboardTypes))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn imageUnfilteredPasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
226
227        #[deprecated = "Use +imageTypes instead"]
228        #[unsafe(method(imageFileTypes))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn imageFileTypes() -> Retained<NSArray<NSString>>;
231
232        #[cfg(feature = "NSPasteboard")]
233        #[deprecated = "Use +imageTypes instead"]
234        #[unsafe(method(imagePasteboardTypes))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn imagePasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
237
238        #[unsafe(method(imageUnfilteredTypes))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn imageUnfilteredTypes() -> Retained<NSArray<NSString>>;
241
242        #[unsafe(method(imageTypes))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn imageTypes() -> Retained<NSArray<NSString>>;
245
246        #[cfg(feature = "NSPasteboard")]
247        #[unsafe(method(canInitWithPasteboard:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
250
251        #[unsafe(method(imageRepsWithContentsOfFile:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn imageRepsWithContentsOfFile(
254            filename: &NSString,
255        ) -> Option<Retained<NSArray<NSImageRep>>>;
256
257        #[unsafe(method(imageRepWithContentsOfFile:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn imageRepWithContentsOfFile(
260            filename: &NSString,
261        ) -> Option<Retained<NSImageRep>>;
262
263        #[unsafe(method(imageRepsWithContentsOfURL:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn imageRepsWithContentsOfURL(
266            url: &NSURL,
267        ) -> Option<Retained<NSArray<NSImageRep>>>;
268
269        #[unsafe(method(imageRepWithContentsOfURL:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn imageRepWithContentsOfURL(url: &NSURL) -> Option<Retained<NSImageRep>>;
272
273        #[cfg(feature = "NSPasteboard")]
274        #[unsafe(method(imageRepsWithPasteboard:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn imageRepsWithPasteboard(
277            pasteboard: &NSPasteboard,
278        ) -> Option<Retained<NSArray<NSImageRep>>>;
279
280        #[cfg(feature = "NSPasteboard")]
281        #[unsafe(method(imageRepWithPasteboard:))]
282        #[unsafe(method_family = none)]
283        pub unsafe fn imageRepWithPasteboard(
284            pasteboard: &NSPasteboard,
285        ) -> Option<Retained<NSImageRep>>;
286
287        #[cfg(all(feature = "NSGraphicsContext", feature = "objc2-core-graphics"))]
288        #[cfg(target_vendor = "apple")]
289        #[unsafe(method(CGImageForProposedRect:context:hints:))]
290        #[unsafe(method_family = none)]
291        pub unsafe fn CGImageForProposedRect_context_hints(
292            &self,
293            proposed_dest_rect: *mut NSRect,
294            context: Option<&NSGraphicsContext>,
295            hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
296        ) -> Option<Retained<CGImage>>;
297    );
298}
299
300/// Methods declared on superclass `NSObject`.
301impl NSImageRep {
302    extern_methods!(
303        #[unsafe(method(new))]
304        #[unsafe(method_family = new)]
305        pub unsafe fn new() -> Retained<Self>;
306    );
307}
308
309extern "C" {
310    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagerepregistrydidchangenotification?language=objc)
311    pub static NSImageRepRegistryDidChangeNotification: &'static NSNotificationName;
312}