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