objc2_app_kit/generated/
NSGradient.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use 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/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgradientdrawingoptions?language=objc)
13// NS_OPTIONS
14#[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    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsgradient?language=objc)
36    #[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
45unsafe impl NSCoding for NSGradient {}
46
47unsafe impl NSCopying for NSGradient {}
48
49unsafe impl CopyingHelper for NSGradient {
50    type Result = Self;
51}
52
53unsafe impl NSObjectProtocol for NSGradient {}
54
55unsafe impl NSSecureCoding for NSGradient {}
56
57impl NSGradient {
58    extern_methods!(
59        #[cfg(feature = "NSColor")]
60        #[unsafe(method(initWithStartingColor:endingColor:))]
61        #[unsafe(method_family = init)]
62        pub unsafe fn initWithStartingColor_endingColor(
63            this: Allocated<Self>,
64            starting_color: &NSColor,
65            ending_color: &NSColor,
66        ) -> Option<Retained<Self>>;
67
68        #[cfg(feature = "NSColor")]
69        #[unsafe(method(initWithColors:))]
70        #[unsafe(method_family = init)]
71        pub unsafe fn initWithColors(
72            this: Allocated<Self>,
73            color_array: &NSArray<NSColor>,
74        ) -> Option<Retained<Self>>;
75
76        #[cfg(all(
77            feature = "NSColor",
78            feature = "NSColorSpace",
79            feature = "objc2-core-foundation"
80        ))]
81        #[unsafe(method(initWithColors:atLocations:colorSpace:))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn initWithColors_atLocations_colorSpace(
84            this: Allocated<Self>,
85            color_array: &NSArray<NSColor>,
86            locations: *const CGFloat,
87            color_space: &NSColorSpace,
88        ) -> Option<Retained<Self>>;
89
90        #[unsafe(method(initWithCoder:))]
91        #[unsafe(method_family = init)]
92        pub unsafe fn initWithCoder(
93            this: Allocated<Self>,
94            coder: &NSCoder,
95        ) -> Option<Retained<Self>>;
96
97        #[unsafe(method(drawFromPoint:toPoint:options:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn drawFromPoint_toPoint_options(
100            &self,
101            starting_point: NSPoint,
102            ending_point: NSPoint,
103            options: NSGradientDrawingOptions,
104        );
105
106        #[cfg(feature = "objc2-core-foundation")]
107        #[unsafe(method(drawInRect:angle:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn drawInRect_angle(&self, rect: NSRect, angle: CGFloat);
110
111        #[cfg(all(feature = "NSBezierPath", feature = "objc2-core-foundation"))]
112        #[unsafe(method(drawInBezierPath:angle:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn drawInBezierPath_angle(&self, path: &NSBezierPath, angle: CGFloat);
115
116        #[cfg(feature = "objc2-core-foundation")]
117        #[unsafe(method(drawFromCenter:radius:toCenter:radius:options:))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn drawFromCenter_radius_toCenter_radius_options(
120            &self,
121            start_center: NSPoint,
122            start_radius: CGFloat,
123            end_center: NSPoint,
124            end_radius: CGFloat,
125            options: NSGradientDrawingOptions,
126        );
127
128        #[unsafe(method(drawInRect:relativeCenterPosition:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn drawInRect_relativeCenterPosition(
131            &self,
132            rect: NSRect,
133            relative_center_position: NSPoint,
134        );
135
136        #[cfg(feature = "NSBezierPath")]
137        #[unsafe(method(drawInBezierPath:relativeCenterPosition:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn drawInBezierPath_relativeCenterPosition(
140            &self,
141            path: &NSBezierPath,
142            relative_center_position: NSPoint,
143        );
144
145        #[cfg(feature = "NSColorSpace")]
146        #[unsafe(method(colorSpace))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn colorSpace(&self) -> Retained<NSColorSpace>;
149
150        #[unsafe(method(numberOfColorStops))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn numberOfColorStops(&self) -> NSInteger;
153
154        #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
155        #[unsafe(method(getColor:location:atIndex:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn getColor_location_atIndex(
158            &self,
159            color: Option<&mut Retained<NSColor>>,
160            location: *mut CGFloat,
161            index: NSInteger,
162        );
163
164        #[cfg(all(feature = "NSColor", feature = "objc2-core-foundation"))]
165        #[unsafe(method(interpolatedColorAtLocation:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn interpolatedColorAtLocation(&self, location: CGFloat) -> Retained<NSColor>;
168    );
169}
170
171/// Methods declared on superclass `NSObject`.
172impl NSGradient {
173    extern_methods!(
174        #[unsafe(method(init))]
175        #[unsafe(method_family = init)]
176        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
177
178        #[unsafe(method(new))]
179        #[unsafe(method_family = new)]
180        pub unsafe fn new() -> Retained<Self>;
181    );
182}