objc2_app_kit/generated/
NSColorWell.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/nscolorwellstyle?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSColorWellStyle(pub NSInteger);
17impl NSColorWellStyle {
18    #[doc(alias = "NSColorWellStyleDefault")]
19    pub const Default: Self = Self(0);
20    /// The default `colorWellStyle`. A well that accepts drag/drop of colors as well as reveals the color panel when clicked.
21    #[doc(alias = "NSColorWellStyleMinimal")]
22    pub const Minimal: Self = Self(1);
23    /// A minimally adorned well. By default shows a popover color picker when clicked; this interaction behavior can be customized.
24    #[doc(alias = "NSColorWellStyleExpanded")]
25    pub const Expanded: Self = Self(2);
26}
27
28unsafe impl Encode for NSColorWellStyle {
29    const ENCODING: Encoding = NSInteger::ENCODING;
30}
31
32unsafe impl RefEncode for NSColorWellStyle {
33    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
34}
35
36extern_class!(
37    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nscolorwell?language=objc)
38    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
41    pub struct NSColorWell;
42);
43
44#[cfg(all(
45    feature = "NSAccessibilityProtocols",
46    feature = "NSControl",
47    feature = "NSResponder",
48    feature = "NSView"
49))]
50extern_conformance!(
51    unsafe impl NSAccessibility for NSColorWell {}
52);
53
54#[cfg(all(
55    feature = "NSAccessibilityProtocols",
56    feature = "NSControl",
57    feature = "NSResponder",
58    feature = "NSView"
59))]
60extern_conformance!(
61    unsafe impl NSAccessibilityElementProtocol for NSColorWell {}
62);
63
64#[cfg(all(
65    feature = "NSAnimation",
66    feature = "NSControl",
67    feature = "NSResponder",
68    feature = "NSView"
69))]
70extern_conformance!(
71    unsafe impl NSAnimatablePropertyContainer for NSColorWell {}
72);
73
74#[cfg(all(
75    feature = "NSAppearance",
76    feature = "NSControl",
77    feature = "NSResponder",
78    feature = "NSView"
79))]
80extern_conformance!(
81    unsafe impl NSAppearanceCustomization for NSColorWell {}
82);
83
84#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
85extern_conformance!(
86    unsafe impl NSCoding for NSColorWell {}
87);
88
89#[cfg(all(
90    feature = "NSControl",
91    feature = "NSDragging",
92    feature = "NSResponder",
93    feature = "NSView"
94))]
95extern_conformance!(
96    unsafe impl NSDraggingDestination for NSColorWell {}
97);
98
99#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
100extern_conformance!(
101    unsafe impl NSObjectProtocol for NSColorWell {}
102);
103
104#[cfg(all(
105    feature = "NSControl",
106    feature = "NSResponder",
107    feature = "NSUserInterfaceItemIdentification",
108    feature = "NSView"
109))]
110extern_conformance!(
111    unsafe impl NSUserInterfaceItemIdentification for NSColorWell {}
112);
113
114#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
115impl NSColorWell {
116    extern_methods!(
117        #[unsafe(method(colorWellWithStyle:))]
118        #[unsafe(method_family = none)]
119        pub fn colorWellWithStyle(style: NSColorWellStyle, mtm: MainThreadMarker)
120            -> Retained<Self>;
121
122        /// Instantiates a well in the given style with a default configuration.
123        #[unsafe(method(deactivate))]
124        #[unsafe(method_family = none)]
125        pub fn deactivate(&self);
126
127        #[unsafe(method(activate:))]
128        #[unsafe(method_family = none)]
129        pub fn activate(&self, exclusive: bool);
130
131        #[unsafe(method(isActive))]
132        #[unsafe(method_family = none)]
133        pub fn isActive(&self) -> bool;
134
135        #[unsafe(method(drawWellInside:))]
136        #[unsafe(method_family = none)]
137        pub fn drawWellInside(&self, inside_rect: NSRect);
138
139        #[deprecated = "This property will be deprecated in a future release."]
140        #[unsafe(method(isBordered))]
141        #[unsafe(method_family = none)]
142        pub fn isBordered(&self) -> bool;
143
144        /// Setter for [`isBordered`][Self::isBordered].
145        #[deprecated = "This property will be deprecated in a future release."]
146        #[unsafe(method(setBordered:))]
147        #[unsafe(method_family = none)]
148        pub fn setBordered(&self, bordered: bool);
149
150        /// # Safety
151        ///
152        /// `sender` should be of the correct type.
153        #[unsafe(method(takeColorFrom:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn takeColorFrom(&self, sender: Option<&AnyObject>);
156
157        #[cfg(feature = "NSColor")]
158        #[unsafe(method(color))]
159        #[unsafe(method_family = none)]
160        pub fn color(&self) -> Retained<NSColor>;
161
162        #[cfg(feature = "NSColor")]
163        /// Setter for [`color`][Self::color].
164        ///
165        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
166        #[unsafe(method(setColor:))]
167        #[unsafe(method_family = none)]
168        pub fn setColor(&self, color: &NSColor);
169
170        #[unsafe(method(colorWellStyle))]
171        #[unsafe(method_family = none)]
172        pub fn colorWellStyle(&self) -> NSColorWellStyle;
173
174        /// Setter for [`colorWellStyle`][Self::colorWellStyle].
175        #[unsafe(method(setColorWellStyle:))]
176        #[unsafe(method_family = none)]
177        pub fn setColorWellStyle(&self, color_well_style: NSColorWellStyle);
178
179        #[cfg(feature = "NSImage")]
180        #[unsafe(method(image))]
181        #[unsafe(method_family = none)]
182        pub fn image(&self) -> Option<Retained<NSImage>>;
183
184        #[cfg(feature = "NSImage")]
185        /// Setter for [`image`][Self::image].
186        #[unsafe(method(setImage:))]
187        #[unsafe(method_family = none)]
188        pub fn setImage(&self, image: Option<&NSImage>);
189
190        /// The image that appears on the button portion of the expanded control. This property only applicable when `colorWellStyle` is `NSColorWellStyleExpanded`.
191        #[unsafe(method(pulldownTarget))]
192        #[unsafe(method_family = none)]
193        pub fn pulldownTarget(&self) -> Option<Retained<AnyObject>>;
194
195        /// Setter for [`pulldownTarget`][Self::pulldownTarget].
196        ///
197        /// This is a [weak property][objc2::topics::weak_property].
198        ///
199        /// # Safety
200        ///
201        /// `pulldown_target` should be of the correct type.
202        #[unsafe(method(setPulldownTarget:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setPulldownTarget(&self, pulldown_target: Option<&AnyObject>);
205
206        /// The target which `pulldownAction` is sent to. This property only applicable when `colorWellStyle` is `NSColorWellStyleExpanded` or `NSColorWellStyleMinimal`.
207        #[unsafe(method(pulldownAction))]
208        #[unsafe(method_family = none)]
209        pub fn pulldownAction(&self) -> Option<Sel>;
210
211        /// Setter for [`pulldownAction`][Self::pulldownAction].
212        ///
213        /// # Safety
214        ///
215        /// `pulldown_action` must be a valid selector.
216        #[unsafe(method(setPulldownAction:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setPulldownAction(&self, pulldown_action: Option<Sel>);
219
220        /// Controls alpha support for the current color well, and the visibility of alpha slider in the color panel.
221        /// When `NSColor.ignoresAlpha` (deprecated) is set to `YES`, this property will always return `NO` and alpha is not supported globally.
222        #[unsafe(method(supportsAlpha))]
223        #[unsafe(method_family = none)]
224        pub fn supportsAlpha(&self) -> bool;
225
226        /// Setter for [`supportsAlpha`][Self::supportsAlpha].
227        #[unsafe(method(setSupportsAlpha:))]
228        #[unsafe(method_family = none)]
229        pub fn setSupportsAlpha(&self, supports_alpha: bool);
230
231        #[cfg(feature = "objc2-core-foundation")]
232        /// The maximum linear exposure a color in this color well can be set to. Defaults to 1 and ignores any value less than 1. If set to a value >= 2, the color picked for this well may have a linear exposure applied to it.
233        #[unsafe(method(maximumLinearExposure))]
234        #[unsafe(method_family = none)]
235        pub fn maximumLinearExposure(&self) -> CGFloat;
236
237        #[cfg(feature = "objc2-core-foundation")]
238        /// Setter for [`maximumLinearExposure`][Self::maximumLinearExposure].
239        #[unsafe(method(setMaximumLinearExposure:))]
240        #[unsafe(method_family = none)]
241        pub fn setMaximumLinearExposure(&self, maximum_linear_exposure: CGFloat);
242    );
243}
244
245/// Methods declared on superclass `NSControl`.
246#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
247impl NSColorWell {
248    extern_methods!(
249        #[unsafe(method(initWithFrame:))]
250        #[unsafe(method_family = init)]
251        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
252
253        /// # Safety
254        ///
255        /// `coder` possibly has further requirements.
256        #[unsafe(method(initWithCoder:))]
257        #[unsafe(method_family = init)]
258        pub unsafe fn initWithCoder(
259            this: Allocated<Self>,
260            coder: &NSCoder,
261        ) -> Option<Retained<Self>>;
262    );
263}
264
265/// Methods declared on superclass `NSResponder`.
266#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
267impl NSColorWell {
268    extern_methods!(
269        #[unsafe(method(init))]
270        #[unsafe(method_family = init)]
271        pub fn init(this: Allocated<Self>) -> Retained<Self>;
272    );
273}
274
275/// Methods declared on superclass `NSObject`.
276#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
277impl NSColorWell {
278    extern_methods!(
279        #[unsafe(method(new))]
280        #[unsafe(method_family = new)]
281        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
282    );
283}