objc2_ui_kit/generated/
UICalendarView.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
15extern_class!(
16    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarview?language=objc)
17    #[unsafe(super(UIView, UIResponder, NSObject))]
18    #[thread_kind = MainThreadOnly]
19    #[derive(Debug, PartialEq, Eq, Hash)]
20    #[cfg(all(feature = "UIResponder", feature = "UIView"))]
21    pub struct UICalendarView;
22);
23
24#[cfg(all(
25    feature = "UIResponder",
26    feature = "UIView",
27    feature = "objc2-quartz-core"
28))]
29#[cfg(not(target_os = "watchos"))]
30unsafe impl CALayerDelegate for UICalendarView {}
31
32#[cfg(all(feature = "UIResponder", feature = "UIView"))]
33unsafe impl NSCoding for UICalendarView {}
34
35#[cfg(all(feature = "UIResponder", feature = "UIView"))]
36unsafe impl NSObjectProtocol for UICalendarView {}
37
38#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
39unsafe impl UIAppearance for UICalendarView {}
40
41#[cfg(all(feature = "UIAppearance", feature = "UIResponder", feature = "UIView"))]
42unsafe impl UIAppearanceContainer for UICalendarView {}
43
44#[cfg(all(feature = "UIResponder", feature = "UIView"))]
45unsafe impl UICoordinateSpace for UICalendarView {}
46
47#[cfg(all(
48    feature = "UIDynamicBehavior",
49    feature = "UIResponder",
50    feature = "UIView"
51))]
52unsafe impl UIDynamicItem for UICalendarView {}
53
54#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
55unsafe impl UIFocusEnvironment for UICalendarView {}
56
57#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
58unsafe impl UIFocusItem for UICalendarView {}
59
60#[cfg(all(feature = "UIFocus", feature = "UIResponder", feature = "UIView"))]
61unsafe impl UIFocusItemContainer for UICalendarView {}
62
63#[cfg(all(feature = "UIResponder", feature = "UIView"))]
64unsafe impl UIResponderStandardEditActions for UICalendarView {}
65
66#[cfg(all(
67    feature = "UIResponder",
68    feature = "UITraitCollection",
69    feature = "UIView"
70))]
71unsafe impl UITraitEnvironment for UICalendarView {}
72
73#[cfg(all(feature = "UIResponder", feature = "UIView"))]
74impl UICalendarView {
75    extern_methods!(
76        /// The object that defines the delegate of the calendar view.
77        #[unsafe(method(delegate))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn delegate(
80            &self,
81        ) -> Option<Retained<ProtocolObject<dyn UICalendarViewDelegate>>>;
82
83        /// This is a [weak property][objc2::topics::weak_property].
84        /// Setter for [`delegate`][Self::delegate].
85        #[unsafe(method(setDelegate:))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn setDelegate(
88            &self,
89            delegate: Option<&ProtocolObject<dyn UICalendarViewDelegate>>,
90        );
91
92        #[cfg(feature = "UICalendarSelection")]
93        /// The object that defines the selection behavior of the calendar view.
94        #[unsafe(method(selectionBehavior))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn selectionBehavior(&self) -> Option<Retained<UICalendarSelection>>;
97
98        #[cfg(feature = "UICalendarSelection")]
99        /// Setter for [`selectionBehavior`][Self::selectionBehavior].
100        #[unsafe(method(setSelectionBehavior:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setSelectionBehavior(&self, selection_behavior: Option<&UICalendarSelection>);
103
104        /// The backing locale of the calendar view. The default value is
105        /// `NSLocale.currentLocale`
106        #[unsafe(method(locale))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn locale(&self) -> Retained<NSLocale>;
109
110        /// Setter for [`locale`][Self::locale].
111        #[unsafe(method(setLocale:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setLocale(&self, locale: &NSLocale);
114
115        /// The backing calendar of the calendar view. The default value is
116        /// `NSCalendar.currentCalendar`
117        #[unsafe(method(calendar))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn calendar(&self) -> Retained<NSCalendar>;
120
121        /// Setter for [`calendar`][Self::calendar].
122        #[unsafe(method(setCalendar:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setCalendar(&self, calendar: &NSCalendar);
125
126        /// The backing time zone of the calendar view. Default is nil
127        #[unsafe(method(timeZone))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
130
131        /// Setter for [`timeZone`][Self::timeZone].
132        #[unsafe(method(setTimeZone:))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
135
136        #[cfg(feature = "UIFontDescriptor")]
137        /// The font design of the calendar view. The default value is
138        /// `UIFontDescriptorSystemDesignDefault`
139        #[unsafe(method(fontDesign))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn fontDesign(&self) -> Retained<UIFontDescriptorSystemDesign>;
142
143        #[cfg(feature = "UIFontDescriptor")]
144        /// Setter for [`fontDesign`][Self::fontDesign].
145        #[unsafe(method(setFontDesign:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn setFontDesign(&self, font_design: &UIFontDescriptorSystemDesign);
148
149        /// The available date range of the calendar view. The default is a date interval from
150        /// `NSDate.distantPast`to
151        /// `NSDate.distantFuture`
152        #[unsafe(method(availableDateRange))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn availableDateRange(&self) -> Retained<NSDateInterval>;
155
156        /// Setter for [`availableDateRange`][Self::availableDateRange].
157        #[unsafe(method(setAvailableDateRange:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setAvailableDateRange(&self, available_date_range: &NSDateInterval);
160
161        /// The date components representing the current visible date of the calendar view. The default value is the
162        /// NSDateComponents representation of the current date given the granularity of the displayed component.
163        /// The
164        /// `visibleDateComponents`must also be a valid date within
165        /// `availableDateRange`
166        ///
167        /// Note: If
168        /// `visibleDateComponents.calendar`and
169        /// `UICalendarView.calendar`are not equal,the input date components
170        /// will be converted to use
171        /// `UICalendarView.calendar`upon assignment. UICalendarView will use
172        /// `UICalendarView.calendar`if
173        /// `visibleDateComponents.calendar`is not explicitly marked, and may result
174        /// in incorrect dates if the dateComponents is not valid in
175        /// `UICalendarView.calendar.`
176        #[unsafe(method(visibleDateComponents))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn visibleDateComponents(&self) -> Retained<NSDateComponents>;
179
180        /// Setter for [`visibleDateComponents`][Self::visibleDateComponents].
181        #[unsafe(method(setVisibleDateComponents:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn setVisibleDateComponents(&self, visible_date_components: &NSDateComponents);
184
185        /// Sets the visible date components of the calendar view, with an option to animate the setting.
186        /// The
187        /// `visibleDateComponents`must also be a valid date within
188        /// `availableDateRange`
189        ///
190        /// Note: If
191        /// `visibleDateComponents.calendar`and
192        /// `UICalendarView.calendar`are not equal,the input date components
193        /// will be converted to use
194        /// `UICalendarView.calendar`upon assignment. UICalendarView will use
195        /// `UICalendarView.calendar`if
196        /// `visibleDateComponents.calendar`is not explicitly marked, and may result
197        /// in incorrect dates if the dateComponents is not valid in
198        /// `UICalendarView.calendar.`
199        #[unsafe(method(setVisibleDateComponents:animated:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setVisibleDateComponents_animated(
202            &self,
203            date_components: &NSDateComponents,
204            animated: bool,
205        );
206
207        /// Determines if we show date decorations. By default, this value returns
208        /// `YES,`but you must also implement
209        /// the delegate method
210        /// `calendarView:decorationForDate:`to show decorations.
211        #[unsafe(method(wantsDateDecorations))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn wantsDateDecorations(&self) -> bool;
214
215        /// Setter for [`wantsDateDecorations`][Self::wantsDateDecorations].
216        #[unsafe(method(setWantsDateDecorations:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setWantsDateDecorations(&self, wants_date_decorations: bool);
219
220        /// Reloads the decorations for the specified dates, with an option to animate the action.
221        /// Decorations are only available if you implement the delegate method
222        /// `calendarView:decorationForDate:`
223        #[unsafe(method(reloadDecorationsForDateComponents:animated:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn reloadDecorationsForDateComponents_animated(
226            &self,
227            dates: &NSArray<NSDateComponents>,
228            animated: bool,
229        );
230    );
231}
232
233/// Methods declared on superclass `UIView`.
234#[cfg(all(feature = "UIResponder", feature = "UIView"))]
235impl UICalendarView {
236    extern_methods!(
237        #[cfg(feature = "objc2-core-foundation")]
238        #[unsafe(method(initWithFrame:))]
239        #[unsafe(method_family = init)]
240        pub unsafe fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
241
242        #[unsafe(method(initWithCoder:))]
243        #[unsafe(method_family = init)]
244        pub unsafe fn initWithCoder(
245            this: Allocated<Self>,
246            coder: &NSCoder,
247        ) -> Option<Retained<Self>>;
248    );
249}
250
251/// Methods declared on superclass `NSObject`.
252#[cfg(all(feature = "UIResponder", feature = "UIView"))]
253impl UICalendarView {
254    extern_methods!(
255        #[unsafe(method(init))]
256        #[unsafe(method_family = init)]
257        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
258
259        #[unsafe(method(new))]
260        #[unsafe(method_family = new)]
261        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
262    );
263}
264
265extern_protocol!(
266    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarviewdelegate?language=objc)
267    pub unsafe trait UICalendarViewDelegate: NSObjectProtocol {
268        #[cfg(all(
269            feature = "UICalendarViewDecoration",
270            feature = "UIResponder",
271            feature = "UIView"
272        ))]
273        /// Called when the calendar view is preparing decorations.
274        ///
275        ///
276        /// Parameter `calendarView`: The
277        /// `UICalendarView`
278        /// Parameter `dateComponents`: The date for which the decoration is prepared for.
279        ///
280        ///
281        /// Returns: A
282        /// `UICalendarViewDecoration`to annotate the specific date. Return
283        /// `nil`for no decoration.
284        #[optional]
285        #[unsafe(method(calendarView:decorationForDateComponents:))]
286        #[unsafe(method_family = none)]
287        unsafe fn calendarView_decorationForDateComponents(
288            &self,
289            calendar_view: &UICalendarView,
290            date_components: &NSDateComponents,
291        ) -> Option<Retained<UICalendarViewDecoration>>;
292
293        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
294        /// Called when the visible date has changed from
295        /// `previousDateComponents`from user interaction.
296        ///
297        ///
298        /// Parameter `calendarView`: The
299        /// `UICalendarView`
300        /// Parameter `previousDateComponents`: The previous date components before the visible date components changed.
301        #[optional]
302        #[unsafe(method(calendarView:didChangeVisibleDateComponentsFrom:))]
303        #[unsafe(method_family = none)]
304        unsafe fn calendarView_didChangeVisibleDateComponentsFrom(
305            &self,
306            calendar_view: &UICalendarView,
307            previous_date_components: &NSDateComponents,
308        );
309    }
310);