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 fn delegate(&self) -> Option<Retained<ProtocolObject<dyn UICalendarViewDelegate>>>;
104
105        /// Setter for [`delegate`][Self::delegate].
106        ///
107        /// This is a [weak property][objc2::topics::weak_property].
108        #[unsafe(method(setDelegate:))]
109        #[unsafe(method_family = none)]
110        pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn UICalendarViewDelegate>>);
111
112        #[cfg(feature = "UICalendarSelection")]
113        /// The object that defines the selection behavior of the calendar view.
114        #[unsafe(method(selectionBehavior))]
115        #[unsafe(method_family = none)]
116        pub fn selectionBehavior(&self) -> Option<Retained<UICalendarSelection>>;
117
118        #[cfg(feature = "UICalendarSelection")]
119        /// Setter for [`selectionBehavior`][Self::selectionBehavior].
120        #[unsafe(method(setSelectionBehavior:))]
121        #[unsafe(method_family = none)]
122        pub fn setSelectionBehavior(&self, selection_behavior: Option<&UICalendarSelection>);
123
124        /// The backing locale of the calendar view. The default value is
125        /// `NSLocale.currentLocale`
126        #[unsafe(method(locale))]
127        #[unsafe(method_family = none)]
128        pub fn locale(&self) -> Retained<NSLocale>;
129
130        /// Setter for [`locale`][Self::locale].
131        #[unsafe(method(setLocale:))]
132        #[unsafe(method_family = none)]
133        pub fn setLocale(&self, locale: &NSLocale);
134
135        /// The backing calendar of the calendar view. The default value is
136        /// `NSCalendar.currentCalendar`
137        #[unsafe(method(calendar))]
138        #[unsafe(method_family = none)]
139        pub fn calendar(&self) -> Retained<NSCalendar>;
140
141        /// Setter for [`calendar`][Self::calendar].
142        ///
143        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
144        #[unsafe(method(setCalendar:))]
145        #[unsafe(method_family = none)]
146        pub fn setCalendar(&self, calendar: &NSCalendar);
147
148        /// The backing time zone of the calendar view. Default is nil
149        #[unsafe(method(timeZone))]
150        #[unsafe(method_family = none)]
151        pub fn timeZone(&self) -> Option<Retained<NSTimeZone>>;
152
153        /// Setter for [`timeZone`][Self::timeZone].
154        #[unsafe(method(setTimeZone:))]
155        #[unsafe(method_family = none)]
156        pub fn setTimeZone(&self, time_zone: Option<&NSTimeZone>);
157
158        #[cfg(feature = "UIFontDescriptor")]
159        /// The font design of the calendar view. The default value is
160        /// `UIFontDescriptorSystemDesignDefault`
161        #[unsafe(method(fontDesign))]
162        #[unsafe(method_family = none)]
163        pub fn fontDesign(&self) -> Retained<UIFontDescriptorSystemDesign>;
164
165        #[cfg(feature = "UIFontDescriptor")]
166        /// Setter for [`fontDesign`][Self::fontDesign].
167        ///
168        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
169        #[unsafe(method(setFontDesign:))]
170        #[unsafe(method_family = none)]
171        pub 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 fn availableDateRange(&self) -> Retained<NSDateInterval>;
179
180        /// Setter for [`availableDateRange`][Self::availableDateRange].
181        ///
182        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
183        #[unsafe(method(setAvailableDateRange:))]
184        #[unsafe(method_family = none)]
185        pub fn setAvailableDateRange(&self, available_date_range: &NSDateInterval);
186
187        /// The date components representing the current visible date of the calendar view. The default value is the
188        /// NSDateComponents representation of the current date given the granularity of the displayed component.
189        /// The
190        /// `visibleDateComponents`must also be a valid date within
191        /// `availableDateRange`
192        ///
193        /// Note: If
194        /// `visibleDateComponents.calendar`and
195        /// `UICalendarView.calendar`are not equal,the input date components
196        /// will be converted to use
197        /// `UICalendarView.calendar`upon assignment. UICalendarView will use
198        /// `UICalendarView.calendar`if
199        /// `visibleDateComponents.calendar`is not explicitly marked, and may result
200        /// in incorrect dates if the dateComponents is not valid in
201        /// `UICalendarView.calendar.`
202        #[unsafe(method(visibleDateComponents))]
203        #[unsafe(method_family = none)]
204        pub fn visibleDateComponents(&self) -> Retained<NSDateComponents>;
205
206        /// Setter for [`visibleDateComponents`][Self::visibleDateComponents].
207        ///
208        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
209        #[unsafe(method(setVisibleDateComponents:))]
210        #[unsafe(method_family = none)]
211        pub fn setVisibleDateComponents(&self, visible_date_components: &NSDateComponents);
212
213        /// Sets the visible date components of the calendar view, with an option to animate the setting.
214        /// The
215        /// `visibleDateComponents`must also be a valid date within
216        /// `availableDateRange`
217        ///
218        /// Note: If
219        /// `visibleDateComponents.calendar`and
220        /// `UICalendarView.calendar`are not equal,the input date components
221        /// will be converted to use
222        /// `UICalendarView.calendar`upon assignment. UICalendarView will use
223        /// `UICalendarView.calendar`if
224        /// `visibleDateComponents.calendar`is not explicitly marked, and may result
225        /// in incorrect dates if the dateComponents is not valid in
226        /// `UICalendarView.calendar.`
227        #[unsafe(method(setVisibleDateComponents:animated:))]
228        #[unsafe(method_family = none)]
229        pub fn setVisibleDateComponents_animated(
230            &self,
231            date_components: &NSDateComponents,
232            animated: bool,
233        );
234
235        /// Determines if we show date decorations. By default, this value returns
236        /// `YES,`but you must also implement
237        /// the delegate method
238        /// `calendarView:decorationForDate:`to show decorations.
239        #[unsafe(method(wantsDateDecorations))]
240        #[unsafe(method_family = none)]
241        pub fn wantsDateDecorations(&self) -> bool;
242
243        /// Setter for [`wantsDateDecorations`][Self::wantsDateDecorations].
244        #[unsafe(method(setWantsDateDecorations:))]
245        #[unsafe(method_family = none)]
246        pub fn setWantsDateDecorations(&self, wants_date_decorations: bool);
247
248        /// Reloads the decorations for the specified dates, with an option to animate the action.
249        /// Decorations are only available if you implement the delegate method
250        /// `calendarView:decorationForDate:`
251        #[unsafe(method(reloadDecorationsForDateComponents:animated:))]
252        #[unsafe(method_family = none)]
253        pub fn reloadDecorationsForDateComponents_animated(
254            &self,
255            dates: &NSArray<NSDateComponents>,
256            animated: bool,
257        );
258    );
259}
260
261/// Methods declared on superclass `UIView`.
262#[cfg(all(feature = "UIResponder", feature = "UIView"))]
263impl UICalendarView {
264    extern_methods!(
265        #[cfg(feature = "objc2-core-foundation")]
266        #[unsafe(method(initWithFrame:))]
267        #[unsafe(method_family = init)]
268        pub fn initWithFrame(this: Allocated<Self>, frame: CGRect) -> Retained<Self>;
269
270        /// # Safety
271        ///
272        /// `coder` possibly has further requirements.
273        #[unsafe(method(initWithCoder:))]
274        #[unsafe(method_family = init)]
275        pub unsafe fn initWithCoder(
276            this: Allocated<Self>,
277            coder: &NSCoder,
278        ) -> Option<Retained<Self>>;
279
280        #[unsafe(method(init))]
281        #[unsafe(method_family = init)]
282        pub fn init(this: Allocated<Self>) -> Retained<Self>;
283    );
284}
285
286/// Methods declared on superclass `NSObject`.
287#[cfg(all(feature = "UIResponder", feature = "UIView"))]
288impl UICalendarView {
289    extern_methods!(
290        #[unsafe(method(new))]
291        #[unsafe(method_family = new)]
292        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
293    );
294}
295
296extern_protocol!(
297    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicalendarviewdelegate?language=objc)
298    pub unsafe trait UICalendarViewDelegate: NSObjectProtocol + MainThreadOnly {
299        #[cfg(all(
300            feature = "UICalendarViewDecoration",
301            feature = "UIResponder",
302            feature = "UIView"
303        ))]
304        /// Called when the calendar view is preparing decorations.
305        ///
306        ///
307        /// Parameter `calendarView`: The
308        /// `UICalendarView`
309        /// Parameter `dateComponents`: The date for which the decoration is prepared for.
310        ///
311        ///
312        /// Returns: A
313        /// `UICalendarViewDecoration`to annotate the specific date. Return
314        /// `nil`for no decoration.
315        #[optional]
316        #[unsafe(method(calendarView:decorationForDateComponents:))]
317        #[unsafe(method_family = none)]
318        fn calendarView_decorationForDateComponents(
319            &self,
320            calendar_view: &UICalendarView,
321            date_components: &NSDateComponents,
322        ) -> Option<Retained<UICalendarViewDecoration>>;
323
324        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
325        /// Called when the visible date has changed from
326        /// `previousDateComponents`from user interaction.
327        ///
328        ///
329        /// Parameter `calendarView`: The
330        /// `UICalendarView`
331        /// Parameter `previousDateComponents`: The previous date components before the visible date components changed.
332        #[optional]
333        #[unsafe(method(calendarView:didChangeVisibleDateComponentsFrom:))]
334        #[unsafe(method_family = none)]
335        fn calendarView_didChangeVisibleDateComponentsFrom(
336            &self,
337            calendar_view: &UICalendarView,
338            previous_date_components: &NSDateComponents,
339        );
340    }
341);