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 unsafe 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 unsafe 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:))]
90 #[unsafe(method_family = init)]
91 pub unsafe fn initWithColors_atLocations_colorSpace(
92 this: Allocated<Self>,
93 color_array: &NSArray<NSColor>,
94 locations: *const CGFloat,
95 color_space: &NSColorSpace,
96 ) -> Option<Retained<Self>>;
97
98 #[unsafe(method(initWithCoder:))]
99 #[unsafe(method_family = init)]
100 pub unsafe fn initWithCoder(
101 this: Allocated<Self>,
102 coder: &NSCoder,
103 ) -> Option<Retained<Self>>;
104
105 #[unsafe(method(drawFromPoint:toPoint:options:))]
106 #[unsafe(method_family = none)]
107 pub unsafe fn drawFromPoint_toPoint_options(
108 &self,
109 starting_point: NSPoint,
110 ending_point: NSPoint,
111 options: NSGradientDrawingOptions,
112 );
113
114 #[cfg(feature = "objc2-core-foundation")]
115 #[unsafe(method(drawInRect:angle:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn drawInRect_angle(&self, rect: NSRect, angle: CGFloat);
118
119 #[cfg(all(feature = "NSBezierPath", feature = "objc2-core-foundation"))]
120 #[unsafe(method(drawInBezierPath:angle:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn drawInBezierPath_angle(&self, path: &NSBezierPath, angle: CGFloat);
123
124 #[cfg(feature = "objc2-core-foundation")]
125 #[unsafe(method(drawFromCenter:radius:toCenter:radius:options:))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn drawFromCenter_radius_toCenter_radius_options(
128 &self,
129 start_center: NSPoint,
130 start_radius: CGFloat,
131 end_center: NSPoint,
132 end_radius: CGFloat,
133 options: NSGradientDrawingOptions,
134 );
135
136 #[unsafe(method(drawInRect:relativeCenterPosition:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn drawInRect_relativeCenterPosition(
139 &self,
140 rect: NSRect,
141 relative_center_position: NSPoint,
142 );
143
144 #[cfg(feature = "NSBezierPath")]
145 #[unsafe(method(drawInBezierPath:relativeCenterPosition:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn drawInBezierPath_relativeCenterPosition(
148 &self,
149 path: &NSBezierPath,
150 relative_center_position: NSPoint,
151 );
152
153 #[cfg(feature = "NSColorSpace")]
154 #[unsafe(method(colorSpace))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn colorSpace(&self) -> Retained<NSColorSpace>;
157
158 #[unsafe(method(numberOfColorStops))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn numberOfColorStops(&self) -> NSInteger;
161
162 #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
163 #[unsafe(method(getColor:location:atIndex:))]
164 #[unsafe(method_family = none)]
165 pub unsafe fn getColor_location_atIndex(
166 &self,
167 color: Option<&mut Retained<NSColor>>,
168 location: *mut CGFloat,
169 index: NSInteger,
170 );
171
172 #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
173 #[unsafe(method(interpolatedColorAtLocation:))]
174 #[unsafe(method_family = none)]
175 pub unsafe fn interpolatedColorAtLocation(&self, location: CGFloat) -> Retained<NSColor>;
176 );
177}
178
179impl NSGradient {
181 extern_methods!(
182 #[unsafe(method(init))]
183 #[unsafe(method_family = init)]
184 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
185
186 #[unsafe(method(new))]
187 #[unsafe(method_family = new)]
188 pub unsafe fn new() -> Retained<Self>;
189 );
190}