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        /// This is a [weak property][objc2::topics::weak_property].
93        /// Setter for [`editViewDelegate`][Self::editViewDelegate].
94        #[unsafe(method(setEditViewDelegate:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setEditViewDelegate(
97            &self,
98            edit_view_delegate: Option<&ProtocolObject<dyn EKEventEditViewDelegate>>,
99        );
100
101        #[cfg(feature = "objc2-event-kit")]
102        /// The event store to use to save events.
103        ///
104        /// You must set this before presenting the view controller.
105        #[unsafe(method(eventStore))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn eventStore(&self) -> Option<Retained<EKEventStore>>;
108
109        #[cfg(feature = "objc2-event-kit")]
110        /// Setter for [`eventStore`][Self::eventStore].
111        #[unsafe(method(setEventStore:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setEventStore(&self, event_store: Option<&EKEventStore>);
114
115        #[cfg(feature = "objc2-event-kit")]
116        /// The event to edit.
117        ///
118        /// You must set this before presenting the view controller. You can leave
119        /// it set to nil and a new event will be created for you. If you pass an event
120        /// here and it does not belong to the event store (if set) an exception will be
121        /// raised.
122        #[unsafe(method(event))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn event(&self) -> Option<Retained<EKEvent>>;
125
126        #[cfg(feature = "objc2-event-kit")]
127        /// Setter for [`event`][Self::event].
128        #[unsafe(method(setEvent:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setEvent(&self, event: Option<&EKEvent>);
131
132        /// Ends the editing session discarding any changes to the event.
133        ///
134        /// This method simulates the user tapping the Cancel button. The delegate will not
135        /// receive the eventEditViewController:didCompleteWithAction: message, so you are
136        /// responsible for dismissing the controller after calling this method.
137        #[unsafe(method(cancelEditing))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn cancelEditing(&self);
140    );
141}
142
143/// Methods declared on superclass `UINavigationController`.
144#[cfg(feature = "objc2-ui-kit")]
145impl EKEventEditViewController {
146    extern_methods!(
147        #[unsafe(method(initWithNavigationBarClass:toolbarClass:))]
148        #[unsafe(method_family = init)]
149        pub unsafe fn initWithNavigationBarClass_toolbarClass(
150            this: Allocated<Self>,
151            navigation_bar_class: Option<&AnyClass>,
152            toolbar_class: Option<&AnyClass>,
153        ) -> Retained<Self>;
154
155        #[unsafe(method(initWithRootViewController:))]
156        #[unsafe(method_family = init)]
157        pub unsafe fn initWithRootViewController(
158            this: Allocated<Self>,
159            root_view_controller: &UIViewController,
160        ) -> Retained<Self>;
161
162        #[unsafe(method(initWithNibName:bundle:))]
163        #[unsafe(method_family = init)]
164        pub unsafe fn initWithNibName_bundle(
165            this: Allocated<Self>,
166            nib_name_or_nil: Option<&NSString>,
167            nib_bundle_or_nil: Option<&NSBundle>,
168        ) -> Retained<Self>;
169
170        #[unsafe(method(initWithCoder:))]
171        #[unsafe(method_family = init)]
172        pub unsafe fn initWithCoder(
173            this: Allocated<Self>,
174            a_decoder: &NSCoder,
175        ) -> Option<Retained<Self>>;
176    );
177}
178
179/// Methods declared on superclass `NSObject`.
180#[cfg(feature = "objc2-ui-kit")]
181impl EKEventEditViewController {
182    extern_methods!(
183        #[unsafe(method(init))]
184        #[unsafe(method_family = init)]
185        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
186
187        #[unsafe(method(new))]
188        #[unsafe(method_family = new)]
189        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
190    );
191}
192
193extern_protocol!(
194    /// View controller to create/edit events.
195    ///
196    /// You can present this view controller to create a new event or edit an existing
197    /// event. You should present it modally. To create a new event, you can either pass
198    /// nil for the event parameter or pass a partially constructed event. If the event
199    /// you pass has no calendar set, the default calendar as set in Settings will be used.
200    ///
201    /// See also [Apple's documentation](https://developer.apple.com/documentation/eventkitui/ekeventeditviewdelegate?language=objc)
202    pub unsafe trait EKEventEditViewDelegate: NSObjectProtocol {
203        #[cfg(feature = "objc2-ui-kit")]
204        /// Called to let delegate know the controller is done editing.
205        ///
206        /// When the user presses Cancel, presses Done, or deletes the event, this method
207        /// is called. Your delegate is responsible for dismissing the controller. If the editing
208        /// session is terminated programmatically using cancelEditing,
209        /// this method will not be called.
210        ///
211        ///
212        /// Parameter `controller`: the controller in question
213        ///
214        /// Parameter `action`: the action that is causing the dismissal
215        #[unsafe(method(eventEditViewController:didCompleteWithAction:))]
216        #[unsafe(method_family = none)]
217        unsafe fn eventEditViewController_didCompleteWithAction(
218            &self,
219            controller: &EKEventEditViewController,
220            action: EKEventEditViewAction,
221        );
222
223        #[cfg(all(feature = "objc2-event-kit", feature = "objc2-ui-kit"))]
224        /// Allows you to supply your own default calendar for new events.
225        ///
226        /// This delegate method allows you to control what the editor chooses for the default calendar
227        /// if it needs to fill in a calendar. This might be necessary if you either don't pass an initial
228        /// event to the view controller, or you do, but you did not supply a calendar. In these cases, we
229        /// we set the calendar to a default. If this is not implemented by the delegate, the controller
230        /// will use the store's defaultCalendarForNewEvents.
231        #[optional]
232        #[unsafe(method(eventEditViewControllerDefaultCalendarForNewEvents:))]
233        #[unsafe(method_family = none)]
234        unsafe fn eventEditViewControllerDefaultCalendarForNewEvents(
235            &self,
236            controller: &EKEventEditViewController,
237        ) -> Retained<EKCalendar>;
238    }
239);