objc2_ui_kit/generated/
UICalendarSelectionSingleDate.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarselectionsingledate?language=objc)
12    #[unsafe(super(UICalendarSelection, NSObject))]
13    #[thread_kind = MainThreadOnly]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    #[cfg(feature = "UICalendarSelection")]
16    pub struct UICalendarSelectionSingleDate;
17);
18
19#[cfg(feature = "UICalendarSelection")]
20extern_conformance!(
21    unsafe impl NSObjectProtocol for UICalendarSelectionSingleDate {}
22);
23
24#[cfg(feature = "UICalendarSelection")]
25impl UICalendarSelectionSingleDate {
26    extern_methods!(
27        /// The object that acts as the delegate of the calendar view selection
28        #[unsafe(method(delegate))]
29        #[unsafe(method_family = none)]
30        pub fn delegate(
31            &self,
32        ) -> Option<Retained<ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>>;
33
34        /// The currently selected dates in the Calendar view. If this property is
35        /// `nil`then nothing in the calendar
36        /// view is currently selected. The default value is
37        /// `nil.`
38        #[unsafe(method(selectedDate))]
39        #[unsafe(method_family = none)]
40        pub fn selectedDate(&self) -> Option<Retained<NSDateComponents>>;
41
42        /// Setter for [`selectedDate`][Self::selectedDate].
43        ///
44        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
45        #[unsafe(method(setSelectedDate:))]
46        #[unsafe(method_family = none)]
47        pub fn setSelectedDate(&self, selected_date: Option<&NSDateComponents>);
48
49        /// Sets the selected date to be displayed in the calendar, with an option to animate the setting.
50        #[unsafe(method(setSelectedDate:animated:))]
51        #[unsafe(method_family = none)]
52        pub fn setSelectedDate_animated(
53            &self,
54            selected_date: Option<&NSDateComponents>,
55            animated: bool,
56        );
57
58        /// Creates a new single selection with the specified delegate.
59        #[unsafe(method(initWithDelegate:))]
60        #[unsafe(method_family = init)]
61        pub fn initWithDelegate(
62            this: Allocated<Self>,
63            delegate: Option<&ProtocolObject<dyn UICalendarSelectionSingleDateDelegate>>,
64        ) -> Retained<Self>;
65    );
66}
67
68/// Methods declared on superclass `UICalendarSelection`.
69#[cfg(feature = "UICalendarSelection")]
70impl UICalendarSelectionSingleDate {
71    extern_methods!(
72        #[unsafe(method(init))]
73        #[unsafe(method_family = init)]
74        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
75
76        #[unsafe(method(new))]
77        #[unsafe(method_family = new)]
78        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
79    );
80}
81
82extern_protocol!(
83    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarselectionsingledatedelegate?language=objc)
84    pub unsafe trait UICalendarSelectionSingleDateDelegate:
85        NSObjectProtocol + MainThreadOnly
86    {
87        #[cfg(feature = "UICalendarSelection")]
88        /// Called after the user selects a date in the calendar view.
89        ///
90        ///
91        /// Parameter `selection`: The
92        /// `UICalendarSelectionMultiDate`
93        /// Parameter `dateComponents`: The date that was selected by the user.
94        /// `dateComponents`can be
95        /// `nil`when the selected date is deselected by the user.
96        #[unsafe(method(dateSelection:didSelectDate:))]
97        #[unsafe(method_family = none)]
98        fn dateSelection_didSelectDate(
99            &self,
100            selection: &UICalendarSelectionSingleDate,
101            date_components: Option<&NSDateComponents>,
102        );
103
104        #[cfg(feature = "UICalendarSelection")]
105        /// Determines if a date is selectable. Dates that are not selectable will be disabled in the calendar view.
106        /// By default,
107        /// `dateSelection:canSelectDate:`returns YES if dateComponents is non-nil.
108        ///
109        ///
110        /// Parameter `selection`: The
111        /// `UICalendarSelectionMultiDate`
112        /// Parameter `dateComponents`: The date to be checked by selection; a
113        /// `nil`date represents a deselected date.
114        ///
115        ///
116        /// Returns: YES if the date can be selected, NO otherwise.
117        #[optional]
118        #[unsafe(method(dateSelection:canSelectDate:))]
119        #[unsafe(method_family = none)]
120        fn dateSelection_canSelectDate(
121            &self,
122            selection: &UICalendarSelectionSingleDate,
123            date_components: Option<&NSDateComponents>,
124        ) -> bool;
125    }
126);