objc2_app_kit/generated/
NSViewController.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsviewcontrollertransitionoptions?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSViewControllerTransitionOptions(pub NSUInteger);
15bitflags::bitflags! {
16    impl NSViewControllerTransitionOptions: NSUInteger {
17        #[doc(alias = "NSViewControllerTransitionNone")]
18        const None = 0x0;
19        #[doc(alias = "NSViewControllerTransitionCrossfade")]
20        const Crossfade = 0x1;
21        #[doc(alias = "NSViewControllerTransitionSlideUp")]
22        const SlideUp = 0x10;
23        #[doc(alias = "NSViewControllerTransitionSlideDown")]
24        const SlideDown = 0x20;
25        #[doc(alias = "NSViewControllerTransitionSlideLeft")]
26        const SlideLeft = 0x40;
27        #[doc(alias = "NSViewControllerTransitionSlideRight")]
28        const SlideRight = 0x80;
29        #[doc(alias = "NSViewControllerTransitionSlideForward")]
30        const SlideForward = 0x140;
31        #[doc(alias = "NSViewControllerTransitionSlideBackward")]
32        const SlideBackward = 0x180;
33        #[doc(alias = "NSViewControllerTransitionAllowUserInteraction")]
34        const AllowUserInteraction = 0x1000;
35    }
36}
37
38unsafe impl Encode for NSViewControllerTransitionOptions {
39    const ENCODING: Encoding = NSUInteger::ENCODING;
40}
41
42unsafe impl RefEncode for NSViewControllerTransitionOptions {
43    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
44}
45
46extern_class!(
47    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsviewcontroller?language=objc)
48    #[unsafe(super(NSResponder, NSObject))]
49    #[derive(Debug, PartialEq, Eq, Hash)]
50    #[cfg(feature = "NSResponder")]
51    pub struct NSViewController;
52);
53
54#[cfg(feature = "NSResponder")]
55unsafe impl NSCoding for NSViewController {}
56
57#[cfg(all(feature = "NSKeyValueBinding", feature = "NSResponder"))]
58unsafe impl NSEditor for NSViewController {}
59
60#[cfg(feature = "NSResponder")]
61unsafe impl NSObjectProtocol for NSViewController {}
62
63#[cfg(all(feature = "NSResponder", feature = "NSStoryboardSegue"))]
64unsafe impl NSSeguePerforming for NSViewController {}
65
66#[cfg(all(feature = "NSResponder", feature = "NSUserInterfaceItemIdentification"))]
67unsafe impl NSUserInterfaceItemIdentification for NSViewController {}
68
69#[cfg(feature = "NSResponder")]
70impl NSViewController {
71    extern_methods!(
72        #[cfg(feature = "NSNib")]
73        #[unsafe(method(initWithNibName:bundle:))]
74        #[unsafe(method_family = init)]
75        pub unsafe fn initWithNibName_bundle(
76            this: Allocated<Self>,
77            nib_name_or_nil: Option<&NSNibName>,
78            nib_bundle_or_nil: Option<&NSBundle>,
79        ) -> Retained<Self>;
80
81        #[unsafe(method(initWithCoder:))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn initWithCoder(
84            this: Allocated<Self>,
85            coder: &NSCoder,
86        ) -> Option<Retained<Self>>;
87
88        #[cfg(feature = "NSNib")]
89        #[unsafe(method(nibName))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn nibName(&self) -> Option<Retained<NSNibName>>;
92
93        #[unsafe(method(nibBundle))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn nibBundle(&self) -> Option<Retained<NSBundle>>;
96
97        #[unsafe(method(representedObject))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn representedObject(&self) -> Option<Retained<AnyObject>>;
100
101        /// Setter for [`representedObject`][Self::representedObject].
102        #[unsafe(method(setRepresentedObject:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setRepresentedObject(&self, represented_object: Option<&AnyObject>);
105
106        #[unsafe(method(title))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn title(&self) -> Option<Retained<NSString>>;
109
110        /// Setter for [`title`][Self::title].
111        #[unsafe(method(setTitle:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setTitle(&self, title: Option<&NSString>);
114
115        #[cfg(feature = "NSView")]
116        #[unsafe(method(view))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn view(&self) -> Retained<NSView>;
119
120        #[cfg(feature = "NSView")]
121        /// Setter for [`view`][Self::view].
122        #[unsafe(method(setView:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setView(&self, view: &NSView);
125
126        #[cfg(feature = "NSView")]
127        #[unsafe(method(viewIfLoaded))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn viewIfLoaded(&self) -> Option<Retained<NSView>>;
130
131        #[unsafe(method(loadView))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn loadView(&self);
134
135        #[unsafe(method(loadViewIfNeeded))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn loadViewIfNeeded(&self);
138
139        #[unsafe(method(commitEditingWithDelegate:didCommitSelector:contextInfo:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn commitEditingWithDelegate_didCommitSelector_contextInfo(
142            &self,
143            delegate: Option<&AnyObject>,
144            did_commit_selector: Option<Sel>,
145            context_info: *mut c_void,
146        );
147
148        #[unsafe(method(commitEditing))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn commitEditing(&self) -> bool;
151
152        #[unsafe(method(discardEditing))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn discardEditing(&self);
155
156        #[unsafe(method(viewDidLoad))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn viewDidLoad(&self);
159
160        #[unsafe(method(isViewLoaded))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn isViewLoaded(&self) -> bool;
163
164        #[unsafe(method(viewWillAppear))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn viewWillAppear(&self);
167
168        #[unsafe(method(viewDidAppear))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn viewDidAppear(&self);
171
172        #[unsafe(method(viewWillDisappear))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn viewWillDisappear(&self);
175
176        #[unsafe(method(viewDidDisappear))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn viewDidDisappear(&self);
179
180        #[unsafe(method(preferredContentSize))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn preferredContentSize(&self) -> NSSize;
183
184        /// Setter for [`preferredContentSize`][Self::preferredContentSize].
185        #[unsafe(method(setPreferredContentSize:))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn setPreferredContentSize(&self, preferred_content_size: NSSize);
188
189        #[unsafe(method(updateViewConstraints))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn updateViewConstraints(&self);
192
193        #[unsafe(method(viewWillLayout))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn viewWillLayout(&self);
196
197        #[unsafe(method(viewDidLayout))]
198        #[unsafe(method_family = none)]
199        pub unsafe fn viewDidLayout(&self);
200    );
201}
202
203/// Methods declared on superclass `NSResponder`.
204#[cfg(feature = "NSResponder")]
205impl NSViewController {
206    extern_methods!(
207        #[unsafe(method(init))]
208        #[unsafe(method_family = init)]
209        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
210    );
211}
212
213/// Methods declared on superclass `NSObject`.
214#[cfg(feature = "NSResponder")]
215impl NSViewController {
216    extern_methods!(
217        #[unsafe(method(new))]
218        #[unsafe(method_family = new)]
219        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
220    );
221}
222
223/// NSViewControllerPresentation.
224#[cfg(feature = "NSResponder")]
225impl NSViewController {
226    extern_methods!(
227        #[unsafe(method(presentViewController:animator:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn presentViewController_animator(
230            &self,
231            view_controller: &NSViewController,
232            animator: &ProtocolObject<dyn NSViewControllerPresentationAnimator>,
233        );
234
235        #[unsafe(method(dismissViewController:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn dismissViewController(&self, view_controller: &NSViewController);
238
239        #[unsafe(method(dismissController:))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn dismissController(&self, sender: Option<&AnyObject>);
242
243        #[unsafe(method(presentedViewControllers))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn presentedViewControllers(
246            &self,
247        ) -> Option<Retained<NSArray<NSViewController>>>;
248
249        #[unsafe(method(presentingViewController))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn presentingViewController(&self) -> Option<Retained<NSViewController>>;
252    );
253}
254
255/// NSViewControllerPresentationAndTransitionStyles.
256#[cfg(feature = "NSResponder")]
257impl NSViewController {
258    extern_methods!(
259        #[unsafe(method(presentViewControllerAsSheet:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn presentViewControllerAsSheet(&self, view_controller: &NSViewController);
262
263        #[unsafe(method(presentViewControllerAsModalWindow:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn presentViewControllerAsModalWindow(&self, view_controller: &NSViewController);
266
267        #[cfg(all(feature = "NSPopover", feature = "NSView"))]
268        #[unsafe(method(presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn presentViewController_asPopoverRelativeToRect_ofView_preferredEdge_behavior(
271            &self,
272            view_controller: &NSViewController,
273            positioning_rect: NSRect,
274            positioning_view: &NSView,
275            preferred_edge: NSRectEdge,
276            behavior: NSPopoverBehavior,
277        );
278
279        #[cfg(all(feature = "NSPopover", feature = "NSView"))]
280        #[unsafe(method(presentViewController:asPopoverRelativeToRect:ofView:preferredEdge:behavior:hasFullSizeContent:))]
281        #[unsafe(method_family = none)]
282        pub unsafe fn presentViewController_asPopoverRelativeToRect_ofView_preferredEdge_behavior_hasFullSizeContent(
283            &self,
284            view_controller: &NSViewController,
285            positioning_rect: NSRect,
286            positioning_view: &NSView,
287            preferred_edge: NSRectEdge,
288            behavior: NSPopoverBehavior,
289            has_full_size_content: bool,
290        );
291
292        #[cfg(feature = "block2")]
293        #[unsafe(method(transitionFromViewController:toViewController:options:completionHandler:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn transitionFromViewController_toViewController_options_completionHandler(
296            &self,
297            from_view_controller: &NSViewController,
298            to_view_controller: &NSViewController,
299            options: NSViewControllerTransitionOptions,
300            completion: Option<&block2::Block<dyn Fn()>>,
301        );
302    );
303}
304
305/// NSViewControllerContainer.
306#[cfg(feature = "NSResponder")]
307impl NSViewController {
308    extern_methods!(
309        #[unsafe(method(parentViewController))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn parentViewController(&self) -> Option<Retained<NSViewController>>;
312
313        #[unsafe(method(childViewControllers))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn childViewControllers(&self) -> Retained<NSArray<NSViewController>>;
316
317        /// Setter for [`childViewControllers`][Self::childViewControllers].
318        #[unsafe(method(setChildViewControllers:))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn setChildViewControllers(
321            &self,
322            child_view_controllers: &NSArray<NSViewController>,
323        );
324
325        #[unsafe(method(addChildViewController:))]
326        #[unsafe(method_family = none)]
327        pub unsafe fn addChildViewController(&self, child_view_controller: &NSViewController);
328
329        #[unsafe(method(removeFromParentViewController))]
330        #[unsafe(method_family = none)]
331        pub unsafe fn removeFromParentViewController(&self);
332
333        #[unsafe(method(insertChildViewController:atIndex:))]
334        #[unsafe(method_family = none)]
335        pub unsafe fn insertChildViewController_atIndex(
336            &self,
337            child_view_controller: &NSViewController,
338            index: NSInteger,
339        );
340
341        #[unsafe(method(removeChildViewControllerAtIndex:))]
342        #[unsafe(method_family = none)]
343        pub unsafe fn removeChildViewControllerAtIndex(&self, index: NSInteger);
344
345        #[unsafe(method(preferredContentSizeDidChangeForViewController:))]
346        #[unsafe(method_family = none)]
347        pub unsafe fn preferredContentSizeDidChangeForViewController(
348            &self,
349            view_controller: &NSViewController,
350        );
351
352        #[unsafe(method(viewWillTransitionToSize:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn viewWillTransitionToSize(&self, new_size: NSSize);
355    );
356}
357
358extern_protocol!(
359    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsviewcontrollerpresentationanimator?language=objc)
360    pub unsafe trait NSViewControllerPresentationAnimator:
361        NSObjectProtocol + MainThreadOnly
362    {
363        #[cfg(feature = "NSResponder")]
364        #[unsafe(method(animatePresentationOfViewController:fromViewController:))]
365        #[unsafe(method_family = none)]
366        unsafe fn animatePresentationOfViewController_fromViewController(
367            &self,
368            view_controller: &NSViewController,
369            from_view_controller: &NSViewController,
370        );
371
372        #[cfg(feature = "NSResponder")]
373        #[unsafe(method(animateDismissalOfViewController:fromViewController:))]
374        #[unsafe(method_family = none)]
375        unsafe fn animateDismissalOfViewController_fromViewController(
376            &self,
377            view_controller: &NSViewController,
378            from_view_controller: &NSViewController,
379        );
380    }
381);
382
383/// NSViewControllerStoryboardingMethods.
384#[cfg(feature = "NSResponder")]
385impl NSViewController {
386    extern_methods!(
387        #[cfg(feature = "NSStoryboard")]
388        #[unsafe(method(storyboard))]
389        #[unsafe(method_family = none)]
390        pub unsafe fn storyboard(&self) -> Option<Retained<NSStoryboard>>;
391    );
392}
393
394/// NSExtensionAdditions.
395#[cfg(feature = "NSResponder")]
396impl NSViewController {
397    extern_methods!(
398        #[unsafe(method(extensionContext))]
399        #[unsafe(method_family = none)]
400        pub unsafe fn extensionContext(&self) -> Option<Retained<NSExtensionContext>>;
401
402        #[cfg(feature = "NSView")]
403        #[unsafe(method(sourceItemView))]
404        #[unsafe(method_family = none)]
405        pub unsafe fn sourceItemView(&self) -> Option<Retained<NSView>>;
406
407        #[cfg(feature = "NSView")]
408        /// Setter for [`sourceItemView`][Self::sourceItemView].
409        #[unsafe(method(setSourceItemView:))]
410        #[unsafe(method_family = none)]
411        pub unsafe fn setSourceItemView(&self, source_item_view: Option<&NSView>);
412
413        #[unsafe(method(preferredScreenOrigin))]
414        #[unsafe(method_family = none)]
415        pub unsafe fn preferredScreenOrigin(&self) -> NSPoint;
416
417        /// Setter for [`preferredScreenOrigin`][Self::preferredScreenOrigin].
418        #[unsafe(method(setPreferredScreenOrigin:))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn setPreferredScreenOrigin(&self, preferred_screen_origin: NSPoint);
421
422        #[unsafe(method(preferredMinimumSize))]
423        #[unsafe(method_family = none)]
424        pub unsafe fn preferredMinimumSize(&self) -> NSSize;
425
426        #[unsafe(method(preferredMaximumSize))]
427        #[unsafe(method_family = none)]
428        pub unsafe fn preferredMaximumSize(&self) -> NSSize;
429    );
430}
431
432#[cfg(feature = "NSResponder")]
433unsafe impl NSExtensionRequestHandling for NSViewController {}