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"))]
92unsafe impl CALayerDelegate for UIDatePicker {}
93
94#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
95unsafe impl NSCoding for UIDatePicker {}
96
97#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
98unsafe impl NSObjectProtocol for UIDatePicker {}
99
100#[cfg(all(
101    feature = "UIAppearance",
102    feature = "UIControl",
103    feature = "UIResponder",
104    feature = "UIView"
105))]
106unsafe impl UIAppearance for UIDatePicker {}
107
108#[cfg(all(
109    feature = "UIAppearance",
110    feature = "UIControl",
111    feature = "UIResponder",
112    feature = "UIView"
113))]
114unsafe impl UIAppearanceContainer for UIDatePicker {}
115
116#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
117unsafe impl UICoordinateSpace for UIDatePicker {}
118
119#[cfg(all(
120    feature = "UIControl",
121    feature = "UIDynamicBehavior",
122    feature = "UIResponder",
123    feature = "UIView"
124))]
125unsafe impl UIDynamicItem for UIDatePicker {}
126
127#[cfg(all(
128    feature = "UIControl",
129    feature = "UIFocus",
130    feature = "UIResponder",
131    feature = "UIView"
132))]
133unsafe impl UIFocusEnvironment for UIDatePicker {}
134
135#[cfg(all(
136    feature = "UIControl",
137    feature = "UIFocus",
138    feature = "UIResponder",
139    feature = "UIView"
140))]
141unsafe impl UIFocusItem for UIDatePicker {}
142
143#[cfg(all(
144    feature = "UIControl",
145    feature = "UIFocus",
146    feature = "UIResponder",
147    feature = "UIView"
148))]
149unsafe impl UIFocusItemContainer for UIDatePicker {}
150
151#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
152unsafe impl UIResponderStandardEditActions for UIDatePicker {}
153
154#[cfg(all(
155    feature = "UIControl",
156    feature = "UIResponder",
157    feature = "UITraitCollection",
158    feature = "UIView"
159))]
160unsafe impl UITraitEnvironment for UIDatePicker {}
161
162#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
163impl UIDatePicker {
164    extern_methods!(
165        #[unsafe(method(datePickerMode))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn datePickerMode(&self) -> UIDatePickerMode;
168
169        /// Setter for [`datePickerMode`][Self::datePickerMode].
170        #[unsafe(method(setDatePickerMode:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setDatePickerMode(&self, date_picker_mode: UIDatePickerMode);
173
174        #[unsafe(method(locale))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn locale(&self) -> Option<Retained<NSLocale>>;
177
178        /// Setter for [`locale`][Self::locale].
179        #[unsafe(method(setLocale:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setLocale(&self, locale: Option<&NSLocale>);
182
183        #[unsafe(method(calendar))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;
186
187        /// Setter for [`calendar`][Self::calendar].
188        #[unsafe(method(setCalendar:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setCalendar(&self, calendar: Option<&NSCalendar>);
191
192        #[unsafe(method(timeZone))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
195
196        /// Setter for [`timeZone`][Self::timeZone].
197        #[unsafe(method(setTimeZone:))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
200
201        #[unsafe(method(date))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn date(&self) -> Retained<NSDate>;
204
205        /// Setter for [`date`][Self::date].
206        #[unsafe(method(setDate:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn setDate(&self, date: &NSDate);
209
210        #[unsafe(method(minimumDate))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn minimumDate(&self) -> Option<Retained<NSDate>>;
213
214        /// Setter for [`minimumDate`][Self::minimumDate].
215        #[unsafe(method(setMinimumDate:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setMinimumDate(&self, minimum_date: Option<&NSDate>);
218
219        #[unsafe(method(maximumDate))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn maximumDate(&self) -> Option<Retained<NSDate>>;
222
223        /// Setter for [`maximumDate`][Self::maximumDate].
224        #[unsafe(method(setMaximumDate:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setMaximumDate(&self, maximum_date: Option<&NSDate>);
227
228        #[unsafe(method(countDownDuration))]
229        #[unsafe(method_family = none)]
230        pub unsafe fn countDownDuration(&self) -> NSTimeInterval;
231
232        /// Setter for [`countDownDuration`][Self::countDownDuration].
233        #[unsafe(method(setCountDownDuration:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setCountDownDuration(&self, count_down_duration: NSTimeInterval);
236
237        #[unsafe(method(minuteInterval))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn minuteInterval(&self) -> NSInteger;
240
241        /// Setter for [`minuteInterval`][Self::minuteInterval].
242        #[unsafe(method(setMinuteInterval:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn setMinuteInterval(&self, minute_interval: NSInteger);
245
246        #[unsafe(method(setDate:animated:))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn setDate_animated(&self, date: &NSDate, animated: bool);
249
250        /// 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.
251        #[unsafe(method(preferredDatePickerStyle))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn preferredDatePickerStyle(&self) -> UIDatePickerStyle;
254
255        /// Setter for [`preferredDatePickerStyle`][Self::preferredDatePickerStyle].
256        #[unsafe(method(setPreferredDatePickerStyle:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setPreferredDatePickerStyle(
259            &self,
260            preferred_date_picker_style: UIDatePickerStyle,
261        );
262
263        /// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
264        #[unsafe(method(datePickerStyle))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn datePickerStyle(&self) -> UIDatePickerStyle;
267
268        /// When this property is YES,
269        /// `date`will always round to the
270        /// `minuteInterval,`and
271        /// only emit dates that are aligned with the
272        /// `minuteInterval.`Otherwise, any changes
273        /// to
274        /// `date`will ignore the
275        /// `minuteInterval`property. Default is
276        /// `YES.`
277        #[unsafe(method(roundsToMinuteInterval))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn roundsToMinuteInterval(&self) -> bool;
280
281        /// Setter for [`roundsToMinuteInterval`][Self::roundsToMinuteInterval].
282        #[unsafe(method(setRoundsToMinuteInterval:))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn setRoundsToMinuteInterval(&self, rounds_to_minute_interval: bool);
285    );
286}
287
288/// Methods declared on superclass `UIControl`.
289#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
290impl UIDatePicker {
291    extern_methods!(
292        #[cfg(feature = "objc2-core-foundation")]
293        #[unsafe(method(initWithFrame:))]
294        #[unsafe(method_family = init)]
295        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
296
297        #[unsafe(method(initWithCoder:))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn initWithCoder(
300            this: Allocated<Self>,
301            coder: &NSCoder,
302        ) -> Option<Retained<Self>>;
303
304        #[cfg(all(
305            feature = "UIAction",
306            feature = "UIMenuElement",
307            feature = "objc2-core-foundation"
308        ))]
309        /// 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.
310        #[unsafe(method(initWithFrame:primaryAction:))]
311        #[unsafe(method_family = init)]
312        pub unsafe fn initWithFrame_primaryAction(
313            this: Allocated<Self>,
314            frame: CGRect,
315            primary_action: Option<&UIAction>,
316        ) -> Retained<Self>;
317    );
318}
319
320/// Methods declared on superclass `NSObject`.
321#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
322impl UIDatePicker {
323    extern_methods!(
324        #[unsafe(method(init))]
325        #[unsafe(method_family = init)]
326        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
327
328        #[unsafe(method(new))]
329        #[unsafe(method_family = new)]
330        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
331    );
332}