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 fn init(this: Allocated<Self>) -> Retained<Self>;
72
73        /// # Safety
74        ///
75        /// `coder` possibly has further requirements.
76        #[unsafe(method(initWithCoder:))]
77        #[unsafe(method_family = init)]
78        pub unsafe fn initWithCoder(
79            this: Allocated<Self>,
80            coder: &NSCoder,
81        ) -> Option<Retained<Self>>;
82
83        #[unsafe(method(draw))]
84        #[unsafe(method_family = none)]
85        pub fn draw(&self) -> bool;
86
87        #[unsafe(method(drawAtPoint:))]
88        #[unsafe(method_family = none)]
89        pub fn drawAtPoint(&self, point: NSPoint) -> bool;
90
91        #[unsafe(method(drawInRect:))]
92        #[unsafe(method_family = none)]
93        pub fn drawInRect(&self, rect: NSRect) -> bool;
94
95        #[cfg(all(feature = "NSGraphics", feature = "objc2-core-foundation"))]
96        /// # Safety
97        ///
98        /// `hints` generic should be of the correct type.
99        #[unsafe(method(drawInRect:fromRect:operation:fraction:respectFlipped:hints:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn drawInRect_fromRect_operation_fraction_respectFlipped_hints(
102            &self,
103            dst_space_portion_rect: NSRect,
104            src_space_portion_rect: NSRect,
105            op: NSCompositingOperation,
106            requested_alpha: CGFloat,
107            respect_context_is_flipped: bool,
108            hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
109        ) -> bool;
110
111        #[unsafe(method(size))]
112        #[unsafe(method_family = none)]
113        pub fn size(&self) -> NSSize;
114
115        /// Setter for [`size`][Self::size].
116        #[unsafe(method(setSize:))]
117        #[unsafe(method_family = none)]
118        pub fn setSize(&self, size: NSSize);
119
120        #[unsafe(method(hasAlpha))]
121        #[unsafe(method_family = none)]
122        pub fn hasAlpha(&self) -> bool;
123
124        /// Setter for [`hasAlpha`][Self::hasAlpha].
125        #[unsafe(method(setAlpha:))]
126        #[unsafe(method_family = none)]
127        pub fn setAlpha(&self, alpha: bool);
128
129        #[unsafe(method(isOpaque))]
130        #[unsafe(method_family = none)]
131        pub fn isOpaque(&self) -> bool;
132
133        /// Setter for [`isOpaque`][Self::isOpaque].
134        #[unsafe(method(setOpaque:))]
135        #[unsafe(method_family = none)]
136        pub fn setOpaque(&self, opaque: bool);
137
138        #[cfg(feature = "NSGraphics")]
139        #[unsafe(method(colorSpaceName))]
140        #[unsafe(method_family = none)]
141        pub fn colorSpaceName(&self) -> Retained<NSColorSpaceName>;
142
143        #[cfg(feature = "NSGraphics")]
144        /// Setter for [`colorSpaceName`][Self::colorSpaceName].
145        ///
146        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
147        #[unsafe(method(setColorSpaceName:))]
148        #[unsafe(method_family = none)]
149        pub fn setColorSpaceName(&self, color_space_name: &NSColorSpaceName);
150
151        #[unsafe(method(bitsPerSample))]
152        #[unsafe(method_family = none)]
153        pub fn bitsPerSample(&self) -> NSInteger;
154
155        /// Setter for [`bitsPerSample`][Self::bitsPerSample].
156        #[unsafe(method(setBitsPerSample:))]
157        #[unsafe(method_family = none)]
158        pub fn setBitsPerSample(&self, bits_per_sample: NSInteger);
159
160        #[unsafe(method(pixelsWide))]
161        #[unsafe(method_family = none)]
162        pub fn pixelsWide(&self) -> NSInteger;
163
164        /// Setter for [`pixelsWide`][Self::pixelsWide].
165        #[unsafe(method(setPixelsWide:))]
166        #[unsafe(method_family = none)]
167        pub fn setPixelsWide(&self, pixels_wide: NSInteger);
168
169        #[unsafe(method(pixelsHigh))]
170        #[unsafe(method_family = none)]
171        pub fn pixelsHigh(&self) -> NSInteger;
172
173        /// Setter for [`pixelsHigh`][Self::pixelsHigh].
174        #[unsafe(method(setPixelsHigh:))]
175        #[unsafe(method_family = none)]
176        pub fn setPixelsHigh(&self, pixels_high: NSInteger);
177
178        #[unsafe(method(layoutDirection))]
179        #[unsafe(method_family = none)]
180        pub fn layoutDirection(&self) -> NSImageLayoutDirection;
181
182        /// Setter for [`layoutDirection`][Self::layoutDirection].
183        #[unsafe(method(setLayoutDirection:))]
184        #[unsafe(method_family = none)]
185        pub fn setLayoutDirection(&self, layout_direction: NSImageLayoutDirection);
186
187        /// # Safety
188        ///
189        /// `image_rep_class` probably has further requirements.
190        #[unsafe(method(registerImageRepClass:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn registerImageRepClass(image_rep_class: &AnyClass);
193
194        /// # Safety
195        ///
196        /// `image_rep_class` probably has further requirements.
197        #[unsafe(method(unregisterImageRepClass:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn unregisterImageRepClass(image_rep_class: &AnyClass);
200
201        #[unsafe(method(registeredImageRepClasses))]
202        #[unsafe(method_family = none)]
203        pub fn registeredImageRepClasses() -> Retained<NSArray<AnyClass>>;
204
205        #[deprecated = "Use +imageRepClassForType: instead"]
206        #[unsafe(method(imageRepClassForFileType:))]
207        #[unsafe(method_family = none)]
208        pub fn imageRepClassForFileType(r#type: &NSString) -> Option<&'static AnyClass>;
209
210        #[cfg(feature = "NSPasteboard")]
211        #[deprecated = "Use +imageRepClassForType: instead"]
212        #[unsafe(method(imageRepClassForPasteboardType:))]
213        #[unsafe(method_family = none)]
214        pub fn imageRepClassForPasteboardType(
215            r#type: &NSPasteboardType,
216        ) -> Option<&'static AnyClass>;
217
218        #[unsafe(method(imageRepClassForType:))]
219        #[unsafe(method_family = none)]
220        pub fn imageRepClassForType(r#type: &NSString) -> Option<&'static AnyClass>;
221
222        #[unsafe(method(imageRepClassForData:))]
223        #[unsafe(method_family = none)]
224        pub fn imageRepClassForData(data: &NSData) -> Option<&'static AnyClass>;
225
226        #[unsafe(method(canInitWithData:))]
227        #[unsafe(method_family = none)]
228        pub fn canInitWithData(data: &NSData) -> bool;
229
230        #[deprecated = "Use +imageUnfilteredTypes instead"]
231        #[unsafe(method(imageUnfilteredFileTypes))]
232        #[unsafe(method_family = none)]
233        pub fn imageUnfilteredFileTypes() -> Retained<NSArray<NSString>>;
234
235        #[cfg(feature = "NSPasteboard")]
236        #[deprecated = "Use +imageUnfilteredTypes instead"]
237        #[unsafe(method(imageUnfilteredPasteboardTypes))]
238        #[unsafe(method_family = none)]
239        pub fn imageUnfilteredPasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
240
241        #[deprecated = "Use +imageTypes instead"]
242        #[unsafe(method(imageFileTypes))]
243        #[unsafe(method_family = none)]
244        pub fn imageFileTypes() -> Retained<NSArray<NSString>>;
245
246        #[cfg(feature = "NSPasteboard")]
247        #[deprecated = "Use +imageTypes instead"]
248        #[unsafe(method(imagePasteboardTypes))]
249        #[unsafe(method_family = none)]
250        pub fn imagePasteboardTypes() -> Retained<NSArray<NSPasteboardType>>;
251
252        #[unsafe(method(imageUnfilteredTypes))]
253        #[unsafe(method_family = none)]
254        pub fn imageUnfilteredTypes() -> Retained<NSArray<NSString>>;
255
256        #[unsafe(method(imageTypes))]
257        #[unsafe(method_family = none)]
258        pub fn imageTypes() -> Retained<NSArray<NSString>>;
259
260        #[cfg(feature = "NSPasteboard")]
261        #[unsafe(method(canInitWithPasteboard:))]
262        #[unsafe(method_family = none)]
263        pub fn canInitWithPasteboard(pasteboard: &NSPasteboard) -> bool;
264
265        #[unsafe(method(imageRepsWithContentsOfFile:))]
266        #[unsafe(method_family = none)]
267        pub fn imageRepsWithContentsOfFile(
268            filename: &NSString,
269        ) -> Option<Retained<NSArray<NSImageRep>>>;
270
271        #[unsafe(method(imageRepWithContentsOfFile:))]
272        #[unsafe(method_family = none)]
273        pub fn imageRepWithContentsOfFile(filename: &NSString) -> Option<Retained<NSImageRep>>;
274
275        #[unsafe(method(imageRepsWithContentsOfURL:))]
276        #[unsafe(method_family = none)]
277        pub fn imageRepsWithContentsOfURL(url: &NSURL) -> Option<Retained<NSArray<NSImageRep>>>;
278
279        #[unsafe(method(imageRepWithContentsOfURL:))]
280        #[unsafe(method_family = none)]
281        pub fn imageRepWithContentsOfURL(url: &NSURL) -> Option<Retained<NSImageRep>>;
282
283        #[cfg(feature = "NSPasteboard")]
284        #[unsafe(method(imageRepsWithPasteboard:))]
285        #[unsafe(method_family = none)]
286        pub fn imageRepsWithPasteboard(
287            pasteboard: &NSPasteboard,
288        ) -> Option<Retained<NSArray<NSImageRep>>>;
289
290        #[cfg(feature = "NSPasteboard")]
291        #[unsafe(method(imageRepWithPasteboard:))]
292        #[unsafe(method_family = none)]
293        pub fn imageRepWithPasteboard(pasteboard: &NSPasteboard) -> Option<Retained<NSImageRep>>;
294
295        #[cfg(all(feature = "NSGraphicsContext", feature = "objc2-core-graphics"))]
296        #[cfg(target_vendor = "apple")]
297        /// # Safety
298        ///
299        /// - `proposed_dest_rect` must be a valid pointer or null.
300        /// - `hints` generic should be of the correct type.
301        #[unsafe(method(CGImageForProposedRect:context:hints:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn CGImageForProposedRect_context_hints(
304            &self,
305            proposed_dest_rect: *mut NSRect,
306            context: Option<&NSGraphicsContext>,
307            hints: Option<&NSDictionary<NSImageHintKey, AnyObject>>,
308        ) -> Option<Retained<CGImage>>;
309    );
310}
311
312/// Methods declared on superclass `NSObject`.
313impl NSImageRep {
314    extern_methods!(
315        #[unsafe(method(new))]
316        #[unsafe(method_family = new)]
317        pub fn new() -> Retained<Self>;
318    );
319}
320
321impl DefaultRetained for NSImageRep {
322    #[inline]
323    fn default_retained() -> Retained<Self> {
324        Self::new()
325    }
326}
327
328extern "C" {
329    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagerepregistrydidchangenotification?language=objc)
330    pub static NSImageRepRegistryDidChangeNotification: &'static NSNotificationName;
331}