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
78unsafe impl NSObjectProtocol for NSGraphicsContext {}
79
80impl NSGraphicsContext {
81 extern_methods!(
82 #[unsafe(method(graphicsContextWithAttributes:))]
83 #[unsafe(method_family = none)]
84 pub unsafe fn graphicsContextWithAttributes(
85 attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
86 ) -> Option<Retained<NSGraphicsContext>>;
87
88 #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
89 #[unsafe(method(graphicsContextWithBitmapImageRep:))]
90 #[unsafe(method_family = none)]
91 pub unsafe fn graphicsContextWithBitmapImageRep(
92 bitmap_rep: &NSBitmapImageRep,
93 ) -> Option<Retained<NSGraphicsContext>>;
94
95 #[cfg(feature = "objc2-core-graphics")]
96 #[cfg(target_vendor = "apple")]
97 #[unsafe(method(graphicsContextWithCGContext:flipped:))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn graphicsContextWithCGContext_flipped(
100 graphics_port: &CGContext,
101 initial_flipped_state: bool,
102 ) -> Retained<NSGraphicsContext>;
103
104 #[unsafe(method(currentContext))]
105 #[unsafe(method_family = none)]
106 pub unsafe fn currentContext() -> Option<Retained<NSGraphicsContext>>;
107
108 #[unsafe(method(setCurrentContext:))]
110 #[unsafe(method_family = none)]
111 pub unsafe fn setCurrentContext(current_context: Option<&NSGraphicsContext>);
112
113 #[unsafe(method(currentContextDrawingToScreen))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn currentContextDrawingToScreen() -> bool;
116
117 #[unsafe(method(saveGraphicsState))]
118 #[unsafe(method_family = none)]
119 pub unsafe fn saveGraphicsState_class();
120
121 #[unsafe(method(restoreGraphicsState))]
122 #[unsafe(method_family = none)]
123 pub unsafe fn restoreGraphicsState_class();
124
125 #[unsafe(method(attributes))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn attributes(
128 &self,
129 ) -> Option<Retained<NSDictionary<NSGraphicsContextAttributeKey, AnyObject>>>;
130
131 #[unsafe(method(isDrawingToScreen))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn isDrawingToScreen(&self) -> bool;
134
135 #[unsafe(method(saveGraphicsState))]
136 #[unsafe(method_family = none)]
137 pub unsafe fn saveGraphicsState(&self);
138
139 #[unsafe(method(restoreGraphicsState))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn restoreGraphicsState(&self);
142
143 #[unsafe(method(flushGraphics))]
144 #[unsafe(method_family = none)]
145 pub unsafe fn flushGraphics(&self);
146
147 #[cfg(feature = "objc2-core-graphics")]
148 #[cfg(target_vendor = "apple")]
149 #[unsafe(method(CGContext))]
150 #[unsafe(method_family = none)]
151 pub unsafe fn CGContext(&self) -> Retained<CGContext>;
152
153 #[unsafe(method(isFlipped))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn isFlipped(&self) -> bool;
156 );
157}
158
159impl NSGraphicsContext {
161 extern_methods!(
162 #[unsafe(method(init))]
163 #[unsafe(method_family = init)]
164 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
165
166 #[unsafe(method(new))]
167 #[unsafe(method_family = new)]
168 pub unsafe fn new() -> Retained<Self>;
169 );
170}
171
172impl NSGraphicsContext {
174 extern_methods!(
175 #[unsafe(method(shouldAntialias))]
176 #[unsafe(method_family = none)]
177 pub unsafe fn shouldAntialias(&self) -> bool;
178
179 #[unsafe(method(setShouldAntialias:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn setShouldAntialias(&self, should_antialias: bool);
183
184 #[unsafe(method(imageInterpolation))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn imageInterpolation(&self) -> NSImageInterpolation;
187
188 #[unsafe(method(setImageInterpolation:))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn setImageInterpolation(&self, image_interpolation: NSImageInterpolation);
192
193 #[unsafe(method(patternPhase))]
194 #[unsafe(method_family = none)]
195 pub unsafe fn patternPhase(&self) -> NSPoint;
196
197 #[unsafe(method(setPatternPhase:))]
199 #[unsafe(method_family = none)]
200 pub unsafe fn setPatternPhase(&self, pattern_phase: NSPoint);
201
202 #[cfg(feature = "NSGraphics")]
203 #[unsafe(method(compositingOperation))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn compositingOperation(&self) -> NSCompositingOperation;
206
207 #[cfg(feature = "NSGraphics")]
208 #[unsafe(method(setCompositingOperation:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);
212
213 #[cfg(feature = "NSGraphics")]
214 #[unsafe(method(colorRenderingIntent))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn colorRenderingIntent(&self) -> NSColorRenderingIntent;
217
218 #[cfg(feature = "NSGraphics")]
219 #[unsafe(method(setColorRenderingIntent:))]
221 #[unsafe(method_family = none)]
222 pub unsafe fn setColorRenderingIntent(
223 &self,
224 color_rendering_intent: NSColorRenderingIntent,
225 );
226 );
227}
228
229impl NSGraphicsContext {
231 extern_methods!(
232 #[cfg(feature = "objc2-core-image")]
233 #[cfg(target_vendor = "apple")]
234 #[unsafe(method(CIContext))]
235 #[unsafe(method_family = none)]
236 pub unsafe fn CIContext(&self) -> Option<Retained<CIContext>>;
237 );
238}
239
240impl NSGraphicsContext {
242 extern_methods!(
243 #[deprecated = "This method has no effect"]
244 #[unsafe(method(setGraphicsState:))]
245 #[unsafe(method_family = none)]
246 pub unsafe fn setGraphicsState(g_state: NSInteger);
247
248 #[deprecated]
249 #[unsafe(method(focusStack))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn focusStack(&self) -> Option<Retained<AnyObject>>;
252
253 #[deprecated]
254 #[unsafe(method(setFocusStack:))]
255 #[unsafe(method_family = none)]
256 pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);
257
258 #[deprecated]
259 #[unsafe(method(graphicsContextWithGraphicsPort:flipped:))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn graphicsContextWithGraphicsPort_flipped(
262 graphics_port: NonNull<c_void>,
263 initial_flipped_state: bool,
264 ) -> Retained<NSGraphicsContext>;
265
266 #[deprecated]
267 #[unsafe(method(graphicsPort))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn graphicsPort(&self) -> NonNull<c_void>;
270
271 #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
272 #[deprecated = "Add instances of NSView to display content in a window"]
273 #[unsafe(method(graphicsContextWithWindow:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn graphicsContextWithWindow(window: &NSWindow) -> Retained<NSGraphicsContext>;
276 );
277}