objc2_event_kit_ui/generated/
EKEventEditViewController.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-event-kit")]
7use objc2_event_kit::*;
8use objc2_foundation::*;
9#[cfg(feature = "objc2-ui-kit")]
10use objc2_ui_kit::*;
11
12use crate::*;
13
14/// Represents actions that should cause the edit view controller to be dismissed
15///
16/// See also [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewaction?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct EKEventEditViewAction(pub NSInteger);
21impl EKEventEditViewAction {
22    #[doc(alias = "EKEventEditViewActionCanceled")]
23    pub const Canceled: Self = Self(0);
24    #[doc(alias = "EKEventEditViewActionSaved")]
25    pub const Saved: Self = Self(1);
26    #[doc(alias = "EKEventEditViewActionDeleted")]
27    pub const Deleted: Self = Self(2);
28    #[doc(alias = "EKEventEditViewActionCancelled")]
29    pub const Cancelled: Self = Self(EKEventEditViewAction::Canceled.0);
30}
31
32unsafe impl Encode for EKEventEditViewAction {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for EKEventEditViewAction {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewcontroller?language=objc)
42    #[unsafe(super(UINavigationController, UIViewController, UIResponder, NSObject))]
43    #[derive(Debug, PartialEq, Eq, Hash)]
44    #[cfg(feature = "objc2-ui-kit")]
45    pub struct EKEventEditViewController;
46);
47
48#[cfg(feature = "objc2-ui-kit")]
49extern_conformance!(
50    unsafe impl NSCoding for EKEventEditViewController {}
51);
52
53#[cfg(feature = "objc2-ui-kit")]
54extern_conformance!(
55    unsafe impl NSObjectProtocol for EKEventEditViewController {}
56);
57
58#[cfg(feature = "objc2-ui-kit")]
59extern_conformance!(
60    unsafe impl UIAppearanceContainer for EKEventEditViewController {}
61);
62
63#[cfg(feature = "objc2-ui-kit")]
64extern_conformance!(
65    unsafe impl UIContentContainer for EKEventEditViewController {}
66);
67
68#[cfg(feature = "objc2-ui-kit")]
69extern_conformance!(
70    unsafe impl UIFocusEnvironment for EKEventEditViewController {}
71);
72
73#[cfg(feature = "objc2-ui-kit")]
74extern_conformance!(
75    unsafe impl UIResponderStandardEditActions for EKEventEditViewController {}
76);
77
78#[cfg(feature = "objc2-ui-kit")]
79extern_conformance!(
80    unsafe impl UITraitEnvironment for EKEventEditViewController {}
81);
82
83#[cfg(feature = "objc2-ui-kit")]
84impl EKEventEditViewController {
85    extern_methods!(
86        #[unsafe(method(editViewDelegate))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn editViewDelegate(
89            &self,
90        ) -> Option<Retained<ProtocolObject<dyn EKEventEditViewDelegate>>>;
91
92        /// Setter for [`editViewDelegate`][Self::editViewDelegate].
93        ///
94        /// This is a [weak property][objc2::topics::weak_property].
95        #[unsafe(method(setEditViewDelegate:))]
96        #[unsafe(method_family = none)]
97        pub unsafe fn setEditViewDelegate(
98            &self,
99            edit_view_delegate: Option<&ProtocolObject<dyn EKEventEditViewDelegate>>,
100        );
101
102        #[cfg(feature = "objc2-event-kit")]
103        /// The event store to use to save events.
104        ///
105        /// You must set this before presenting the view controller.
106        #[unsafe(method(eventStore))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn eventStore(&self) -> Option<Retained<EKEventStore>>;
109
110        #[cfg(feature = "objc2-event-kit")]
111        /// Setter for [`eventStore`][Self::eventStore].
112        ///
113        /// # Safety
114        ///
115        /// `event_store` might not allow `None`.
116        #[unsafe(method(setEventStore:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setEventStore(&self, event_store: Option<&EKEventStore>);
119
120        #[cfg(feature = "objc2-event-kit")]
121        /// The event to edit.
122        ///
123        /// You must set this before presenting the view controller. You can leave
124        /// it set to nil and a new event will be created for you. If you pass an event
125        /// here and it does not belong to the event store (if set) an exception will be
126        /// raised.
127        #[unsafe(method(event))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn event(&self) -> Option<Retained<EKEvent>>;
130
131        #[cfg(feature = "objc2-event-kit")]
132        /// Setter for [`event`][Self::event].
133        #[unsafe(method(setEvent:))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn setEvent(&self, event: Option<&EKEvent>);
136
137        /// Ends the editing session discarding any changes to the event.
138        ///
139        /// This method simulates the user tapping the Cancel button. The delegate will not
140        /// receive the eventEditViewController:didCompleteWithAction: message, so you are
141        /// responsible for dismissing the controller after calling this method.
142        #[unsafe(method(cancelEditing))]
143        #[unsafe(method_family = none)]
144        pub unsafe fn cancelEditing(&self);
145    );
146}
147
148/// Methods declared on superclass `UINavigationController`.
149#[cfg(feature = "objc2-ui-kit")]
150impl EKEventEditViewController {
151    extern_methods!(
152        /// # Safety
153        ///
154        /// - `navigation_bar_class` probably has further requirements.
155        /// - `toolbar_class` probably has further requirements.
156        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
157        #[unsafe(method_family = init)]
158        pub unsafe fn initWithNavigationBarClass_toolbarClass(
159            this: Allocated<Self>,
160            navigation_bar_class: Option<&AnyClass>,
161            toolbar_class: Option<&AnyClass>,
162        ) -> Retained<Self>;
163
164        #[unsafe(method(initWithRootViewController:))]
165        #[unsafe(method_family = init)]
166        pub unsafe fn initWithRootViewController(
167            this: Allocated<Self>,
168            root_view_controller: &UIViewController,
169        ) -> Retained<Self>;
170
171        #[unsafe(method(initWithNibName:bundle:))]
172        #[unsafe(method_family = init)]
173        pub unsafe fn initWithNibName_bundle(
174            this: Allocated<Self>,
175            nib_name_or_nil: Option<&NSString>,
176            nib_bundle_or_nil: Option<&NSBundle>,
177        ) -> Retained<Self>;
178
179        /// # Safety
180        ///
181        /// `a_decoder` possibly has further requirements.
182        #[unsafe(method(initWithCoder:))]
183        #[unsafe(method_family = init)]
184        pub unsafe fn initWithCoder(
185            this: Allocated<Self>,
186            a_decoder: &NSCoder,
187        ) -> Option<Retained<Self>>;
188    );
189}
190
191/// Methods declared on superclass `NSObject`.
192#[cfg(feature = "objc2-ui-kit")]
193impl EKEventEditViewController {
194    extern_methods!(
195        #[unsafe(method(init))]
196        #[unsafe(method_family = init)]
197        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
198
199        #[unsafe(method(new))]
200        #[unsafe(method_family = new)]
201        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
202    );
203}
204
205extern_protocol!(
206    /// View controller to create/edit events.
207    ///
208    /// You can present this view controller to create a new event or edit an existing
209    /// event. You should present it modally. To create a new event, you can either pass
210    /// nil for the event parameter or pass a partially constructed event. If the event
211    /// you pass has no calendar set, the default calendar as set in Settings will be used.
212    ///
213    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewdelegate?language=objc)
214    pub unsafe trait EKEventEditViewDelegate: NSObjectProtocol {
215        #[cfg(feature = "objc2-ui-kit")]
216        /// Called to let delegate know the controller is done editing.
217        ///
218        /// When the user presses Cancel, presses Done, or deletes the event, this method
219        /// is called. Your delegate is responsible for dismissing the controller. If the editing
220        /// session is terminated programmatically using cancelEditing,
221        /// this method will not be called.
222        ///
223        ///
224        /// Parameter `controller`: the controller in question
225        ///
226        /// Parameter `action`: the action that is causing the dismissal
227        #[unsafe(method(eventEditViewController:didCompleteWithAction:))]
228        #[unsafe(method_family = none)]
229        unsafe fn eventEditViewController_didCompleteWithAction(
230            &self,
231            controller: &EKEventEditViewController,
232            action: EKEventEditViewAction,
233        );
234
235        #[cfg(all(feature = "objc2-event-kit", feature = "objc2-ui-kit"))]
236        /// Allows you to supply your own default calendar for new events.
237        ///
238        /// This delegate method allows you to control what the editor chooses for the default calendar
239        /// if it needs to fill in a calendar. This might be necessary if you either don't pass an initial
240        /// event to the view controller, or you do, but you did not supply a calendar. In these cases, we
241        /// we set the calendar to a default. If this is not implemented by the delegate, the controller
242        /// will use the store's defaultCalendarForNewEvents.
243        #[optional]
244        #[unsafe(method(eventEditViewControllerDefaultCalendarForNewEvents:))]
245        #[unsafe(method_family = none)]
246        unsafe fn eventEditViewControllerDefaultCalendarForNewEvents(
247            &self,
248            controller: &EKEventEditViewController,
249        ) -> Retained<EKCalendar>;
250    }
251);