objc2_app_kit/generated/
NSGraphicsContext.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-graphics")]
7#[cfg(target_vendor = "apple")]
8use objc2_core_graphics::*;
9#[cfg(feature = "objc2-core-image")]
10#[cfg(target_vendor = "apple")]
11use objc2_core_image::*;
12use objc2_foundation::*;
13
14use crate::*;
15
16pub type NSGraphicsContextAttributeKey = NSString;
19
20extern "C" {
21 pub static NSGraphicsContextDestinationAttributeName: &'static NSGraphicsContextAttributeKey;
23}
24
25extern "C" {
26 pub static NSGraphicsContextRepresentationFormatAttributeName:
28 &'static NSGraphicsContextAttributeKey;
29}
30
31pub type NSGraphicsContextRepresentationFormatName = NSString;
34
35extern "C" {
36 pub static NSGraphicsContextPSFormat: &'static NSGraphicsContextRepresentationFormatName;
38}
39
40extern "C" {
41 pub static NSGraphicsContextPDFFormat: &'static NSGraphicsContextRepresentationFormatName;
43}
44
45#[repr(transparent)]
48#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
49pub struct NSImageInterpolation(pub NSUInteger);
50impl NSImageInterpolation {
51 #[doc(alias = "NSImageInterpolationDefault")]
52 pub const Default: Self = Self(0);
53 #[doc(alias = "NSImageInterpolationNone")]
54 pub const None: Self = Self(1);
55 #[doc(alias = "NSImageInterpolationLow")]
56 pub const Low: Self = Self(2);
57 #[doc(alias = "NSImageInterpolationMedium")]
58 pub const Medium: Self = Self(4);
59 #[doc(alias = "NSImageInterpolationHigh")]
60 pub const High: Self = Self(3);
61}
62
63unsafe impl Encode for NSImageInterpolation {
64 const ENCODING: Encoding = NSUInteger::ENCODING;
65}
66
67unsafe impl RefEncode for NSImageInterpolation {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71extern_class!(
72 #[unsafe(super(NSObject))]
74 #[derive(Debug, PartialEq, Eq, Hash)]
75 pub struct NSGraphicsContext;
76);
77
78extern_conformance!(
79 unsafe impl NSObjectProtocol for NSGraphicsContext {}
80);
81
82impl NSGraphicsContext {
83 extern_methods!(
84 #[unsafe(method(graphicsContextWithAttributes:))]
88 #[unsafe(method_family = none)]
89 pub unsafe fn graphicsContextWithAttributes(
90 attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
91 ) -> Option<Retained<NSGraphicsContext>>;
92
93 #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
94 #[unsafe(method(graphicsContextWithBitmapImageRep:))]
95 #[unsafe(method_family = none)]
96 pub fn graphicsContextWithBitmapImageRep(
97 bitmap_rep: &NSBitmapImageRep,
98 ) -> Option<Retained<NSGraphicsContext>>;
99
100 #[cfg(feature = "objc2-core-graphics")]
101 #[cfg(target_vendor = "apple")]
102 #[unsafe(method(graphicsContextWithCGContext:flipped:))]
103 #[unsafe(method_family = none)]
104 pub fn graphicsContextWithCGContext_flipped(
105 graphics_port: &CGContext,
106 initial_flipped_state: bool,
107 ) -> Retained<NSGraphicsContext>;
108
109 #[unsafe(method(currentContext))]
110 #[unsafe(method_family = none)]
111 pub fn currentContext() -> Option<Retained<NSGraphicsContext>>;
112
113 #[unsafe(method(setCurrentContext:))]
115 #[unsafe(method_family = none)]
116 pub fn setCurrentContext(current_context: Option<&NSGraphicsContext>);
117
118 #[unsafe(method(currentContextDrawingToScreen))]
119 #[unsafe(method_family = none)]
120 pub fn currentContextDrawingToScreen() -> bool;
121
122 #[unsafe(method(saveGraphicsState))]
123 #[unsafe(method_family = none)]
124 pub fn saveGraphicsState_class();
125
126 #[unsafe(method(restoreGraphicsState))]
127 #[unsafe(method_family = none)]
128 pub fn restoreGraphicsState_class();
129
130 #[unsafe(method(attributes))]
131 #[unsafe(method_family = none)]
132 pub fn attributes(
133 &self,
134 ) -> Option<Retained<NSDictionary<NSGraphicsContextAttributeKey, AnyObject>>>;
135
136 #[unsafe(method(isDrawingToScreen))]
137 #[unsafe(method_family = none)]
138 pub fn isDrawingToScreen(&self) -> bool;
139
140 #[unsafe(method(saveGraphicsState))]
141 #[unsafe(method_family = none)]
142 pub fn saveGraphicsState(&self);
143
144 #[unsafe(method(restoreGraphicsState))]
145 #[unsafe(method_family = none)]
146 pub fn restoreGraphicsState(&self);
147
148 #[unsafe(method(flushGraphics))]
149 #[unsafe(method_family = none)]
150 pub fn flushGraphics(&self);
151
152 #[cfg(feature = "objc2-core-graphics")]
153 #[cfg(target_vendor = "apple")]
154 #[unsafe(method(CGContext))]
155 #[unsafe(method_family = none)]
156 pub fn CGContext(&self) -> Retained<CGContext>;
157
158 #[unsafe(method(isFlipped))]
159 #[unsafe(method_family = none)]
160 pub fn isFlipped(&self) -> bool;
161 );
162}
163
164impl NSGraphicsContext {
166 extern_methods!(
167 #[unsafe(method(init))]
168 #[unsafe(method_family = init)]
169 pub fn init(this: Allocated<Self>) -> Retained<Self>;
170
171 #[unsafe(method(new))]
172 #[unsafe(method_family = new)]
173 pub fn new() -> Retained<Self>;
174 );
175}
176
177impl DefaultRetained for NSGraphicsContext {
178 #[inline]
179 fn default_retained() -> Retained<Self> {
180 Self::new()
181 }
182}
183
184impl NSGraphicsContext {
186 extern_methods!(
187 #[unsafe(method(shouldAntialias))]
188 #[unsafe(method_family = none)]
189 pub fn shouldAntialias(&self) -> bool;
190
191 #[unsafe(method(setShouldAntialias:))]
193 #[unsafe(method_family = none)]
194 pub fn setShouldAntialias(&self, should_antialias: bool);
195
196 #[unsafe(method(imageInterpolation))]
197 #[unsafe(method_family = none)]
198 pub fn imageInterpolation(&self) -> NSImageInterpolation;
199
200 #[unsafe(method(setImageInterpolation:))]
202 #[unsafe(method_family = none)]
203 pub fn setImageInterpolation(&self, image_interpolation: NSImageInterpolation);
204
205 #[unsafe(method(patternPhase))]
206 #[unsafe(method_family = none)]
207 pub fn patternPhase(&self) -> NSPoint;
208
209 #[unsafe(method(setPatternPhase:))]
211 #[unsafe(method_family = none)]
212 pub fn setPatternPhase(&self, pattern_phase: NSPoint);
213
214 #[cfg(feature = "NSGraphics")]
215 #[unsafe(method(compositingOperation))]
216 #[unsafe(method_family = none)]
217 pub fn compositingOperation(&self) -> NSCompositingOperation;
218
219 #[cfg(feature = "NSGraphics")]
220 #[unsafe(method(setCompositingOperation:))]
222 #[unsafe(method_family = none)]
223 pub fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);
224
225 #[cfg(feature = "NSGraphics")]
226 #[unsafe(method(colorRenderingIntent))]
227 #[unsafe(method_family = none)]
228 pub fn colorRenderingIntent(&self) -> NSColorRenderingIntent;
229
230 #[cfg(feature = "NSGraphics")]
231 #[unsafe(method(setColorRenderingIntent:))]
233 #[unsafe(method_family = none)]
234 pub fn setColorRenderingIntent(&self, color_rendering_intent: NSColorRenderingIntent);
235 );
236}
237
238impl NSGraphicsContext {
240 extern_methods!(
241 #[cfg(feature = "objc2-core-image")]
242 #[cfg(target_vendor = "apple")]
243 #[unsafe(method(CIContext))]
244 #[unsafe(method_family = none)]
245 pub fn CIContext(&self) -> Option<Retained<CIContext>>;
246 );
247}
248
249impl NSGraphicsContext {
251 extern_methods!(
252 #[deprecated = "This method has no effect"]
253 #[unsafe(method(setGraphicsState:))]
254 #[unsafe(method_family = none)]
255 pub fn setGraphicsState(g_state: NSInteger);
256
257 #[deprecated]
258 #[unsafe(method(focusStack))]
259 #[unsafe(method_family = none)]
260 pub fn focusStack(&self) -> Option<Retained<AnyObject>>;
261
262 #[deprecated]
267 #[unsafe(method(setFocusStack:))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);
270
271 #[deprecated]
275 #[unsafe(method(graphicsContextWithGraphicsPort:flipped:))]
276 #[unsafe(method_family = none)]
277 pub unsafe fn graphicsContextWithGraphicsPort_flipped(
278 graphics_port: NonNull<c_void>,
279 initial_flipped_state: bool,
280 ) -> Retained<NSGraphicsContext>;
281
282 #[deprecated]
283 #[unsafe(method(graphicsPort))]
284 #[unsafe(method_family = none)]
285 pub fn graphicsPort(&self) -> NonNull<c_void>;
286
287 #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
288 #[deprecated = "Add instances of NSView to display content in a window"]
289 #[unsafe(method(graphicsContextWithWindow:))]
290 #[unsafe(method_family = none)]
291 pub fn graphicsContextWithWindow(window: &NSWindow) -> Retained<NSGraphicsContext>;
292 );
293}