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 fn datePickerMode(&self) -> UIDatePickerMode;
192
193        /// Setter for [`datePickerMode`][Self::datePickerMode].
194        #[unsafe(method(setDatePickerMode:))]
195        #[unsafe(method_family = none)]
196        pub fn setDatePickerMode(&self, date_picker_mode: UIDatePickerMode);
197
198        #[unsafe(method(locale))]
199        #[unsafe(method_family = none)]
200        pub fn locale(&self) -> Option<Retained<NSLocale>>;
201
202        /// Setter for [`locale`][Self::locale].
203        #[unsafe(method(setLocale:))]
204        #[unsafe(method_family = none)]
205        pub fn setLocale(&self, locale: Option<&NSLocale>);
206
207        #[unsafe(method(calendar))]
208        #[unsafe(method_family = none)]
209        pub fn calendar(&self) -> Retained<NSCalendar>;
210
211        /// Setter for [`calendar`][Self::calendar].
212        ///
213        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
214        #[unsafe(method(setCalendar:))]
215        #[unsafe(method_family = none)]
216        pub fn setCalendar(&self, calendar: Option<&NSCalendar>);
217
218        #[unsafe(method(timeZone))]
219        #[unsafe(method_family = none)]
220        pub fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
221
222        /// Setter for [`timeZone`][Self::timeZone].
223        #[unsafe(method(setTimeZone:))]
224        #[unsafe(method_family = none)]
225        pub fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
226
227        #[unsafe(method(date))]
228        #[unsafe(method_family = none)]
229        pub fn date(&self) -> Retained<NSDate>;
230
231        /// Setter for [`date`][Self::date].
232        #[unsafe(method(setDate:))]
233        #[unsafe(method_family = none)]
234        pub fn setDate(&self, date: &NSDate);
235
236        #[unsafe(method(minimumDate))]
237        #[unsafe(method_family = none)]
238        pub fn minimumDate(&self) -> Option<Retained<NSDate>>;
239
240        /// Setter for [`minimumDate`][Self::minimumDate].
241        #[unsafe(method(setMinimumDate:))]
242        #[unsafe(method_family = none)]
243        pub fn setMinimumDate(&self, minimum_date: Option<&NSDate>);
244
245        #[unsafe(method(maximumDate))]
246        #[unsafe(method_family = none)]
247        pub fn maximumDate(&self) -> Option<Retained<NSDate>>;
248
249        /// Setter for [`maximumDate`][Self::maximumDate].
250        #[unsafe(method(setMaximumDate:))]
251        #[unsafe(method_family = none)]
252        pub fn setMaximumDate(&self, maximum_date: Option<&NSDate>);
253
254        #[unsafe(method(countDownDuration))]
255        #[unsafe(method_family = none)]
256        pub fn countDownDuration(&self) -> NSTimeInterval;
257
258        /// Setter for [`countDownDuration`][Self::countDownDuration].
259        #[unsafe(method(setCountDownDuration:))]
260        #[unsafe(method_family = none)]
261        pub fn setCountDownDuration(&self, count_down_duration: NSTimeInterval);
262
263        #[unsafe(method(minuteInterval))]
264        #[unsafe(method_family = none)]
265        pub fn minuteInterval(&self) -> NSInteger;
266
267        /// Setter for [`minuteInterval`][Self::minuteInterval].
268        #[unsafe(method(setMinuteInterval:))]
269        #[unsafe(method_family = none)]
270        pub fn setMinuteInterval(&self, minute_interval: NSInteger);
271
272        #[unsafe(method(setDate:animated:))]
273        #[unsafe(method_family = none)]
274        pub fn setDate_animated(&self, date: &NSDate, animated: bool);
275
276        /// 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.
277        #[unsafe(method(preferredDatePickerStyle))]
278        #[unsafe(method_family = none)]
279        pub fn preferredDatePickerStyle(&self) -> UIDatePickerStyle;
280
281        /// Setter for [`preferredDatePickerStyle`][Self::preferredDatePickerStyle].
282        #[unsafe(method(setPreferredDatePickerStyle:))]
283        #[unsafe(method_family = none)]
284        pub fn setPreferredDatePickerStyle(&self, preferred_date_picker_style: UIDatePickerStyle);
285
286        /// The style that the date picker is using for its layout. This property always returns a concrete style (never automatic).
287        #[unsafe(method(datePickerStyle))]
288        #[unsafe(method_family = none)]
289        pub fn datePickerStyle(&self) -> UIDatePickerStyle;
290
291        /// When this property is YES,
292        /// `date`will always round to the
293        /// `minuteInterval,`and
294        /// only emit dates that are aligned with the
295        /// `minuteInterval.`Otherwise, any changes
296        /// to
297        /// `date`will ignore the
298        /// `minuteInterval`property. Default is
299        /// `YES.`
300        #[unsafe(method(roundsToMinuteInterval))]
301        #[unsafe(method_family = none)]
302        pub fn roundsToMinuteInterval(&self) -> bool;
303
304        /// Setter for [`roundsToMinuteInterval`][Self::roundsToMinuteInterval].
305        #[unsafe(method(setRoundsToMinuteInterval:))]
306        #[unsafe(method_family = none)]
307        pub fn setRoundsToMinuteInterval(&self, rounds_to_minute_interval: bool);
308    );
309}
310
311/// Methods declared on superclass `UIControl`.
312#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
313impl UIDatePicker {
314    extern_methods!(
315        #[cfg(feature = "objc2-core-foundation")]
316        #[unsafe(method(initWithFrame:))]
317        #[unsafe(method_family = init)]
318        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
319
320        /// # Safety
321        ///
322        /// `coder` possibly has further requirements.
323        #[unsafe(method(initWithCoder:))]
324        #[unsafe(method_family = init)]
325        pub unsafe fn initWithCoder(
326            this: Allocated<Self>,
327            coder: &NSCoder,
328        ) -> Option<Retained<Self>>;
329
330        #[cfg(all(
331            feature = "UIAction",
332            feature = "UIMenuElement",
333            feature = "objc2-core-foundation"
334        ))]
335        /// 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.
336        #[unsafe(method(initWithFrame:primaryAction:))]
337        #[unsafe(method_family = init)]
338        pub fn initWithFrame_primaryAction(
339            this: Allocated<Self>,
340            frame: CGRect,
341            primary_action: Option<&UIAction>,
342        ) -> Retained<Self>;
343    );
344}
345
346/// Methods declared on superclass `UIView`.
347#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
348impl UIDatePicker {
349    extern_methods!(
350        #[unsafe(method(init))]
351        #[unsafe(method_family = init)]
352        pub fn init(this: Allocated<Self>) -> Retained<Self>;
353    );
354}
355
356/// Methods declared on superclass `NSObject`.
357#[cfg(all(feature = "UIControl", feature = "UIResponder", feature = "UIView"))]
358impl UIDatePicker {
359    extern_methods!(
360        #[unsafe(method(new))]
361        #[unsafe(method_family = new)]
362        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
363    );
364}