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"))]
53extern_conformance!(
54    unsafe impl CALayerDelegate for UISwitch {}
55);
56
57#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
58extern_conformance!(
59    unsafe impl NSCoding for UISwitch {}
60);
61
62#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
63extern_conformance!(
64    unsafe impl NSObjectProtocol for UISwitch {}
65);
66
67#[cfg(all(
68    feature = "UIAppearance",
69    feature = "UIControl",
70    feature = "UIResponder",
71    feature = "UIView"
72))]
73extern_conformance!(
74    unsafe impl UIAppearance for UISwitch {}
75);
76
77#[cfg(all(
78    feature = "UIAppearance",
79    feature = "UIControl",
80    feature = "UIResponder",
81    feature = "UIView"
82))]
83extern_conformance!(
84    unsafe impl UIAppearanceContainer for UISwitch {}
85);
86
87#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
88extern_conformance!(
89    unsafe impl UICoordinateSpace for UISwitch {}
90);
91
92#[cfg(all(
93    feature = "UIControl",
94    feature = "UIDynamicBehavior",
95    feature = "UIResponder",
96    feature = "UIView"
97))]
98extern_conformance!(
99    unsafe impl UIDynamicItem for UISwitch {}
100);
101
102#[cfg(all(
103    feature = "UIControl",
104    feature = "UIFocus",
105    feature = "UIResponder",
106    feature = "UIView"
107))]
108extern_conformance!(
109    unsafe impl UIFocusEnvironment for UISwitch {}
110);
111
112#[cfg(all(
113    feature = "UIControl",
114    feature = "UIFocus",
115    feature = "UIResponder",
116    feature = "UIView"
117))]
118extern_conformance!(
119    unsafe impl UIFocusItem for UISwitch {}
120);
121
122#[cfg(all(
123    feature = "UIControl",
124    feature = "UIFocus",
125    feature = "UIResponder",
126    feature = "UIView"
127))]
128extern_conformance!(
129    unsafe impl UIFocusItemContainer for UISwitch {}
130);
131
132#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
133extern_conformance!(
134    unsafe impl UIResponderStandardEditActions for UISwitch {}
135);
136
137#[cfg(all(
138    feature = "UIControl",
139    feature = "UIResponder",
140    feature = "UITraitCollection",
141    feature = "UIView"
142))]
143extern_conformance!(
144    unsafe impl UITraitEnvironment for UISwitch {}
145);
146
147#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
148impl UISwitch {
149    extern_methods!(
150        #[cfg(feature = "UIColor")]
151        #[unsafe(method(onTintColor))]
152        #[unsafe(method_family = none)]
153        pub fn onTintColor(&self) -> Option<Retained<UIColor>>;
154
155        #[cfg(feature = "UIColor")]
156        /// Setter for [`onTintColor`][Self::onTintColor].
157        #[unsafe(method(setOnTintColor:))]
158        #[unsafe(method_family = none)]
159        pub fn setOnTintColor(&self, on_tint_color: Option<&UIColor>);
160
161        #[cfg(feature = "UIColor")]
162        #[unsafe(method(thumbTintColor))]
163        #[unsafe(method_family = none)]
164        pub fn thumbTintColor(&self) -> Option<Retained<UIColor>>;
165
166        #[cfg(feature = "UIColor")]
167        /// Setter for [`thumbTintColor`][Self::thumbTintColor].
168        #[unsafe(method(setThumbTintColor:))]
169        #[unsafe(method_family = none)]
170        pub fn setThumbTintColor(&self, thumb_tint_color: Option<&UIColor>);
171
172        #[cfg(feature = "UIImage")]
173        #[unsafe(method(onImage))]
174        #[unsafe(method_family = none)]
175        pub fn onImage(&self) -> Option<Retained<UIImage>>;
176
177        #[cfg(feature = "UIImage")]
178        /// Setter for [`onImage`][Self::onImage].
179        #[unsafe(method(setOnImage:))]
180        #[unsafe(method_family = none)]
181        pub fn setOnImage(&self, on_image: Option<&UIImage>);
182
183        #[cfg(feature = "UIImage")]
184        #[unsafe(method(offImage))]
185        #[unsafe(method_family = none)]
186        pub fn offImage(&self) -> Option<Retained<UIImage>>;
187
188        #[cfg(feature = "UIImage")]
189        /// Setter for [`offImage`][Self::offImage].
190        #[unsafe(method(setOffImage:))]
191        #[unsafe(method_family = none)]
192        pub fn setOffImage(&self, off_image: Option<&UIImage>);
193
194        /// The title displayed alongside the switch, positioned appropriately for the
195        /// `UIUserInterfaceIdiom.`
196        /// Note: This property is only supported for Catalyst in the Mac idiom.
197        #[unsafe(method(title))]
198        #[unsafe(method_family = none)]
199        pub fn title(&self) -> Option<Retained<NSString>>;
200
201        /// Setter for [`title`][Self::title].
202        ///
203        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
204        #[unsafe(method(setTitle:))]
205        #[unsafe(method_family = none)]
206        pub fn setTitle(&self, title: Option<&NSString>);
207
208        /// The switch's display style. This property always returns a concrete, resolved style (never UISwitchStyleAutomatic).
209        #[unsafe(method(style))]
210        #[unsafe(method_family = none)]
211        pub fn style(&self) -> UISwitchStyle;
212
213        /// Request a style for the switch. If the style changed, then the switch may resize.
214        #[unsafe(method(preferredStyle))]
215        #[unsafe(method_family = none)]
216        pub fn preferredStyle(&self) -> UISwitchStyle;
217
218        /// Setter for [`preferredStyle`][Self::preferredStyle].
219        #[unsafe(method(setPreferredStyle:))]
220        #[unsafe(method_family = none)]
221        pub fn setPreferredStyle(&self, preferred_style: UISwitchStyle);
222
223        #[unsafe(method(isOn))]
224        #[unsafe(method_family = none)]
225        pub fn isOn(&self) -> bool;
226
227        /// Setter for [`isOn`][Self::isOn].
228        #[unsafe(method(setOn:))]
229        #[unsafe(method_family = none)]
230        pub fn setOn(&self, on: bool);
231
232        #[cfg(feature = "objc2-core-foundation")]
233        #[unsafe(method(initWithFrame:))]
234        #[unsafe(method_family = init)]
235        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
236
237        /// # Safety
238        ///
239        /// `coder` possibly has further requirements.
240        #[unsafe(method(initWithCoder:))]
241        #[unsafe(method_family = init)]
242        pub unsafe fn initWithCoder(
243            this: Allocated<Self>,
244            coder: &NSCoder,
245        ) -> Option<Retained<Self>>;
246
247        #[unsafe(method(setOn:animated:))]
248        #[unsafe(method_family = none)]
249        pub fn setOn_animated(&self, on: bool, animated: bool);
250    );
251}
252
253/// Methods declared on superclass `UIControl`.
254#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
255impl UISwitch {
256    extern_methods!(
257        #[cfg(all(
258            feature = "UIAction",
259            feature = "UIMenuElement",
260            feature = "objc2-core-foundation"
261        ))]
262        /// 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.
263        #[unsafe(method(initWithFrame:primaryAction:))]
264        #[unsafe(method_family = init)]
265        pub fn initWithFrame_primaryAction(
266            this: Allocated<Self>,
267            frame: CGRect,
268            primary_action: Option<&UIAction>,
269        ) -> Retained<Self>;
270    );
271}
272
273/// Methods declared on superclass `UIView`.
274#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
275impl UISwitch {
276    extern_methods!(
277        #[unsafe(method(init))]
278        #[unsafe(method_family = init)]
279        pub fn init(this: Allocated<Self>) -> Retained<Self>;
280    );
281}
282
283/// Methods declared on superclass `NSObject`.
284#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
285impl UISwitch {
286    extern_methods!(
287        #[unsafe(method(new))]
288        #[unsafe(method_family = new)]
289        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
290    );
291}