objc2_ui_kit/generated/
UIDatePicker.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/uidatepickermode?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct UIDatePickerMode(pub NSInteger);
20impl UIDatePickerMode {
21    /// Displays hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. 6 | 53 | PM)
22    #[doc(alias = "UIDatePickerModeTime")]
23    pub const Time: Self = Self(0);
24    /// Displays month, day, and year depending on the locale setting (e.g. November | 15 | 2007)
25    #[doc(alias = "UIDatePickerModeDate")]
26    pub const Date: Self = Self(1);
27    /// Displays date, hour, minute, and optionally AM/PM designation depending on the locale setting (e.g. Wed Nov 15 | 6 | 53 | PM)
28    #[doc(alias = "UIDatePickerModeDateAndTime")]
29    pub const DateAndTime: Self = Self(2);
30    /// Displays hour and minute (e.g. 1 | 53); only supported in `UIDatePickerStyleWheels`
31    #[doc(alias = "UIDatePickerModeCountDownTimer")]
32    pub const CountDownTimer: Self = Self(3);
33    /// Displays year and month depending on the locale setting (e.g. March | 2024); only supported in `UIDatePickerStyleWheels`
34    #[doc(alias = "UIDatePickerModeYearAndMonth")]
35    pub const YearAndMonth: Self = Self(4);
36}
37
38unsafe impl Encode for UIDatePickerMode {
39    const ENCODING: Encoding = NSInteger::ENCODING;
40}
41
42unsafe impl RefEncode for UIDatePickerMode {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidatepickerstyle?language=objc)
47// NS_ENUM
48#[repr(transparent)]
49#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
50pub struct UIDatePickerStyle(pub NSInteger);
51impl UIDatePickerStyle {
52    /// Automatically pick the best style available for the current platform
53    /// &
54    /// mode.
55    #[doc(alias = "UIDatePickerStyleAutomatic")]
56    pub const Automatic: Self = Self(0);
57    /// Use the wheels (UIPickerView) style. Editing occurs inline.
58    #[doc(alias = "UIDatePickerStyleWheels")]
59    pub const Wheels: Self = Self(1);
60    /// Use a compact style for the date picker. Editing occurs in an overlay.
61    #[doc(alias = "UIDatePickerStyleCompact")]
62    pub const Compact: Self = Self(2);
63    /// Use a style for the date picker that allows editing in place.
64    #[doc(alias = "UIDatePickerStyleInline")]
65    pub const Inline: Self = Self(3);
66}
67
68unsafe impl Encode for UIDatePickerStyle {
69    const ENCODING: Encoding = NSInteger::ENCODING;
70}
71
72unsafe impl RefEncode for UIDatePickerStyle {
73    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
74}
75
76extern_class!(
77    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidatepicker?language=objc)
78    #[unsafe(super(UIControl, UIView, UIResponder, NSObject))]
79    #[thread_kind = MainThreadOnly]
80    #[derive(Debug, PartialEq, Eq, Hash)]
81    #[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
82    pub struct UIDatePicker;
83);
84
85#[cfg(all(
86    feature = "UIControl",
87    feature = "UIResponder",
88    feature = "UIView",
89    feature = "objc2-quartz-core"
90))]
91#[cfg(not(target_os = "watchos"))]
92extern_conformance!(
93    unsafe impl CALayerDelegate for UIDatePicker {}
94);
95
96#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
97extern_conformance!(
98    unsafe impl NSCoding for UIDatePicker {}
99);
100
101#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
102extern_conformance!(
103    unsafe impl NSObjectProtocol for UIDatePicker {}
104);
105
106#[cfg(all(
107    feature = "UIAppearance",
108    feature = "UIControl",
109    feature = "UIResponder",
110    feature = "UIView"
111))]
112extern_conformance!(
113    unsafe impl UIAppearance for UIDatePicker {}
114);
115
116#[cfg(all(
117    feature = "UIAppearance",
118    feature = "UIControl",
119    feature = "UIResponder",
120    feature = "UIView"
121))]
122extern_conformance!(
123    unsafe impl UIAppearanceContainer for UIDatePicker {}
124);
125
126#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
127extern_conformance!(
128    unsafe impl UICoordinateSpace for UIDatePicker {}
129);
130
131#[cfg(all(
132    feature = "UIControl",
133    feature = "UIDynamicBehavior",
134    feature = "UIResponder",
135    feature = "UIView"
136))]
137extern_conformance!(
138    unsafe impl UIDynamicItem for UIDatePicker {}
139);
140
141#[cfg(all(
142    feature = "UIControl",
143    feature = "UIFocus",
144    feature = "UIResponder",
145    feature = "UIView"
146))]
147extern_conformance!(
148    unsafe impl UIFocusEnvironment for UIDatePicker {}
149);
150
151#[cfg(all(
152    feature = "UIControl",
153    feature = "UIFocus",
154    feature = "UIResponder",
155    feature = "UIView"
156))]
157extern_conformance!(
158    unsafe impl UIFocusItem for UIDatePicker {}
159);
160
161#[cfg(all(
162    feature = "UIControl",
163    feature = "UIFocus",
164    feature = "UIResponder",
165    feature = "UIView"
166))]
167extern_conformance!(
168    unsafe impl UIFocusItemContainer for UIDatePicker {}
169);
170
171#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
172extern_conformance!(
173    unsafe impl UIResponderStandardEditActions for UIDatePicker {}
174);
175
176#[cfg(all(
177    feature = "UIControl",
178    feature = "UIResponder",
179    feature = "UITraitCollection",
180    feature = "UIView"
181))]
182extern_conformance!(
183    unsafe impl UITraitEnvironment for UIDatePicker {}
184);
185
186#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
187impl UIDatePicker {
188    extern_methods!(
189        #[unsafe(method(datePickerMode))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn datePickerMode(&self) -> UIDatePickerMode;
192
193        /// Setter for [`datePickerMode`][Self::datePickerMode].
194        #[unsafe(method(setDatePickerMode:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn setDatePickerMode(&self, date_picker_mode: UIDatePickerMode);
197
198        #[unsafe(method(locale))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn locale(&self) -> Option<Retained<NSLocale>>;
201
202        /// Setter for [`locale`][Self::locale].
203        #[unsafe(method(setLocale:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);
206
207        #[unsafe(method(calendar))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;
210
211        /// Setter for [`calendar`][Self::calendar].
212        #[unsafe(method(setCalendar:))]
213        #[unsafe(method_family = none)]
214        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);
215
216        #[unsafe(method(timeZone))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
219
220        /// Setter for [`timeZone`][Self::timeZone].
221        #[unsafe(method(setTimeZone:))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
224
225        #[unsafe(method(date))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn date(&self) -> Retained<NSDate>;
228
229        /// Setter for [`date`][Self::date].
230        #[unsafe(method(setDate:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn setDate(&self, date: &NSDate);
233
234        #[unsafe(method(minimumDate))]
235        #[unsafe(method_family = none)]
236        pub unsafe fn minimumDate(&self) -> Option<Retained<NSDate>>;
237
238        /// Setter for [`minimumDate`][Self::minimumDate].
239        #[unsafe(method(setMinimumDate:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn setMinimumDate(&self, minimum_date: Option<&NSDate>);
242
243        #[unsafe(method(maximumDate))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn maximumDate(&self) -> Option<Retained<NSDate>>;
246
247        /// Setter for [`maximumDate`][Self::maximumDate].
248        #[unsafe(method(setMaximumDate:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn setMaximumDate(&self, maximum_date: Option<&NSDate>);
251
252        #[unsafe(method(countDownDuration))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn countDownDuration(&self) -> NSTimeInterval;
255
256        /// Setter for [`countDownDuration`][Self::countDownDuration].
257        #[unsafe(method(setCountDownDuration:))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn setCountDownDuration(&self, count_down_duration: NSTimeInterval);
260
261        #[unsafe(method(minuteInterval))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn minuteInterval(&self) -> NSInteger;
264
265        /// Setter for [`minuteInterval`][Self::minuteInterval].
266        #[unsafe(method(setMinuteInterval:))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn setMinuteInterval(&self, minute_interval: NSInteger);
269
270        #[unsafe(method(setDate:animated:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn setDate_animated(&self, date: &NSDate, animated: bool);
273
274        /// Request a style for the date picker. If the style changed, then the date picker may need to be resized and will generate a layout pass to display correctly.
275        #[unsafe(method(preferredDatePickerStyle))]
276        #[unsafe(method_family = none)]
277        pub unsafe fn preferredDatePickerStyle(&self) -> UIDatePickerStyle;
278
279        /// Setter for [`preferredDatePickerStyle`][Self::preferredDatePickerStyle].
280        #[unsafe(method(setPreferredDatePickerStyle:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn setPreferredDatePickerStyle(
283            &self,
284            preferred_date_picker_style: UIDatePickerStyle,
285        );
286
287        /// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
288        #[unsafe(method(datePickerStyle))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn datePickerStyle(&self) -> UIDatePickerStyle;
291
292        /// When this property is YES,
293        /// `date`will always round to the
294        /// `minuteInterval,`and
295        /// only emit dates that are aligned with the
296        /// `minuteInterval.`Otherwise, any changes
297        /// to
298        /// `date`will ignore the
299        /// `minuteInterval`property. Default is
300        /// `YES.`
301        #[unsafe(method(roundsToMinuteInterval))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn roundsToMinuteInterval(&self) -> bool;
304
305        /// Setter for [`roundsToMinuteInterval`][Self::roundsToMinuteInterval].
306        #[unsafe(method(setRoundsToMinuteInterval:))]
307        #[unsafe(method_family = none)]
308        pub unsafe fn setRoundsToMinuteInterval(&self, rounds_to_minute_interval: bool);
309    );
310}
311
312/// Methods declared on superclass `UIControl`.
313#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
314impl UIDatePicker {
315    extern_methods!(
316        #[cfg(feature = "objc2-core-foundation")]
317        #[unsafe(method(initWithFrame:))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
320
321        #[unsafe(method(initWithCoder:))]
322        #[unsafe(method_family = init)]
323        pub unsafe fn initWithCoder(
324            this: Allocated<Self>,
325            coder: &NSCoder,
326        ) -> Option<Retained<Self>>;
327
328        #[cfg(all(
329            feature = "UIAction",
330            feature = "UIMenuElement",
331            feature = "objc2-core-foundation"
332        ))]
333        /// 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.
334        #[unsafe(method(initWithFrame:primaryAction:))]
335        #[unsafe(method_family = init)]
336        pub unsafe fn initWithFrame_primaryAction(
337            this: Allocated<Self>,
338            frame: CGRect,
339            primary_action: Option<&UIAction>,
340        ) -> Retained<Self>;
341    );
342}
343
344/// Methods declared on superclass `NSObject`.
345#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
346impl UIDatePicker {
347    extern_methods!(
348        #[unsafe(method(init))]
349        #[unsafe(method_family = init)]
350        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
351
352        #[unsafe(method(new))]
353        #[unsafe(method_family = new)]
354        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
355    );
356}