1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

// NS_TYPED_ENUM
pub type NSGraphicsContextAttributeKey = NSString;

extern "C" {
    pub static NSGraphicsContextDestinationAttributeName: &'static NSGraphicsContextAttributeKey;
}

extern "C" {
    pub static NSGraphicsContextRepresentationFormatAttributeName:
        &'static NSGraphicsContextAttributeKey;
}

// NS_TYPED_ENUM
pub type NSGraphicsContextRepresentationFormatName = NSString;

extern "C" {
    pub static NSGraphicsContextPSFormat: &'static NSGraphicsContextRepresentationFormatName;
}

extern "C" {
    pub static NSGraphicsContextPDFFormat: &'static NSGraphicsContextRepresentationFormatName;
}

// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSImageInterpolation(pub NSUInteger);
impl NSImageInterpolation {
    #[doc(alias = "NSImageInterpolationDefault")]
    pub const Default: Self = Self(0);
    #[doc(alias = "NSImageInterpolationNone")]
    pub const None: Self = Self(1);
    #[doc(alias = "NSImageInterpolationLow")]
    pub const Low: Self = Self(2);
    #[doc(alias = "NSImageInterpolationMedium")]
    pub const Medium: Self = Self(4);
    #[doc(alias = "NSImageInterpolationHigh")]
    pub const High: Self = Self(3);
}

unsafe impl Encode for NSImageInterpolation {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSImageInterpolation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSGraphicsContext;

    unsafe impl ClassType for NSGraphicsContext {
        type Super = NSObject;
        type Mutability = InteriorMutable;
    }
);

unsafe impl NSObjectProtocol for NSGraphicsContext {}

extern_methods!(
    unsafe impl NSGraphicsContext {
        #[method_id(@__retain_semantics Other graphicsContextWithAttributes:)]
        pub unsafe fn graphicsContextWithAttributes(
            attributes: &NSDictionary<NSGraphicsContextAttributeKey, AnyObject>,
        ) -> Option<Id<NSGraphicsContext>>;

        #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
        #[method_id(@__retain_semantics Other graphicsContextWithWindow:)]
        pub unsafe fn graphicsContextWithWindow(window: &NSWindow) -> Id<NSGraphicsContext>;

        #[cfg(all(feature = "NSBitmapImageRep", feature = "NSImageRep"))]
        #[method_id(@__retain_semantics Other graphicsContextWithBitmapImageRep:)]
        pub unsafe fn graphicsContextWithBitmapImageRep(
            bitmap_rep: &NSBitmapImageRep,
        ) -> Option<Id<NSGraphicsContext>>;

        #[method_id(@__retain_semantics Other currentContext)]
        pub unsafe fn currentContext() -> Option<Id<NSGraphicsContext>>;

        #[method(setCurrentContext:)]
        pub unsafe fn setCurrentContext(current_context: Option<&NSGraphicsContext>);

        #[method(currentContextDrawingToScreen)]
        pub unsafe fn currentContextDrawingToScreen() -> bool;

        #[method(saveGraphicsState)]
        pub unsafe fn saveGraphicsState_class();

        #[method(restoreGraphicsState)]
        pub unsafe fn restoreGraphicsState_class();

        #[method_id(@__retain_semantics Other attributes)]
        pub unsafe fn attributes(
            &self,
        ) -> Option<Id<NSDictionary<NSGraphicsContextAttributeKey, AnyObject>>>;

        #[method(isDrawingToScreen)]
        pub unsafe fn isDrawingToScreen(&self) -> bool;

        #[method(saveGraphicsState)]
        pub unsafe fn saveGraphicsState(&self);

        #[method(restoreGraphicsState)]
        pub unsafe fn restoreGraphicsState(&self);

        #[method(flushGraphics)]
        pub unsafe fn flushGraphics(&self);

        #[method(isFlipped)]
        pub unsafe fn isFlipped(&self) -> bool;
    }
);

extern_methods!(
    /// Methods declared on superclass `NSObject`
    unsafe impl NSGraphicsContext {
        #[method_id(@__retain_semantics Init init)]
        pub unsafe fn init(this: Allocated<Self>) -> Id<Self>;

        #[method_id(@__retain_semantics New new)]
        pub unsafe fn new() -> Id<Self>;
    }
);

extern_methods!(
    /// NSGraphicsContext_RenderingOptions
    unsafe impl NSGraphicsContext {
        #[method(shouldAntialias)]
        pub unsafe fn shouldAntialias(&self) -> bool;

        #[method(setShouldAntialias:)]
        pub unsafe fn setShouldAntialias(&self, should_antialias: bool);

        #[method(imageInterpolation)]
        pub unsafe fn imageInterpolation(&self) -> NSImageInterpolation;

        #[method(setImageInterpolation:)]
        pub unsafe fn setImageInterpolation(&self, image_interpolation: NSImageInterpolation);

        #[method(patternPhase)]
        pub unsafe fn patternPhase(&self) -> NSPoint;

        #[method(setPatternPhase:)]
        pub unsafe fn setPatternPhase(&self, pattern_phase: NSPoint);

        #[cfg(feature = "NSGraphics")]
        #[method(compositingOperation)]
        pub unsafe fn compositingOperation(&self) -> NSCompositingOperation;

        #[cfg(feature = "NSGraphics")]
        #[method(setCompositingOperation:)]
        pub unsafe fn setCompositingOperation(&self, compositing_operation: NSCompositingOperation);

        #[cfg(feature = "NSGraphics")]
        #[method(colorRenderingIntent)]
        pub unsafe fn colorRenderingIntent(&self) -> NSColorRenderingIntent;

        #[cfg(feature = "NSGraphics")]
        #[method(setColorRenderingIntent:)]
        pub unsafe fn setColorRenderingIntent(
            &self,
            color_rendering_intent: NSColorRenderingIntent,
        );
    }
);

extern_methods!(
    /// NSQuartzCoreAdditions
    unsafe impl NSGraphicsContext {}
);

extern_methods!(
    /// NSGraphicsContextDeprecated
    unsafe impl NSGraphicsContext {
        #[deprecated = "This method has no effect"]
        #[method(setGraphicsState:)]
        pub unsafe fn setGraphicsState(g_state: NSInteger);

        #[deprecated]
        #[method_id(@__retain_semantics Other focusStack)]
        pub unsafe fn focusStack(&self) -> Option<Id<AnyObject>>;

        #[deprecated]
        #[method(setFocusStack:)]
        pub unsafe fn setFocusStack(&self, stack: Option<&AnyObject>);

        #[deprecated]
        #[method_id(@__retain_semantics Other graphicsContextWithGraphicsPort:flipped:)]
        pub unsafe fn graphicsContextWithGraphicsPort_flipped(
            graphics_port: NonNull<c_void>,
            initial_flipped_state: bool,
        ) -> Id<NSGraphicsContext>;

        #[deprecated]
        #[method(graphicsPort)]
        pub unsafe fn graphicsPort(&self) -> NonNull<c_void>;
    }
);