objc2_app_kit/generated/
NSGradient.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSGradientDrawingOptions(pub NSUInteger);
17bitflags::bitflags! {
18 impl NSGradientDrawingOptions: NSUInteger {
19 #[doc(alias = "NSGradientDrawsBeforeStartingLocation")]
20 const DrawsBeforeStartingLocation = 1<<0;
21 #[doc(alias = "NSGradientDrawsAfterEndingLocation")]
22 const DrawsAfterEndingLocation = 1<<1;
23 }
24}
25
26unsafe impl Encode for NSGradientDrawingOptions {
27 const ENCODING: Encoding = NSUInteger::ENCODING;
28}
29
30unsafe impl RefEncode for NSGradientDrawingOptions {
31 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34extern_class!(
35 #[unsafe(super(NSObject))]
37 #[derive(Debug, PartialEq, Eq, Hash)]
38 pub struct NSGradient;
39);
40
41unsafe impl Send for NSGradient {}
42
43unsafe impl Sync for NSGradient {}
44
45extern_conformance!(
46 unsafe impl NSCoding for NSGradient {}
47);
48
49extern_conformance!(
50 unsafe impl NSCopying for NSGradient {}
51);
52
53unsafe impl CopyingHelper for NSGradient {
54 type Result = Self;
55}
56
57extern_conformance!(
58 unsafe impl NSObjectProtocol for NSGradient {}
59);
60
61extern_conformance!(
62 unsafe impl NSSecureCoding for NSGradient {}
63);
64
65impl NSGradient {
66 extern_methods!(
67 #[cfg(feature = "NSColor")]
68 #[unsafe(method(initWithStartingColor:endingColor:))]
69 #[unsafe(method_family = init)]
70 pub fn initWithStartingColor_endingColor(
71 this: Allocated<Self>,
72 starting_color: &NSColor,
73 ending_color: &NSColor,
74 ) -> Option<Retained<Self>>;
75
76 #[cfg(feature = "NSColor")]
77 #[unsafe(method(initWithColors:))]
78 #[unsafe(method_family = init)]
79 pub fn initWithColors(
80 this: Allocated<Self>,
81 color_array: &NSArray<NSColor>,
82 ) -> Option<Retained<Self>>;
83
84 #[cfg(all(
85 feature = "NSColor",
86 feature = "NSColorSpace",
87 feature = "objc2-core-foundation"
88 ))]
89 #[unsafe(method(initWithColors:atLocations:colorSpace:))]
93 #[unsafe(method_family = init)]
94 pub unsafe fn initWithColors_atLocations_colorSpace(
95 this: Allocated<Self>,
96 color_array: &NSArray<NSColor>,
97 locations: *const CGFloat,
98 color_space: &NSColorSpace,
99 ) -> Option<Retained<Self>>;
100
101 #[unsafe(method(initWithCoder:))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn initWithCoder(
107 this: Allocated<Self>,
108 coder: &NSCoder,
109 ) -> Option<Retained<Self>>;
110
111 #[unsafe(method(drawFromPoint:toPoint:options:))]
112 #[unsafe(method_family = none)]
113 pub fn drawFromPoint_toPoint_options(
114 &self,
115 starting_point: NSPoint,
116 ending_point: NSPoint,
117 options: NSGradientDrawingOptions,
118 );
119
120 #[cfg(feature = "objc2-core-foundation")]
121 #[unsafe(method(drawInRect:angle:))]
122 #[unsafe(method_family = none)]
123 pub fn drawInRect_angle(&self, rect: NSRect, angle: CGFloat);
124
125 #[cfg(all(feature = "NSBezierPath", feature = "objc2-core-foundation"))]
126 #[unsafe(method(drawInBezierPath:angle:))]
127 #[unsafe(method_family = none)]
128 pub fn drawInBezierPath_angle(&self, path: &NSBezierPath, angle: CGFloat);
129
130 #[cfg(feature = "objc2-core-foundation")]
131 #[unsafe(method(drawFromCenter:radius:toCenter:radius:options:))]
132 #[unsafe(method_family = none)]
133 pub fn drawFromCenter_radius_toCenter_radius_options(
134 &self,
135 start_center: NSPoint,
136 start_radius: CGFloat,
137 end_center: NSPoint,
138 end_radius: CGFloat,
139 options: NSGradientDrawingOptions,
140 );
141
142 #[unsafe(method(drawInRect:relativeCenterPosition:))]
143 #[unsafe(method_family = none)]
144 pub fn drawInRect_relativeCenterPosition(
145 &self,
146 rect: NSRect,
147 relative_center_position: NSPoint,
148 );
149
150 #[cfg(feature = "NSBezierPath")]
151 #[unsafe(method(drawInBezierPath:relativeCenterPosition:))]
152 #[unsafe(method_family = none)]
153 pub fn drawInBezierPath_relativeCenterPosition(
154 &self,
155 path: &NSBezierPath,
156 relative_center_position: NSPoint,
157 );
158
159 #[cfg(feature = "NSColorSpace")]
160 #[unsafe(method(colorSpace))]
161 #[unsafe(method_family = none)]
162 pub fn colorSpace(&self) -> Retained<NSColorSpace>;
163
164 #[unsafe(method(numberOfColorStops))]
165 #[unsafe(method_family = none)]
166 pub fn numberOfColorStops(&self) -> NSInteger;
167
168 #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
169 #[unsafe(method(getColor:location:atIndex:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn getColor_location_atIndex(
175 &self,
176 color: Option<&mut Retained<NSColor>>,
177 location: *mut CGFloat,
178 index: NSInteger,
179 );
180
181 #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
182 #[unsafe(method(interpolatedColorAtLocation:))]
183 #[unsafe(method_family = none)]
184 pub fn interpolatedColorAtLocation(&self, location: CGFloat) -> Retained<NSColor>;
185 );
186}
187
188impl NSGradient {
190 extern_methods!(
191 #[unsafe(method(init))]
192 #[unsafe(method_family = init)]
193 pub fn init(this: Allocated<Self>) -> Retained<Self>;
194
195 #[unsafe(method(new))]
196 #[unsafe(method_family = new)]
197 pub fn new() -> Retained<Self>;
198 );
199}
200
201impl DefaultRetained for NSGradient {
202 #[inline]
203 fn default_retained() -> Retained<Self> {
204 Self::new()
205 }
206}