objc2_ui_kit/generated/
UISwitch.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#[cfg(feature = "objc2-quartz-core")]
10#[cfg(not(target_os = "watchos"))]
11use objc2_quartz_core::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswitchstyle?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UISwitchStyle(pub NSInteger);
20impl UISwitchStyle {
21    #[doc(alias = "UISwitchStyleAutomatic")]
22    pub const Automatic: Self = Self(0);
23    #[doc(alias = "UISwitchStyleCheckbox")]
24    pub const Checkbox: Self = Self(1);
25    #[doc(alias = "UISwitchStyleSliding")]
26    pub const Sliding: Self = Self(2);
27}
28
29unsafe impl Encode for UISwitchStyle {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for UISwitchStyle {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiswitch?language=objc)
39    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
40    #[thread_kind = MainThreadOnly]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
43    pub struct UISwitch;
44);
45
46#[cfg(all(
47    feature = "UIControl",
48    feature = "UIResponder",
49    feature = "UIView",
50    feature = "objc2-quartz-core"
51))]
52#[cfg(not(target_os = "watchos"))]
53unsafe impl CALayerDelegate for UISwitch {}
54
55#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
56unsafe impl NSCoding for UISwitch {}
57
58#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
59unsafe impl NSObjectProtocol for UISwitch {}
60
61#[cfg(all(
62    feature = "UIAppearance",
63    feature = "UIControl",
64    feature = "UIResponder",
65    feature = "UIView"
66))]
67unsafe impl UIAppearance for UISwitch {}
68
69#[cfg(all(
70    feature = "UIAppearance",
71    feature = "UIControl",
72    feature = "UIResponder",
73    feature = "UIView"
74))]
75unsafe impl UIAppearanceContainer for UISwitch {}
76
77#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
78unsafe impl UICoordinateSpace for UISwitch {}
79
80#[cfg(all(
81    feature = "UIControl",
82    feature = "UIDynamicBehavior",
83    feature = "UIResponder",
84    feature = "UIView"
85))]
86unsafe impl UIDynamicItem for UISwitch {}
87
88#[cfg(all(
89    feature = "UIControl",
90    feature = "UIFocus",
91    feature = "UIResponder",
92    feature = "UIView"
93))]
94unsafe impl UIFocusEnvironment for UISwitch {}
95
96#[cfg(all(
97    feature = "UIControl",
98    feature = "UIFocus",
99    feature = "UIResponder",
100    feature = "UIView"
101))]
102unsafe impl UIFocusItem for UISwitch {}
103
104#[cfg(all(
105    feature = "UIControl",
106    feature = "UIFocus",
107    feature = "UIResponder",
108    feature = "UIView"
109))]
110unsafe impl UIFocusItemContainer for UISwitch {}
111
112#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
113unsafe impl UIResponderStandardEditActions for UISwitch {}
114
115#[cfg(all(
116    feature = "UIControl",
117    feature = "UIResponder",
118    feature = "UITraitCollection",
119    feature = "UIView"
120))]
121unsafe impl UITraitEnvironment for UISwitch {}
122
123#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
124impl UISwitch {
125    extern_methods!(
126        #[cfg(feature = "UIColor")]
127        #[unsafe(method(onTintColor))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn onTintColor(&self) -> Option<Retained<UIColor>>;
130
131        #[cfg(feature = "UIColor")]
132        /// Setter for [`onTintColor`][Self::onTintColor].
133        #[unsafe(method(setOnTintColor:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setOnTintColor(&self, on_tint_color: Option<&UIColor>);
136
137        #[cfg(feature = "UIColor")]
138        #[unsafe(method(thumbTintColor))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn thumbTintColor(&self) -> Option<Retained<UIColor>>;
141
142        #[cfg(feature = "UIColor")]
143        /// Setter for [`thumbTintColor`][Self::thumbTintColor].
144        #[unsafe(method(setThumbTintColor:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn setThumbTintColor(&self, thumb_tint_color: Option<&UIColor>);
147
148        #[cfg(feature = "UIImage")]
149        #[unsafe(method(onImage))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn onImage(&self) -> Option<Retained<UIImage>>;
152
153        #[cfg(feature = "UIImage")]
154        /// Setter for [`onImage`][Self::onImage].
155        #[unsafe(method(setOnImage:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setOnImage(&self, on_image: Option<&UIImage>);
158
159        #[cfg(feature = "UIImage")]
160        #[unsafe(method(offImage))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn offImage(&self) -> Option<Retained<UIImage>>;
163
164        #[cfg(feature = "UIImage")]
165        /// Setter for [`offImage`][Self::offImage].
166        #[unsafe(method(setOffImage:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setOffImage(&self, off_image: Option<&UIImage>);
169
170        /// The title displayed alongside the switch, positioned appropriately for the
171        /// `UIUserInterfaceIdiom.`
172        /// Note: This property is only supported for Catalyst in the Mac idiom.
173        #[unsafe(method(title))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
176
177        /// Setter for [`title`][Self::title].
178        #[unsafe(method(setTitle:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setTitle(&self, title: Option<&NSString>);
181
182        /// The switch's display style. This property always returns a concrete, resolved style (never UISwitchStyleAutomatic).
183        #[unsafe(method(style))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn style(&self) -> UISwitchStyle;
186
187        /// Request a style for the switch. If the style changed, then the switch may resize.
188        #[unsafe(method(preferredStyle))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn preferredStyle(&self) -> UISwitchStyle;
191
192        /// Setter for [`preferredStyle`][Self::preferredStyle].
193        #[unsafe(method(setPreferredStyle:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn setPreferredStyle(&self, preferred_style: UISwitchStyle);
196
197        #[unsafe(method(isOn))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn isOn(&self) -> bool;
200
201        /// Setter for [`isOn`][Self::isOn].
202        #[unsafe(method(setOn:))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn setOn(&self, on: bool);
205
206        #[cfg(feature = "objc2-core-foundation")]
207        #[unsafe(method(initWithFrame:))]
208        #[unsafe(method_family = init)]
209        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
210
211        #[unsafe(method(initWithCoder:))]
212        #[unsafe(method_family = init)]
213        pub unsafe fn initWithCoder(
214            this: Allocated<Self>,
215            coder: &NSCoder,
216        ) -> Option<Retained<Self>>;
217
218        #[unsafe(method(setOn:animated:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn setOn_animated(&self, on: bool, animated: bool);
221    );
222}
223
224/// Methods declared on superclass `UIControl`.
225#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
226impl UISwitch {
227    extern_methods!(
228        #[cfg(all(
229            feature = "UIAction",
230            feature = "UIMenuElement",
231            feature = "objc2-core-foundation"
232        ))]
233        /// Initializes the control and adds primaryAction for the UIControlEventPrimaryActionTriggered control event. Subclasses of UIControl may alter or add behaviors around the usage of primaryAction, see subclass documentation of this initializer for additional information.
234        #[unsafe(method(initWithFrame:primaryAction:))]
235        #[unsafe(method_family = init)]
236        pub unsafe fn initWithFrame_primaryAction(
237            this: Allocated<Self>,
238            frame: CGRect,
239            primary_action: Option<&UIAction>,
240        ) -> Retained<Self>;
241    );
242}
243
244/// Methods declared on superclass `NSObject`.
245#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
246impl UISwitch {
247    extern_methods!(
248        #[unsafe(method(init))]
249        #[unsafe(method_family = init)]
250        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
251
252        #[unsafe(method(new))]
253        #[unsafe(method_family = new)]
254        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
255    );
256}