objc2_app_kit/generated/
NSTabViewController.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/nstabviewcontrollertabstyle?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTabViewControllerTabStyle(pub NSInteger);
15impl NSTabViewControllerTabStyle {
16    /// Uses an NSSegmentedControl to show the UI for the tabs. The control is on the top of the view.
17    #[doc(alias = "NSTabViewControllerTabStyleSegmentedControlOnTop")]
18    pub const SegmentedControlOnTop: Self = Self(0);
19    /// Uses an NSSegmentedControl to show the UI for the tabs. The control is on the bottom of the view.
20    #[doc(alias = "NSTabViewControllerTabStyleSegmentedControlOnBottom")]
21    pub const SegmentedControlOnBottom: Self = Self(1);
22    /// Automatically pushes the tabs into the window's toolbar as toolbar items, if non-nil. This style will cause the TabViewController to set its containing window's toolbar to its own and become that toolbar's delegate. The toolbar items can be customized or supplemented by overriding the relevant NSToolbarDelegate methods.
23    #[doc(alias = "NSTabViewControllerTabStyleToolbar")]
24    pub const Toolbar: Self = Self(2);
25    /// NSTabViewController will not provide any of its own tab control UI. Separate UI, such as a NSSegmentedControl or NSPopupButton, can be easily bound to the TabViewController. Or
26    /// `tabView.tabViewType`can be changed for the TabView itself to draw the UI.
27    #[doc(alias = "NSTabViewControllerTabStyleUnspecified")]
28    pub const Unspecified: Self = Self(-1);
29}
30
31unsafe impl Encode for NSTabViewControllerTabStyle {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for NSTabViewControllerTabStyle {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// NSTabViewController is a container view controller that displays a single child view controller at a time from its
41    /// `childViewControllers.`It provides standard tab-style UI for user selection of tabs, or allows custom UI to be easily created by providing targets for bindings.
42    /// ChildViewControllers’ views are lazily loaded; they are only loaded once their tab is selected and visible.
43    /// The NSTabViewController is set as the delegate of its managed NSTabView. Any overrides of NSTabViewDelegate methods must call super. Properties of the TabView such as the tabStyle can be directly manipulated, but calling methods that add and remove tabViewItems or changing the delegate is not allowed.
44    /// NSViewController's methods
45    /// `-addChildViewController:,``-insertViewController:atIndex:,`and
46    /// `-removeChildViewControllerAtIndex:`can all be used as convience methods to add children; default TabViewItems will be appropriately created or destroyed. The default NSTabViewItem created with with +[NSTabViewItem tabViewItemForViewController:].
47    ///
48    /// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstabviewcontroller?language=objc)
49    #[unsafe(super(NSViewController, NSResponder, NSObject))]
50    #[derive(Debug, PartialEq, Eq, Hash)]
51    #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
52    pub struct NSTabViewController;
53);
54
55#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
56unsafe impl NSCoding for NSTabViewController {}
57
58#[cfg(all(
59    feature = "NSKeyValueBinding",
60    feature = "NSResponder",
61    feature = "NSViewController"
62))]
63unsafe impl NSEditor for NSTabViewController {}
64
65#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
66unsafe impl NSObjectProtocol for NSTabViewController {}
67
68#[cfg(all(
69    feature = "NSResponder",
70    feature = "NSStoryboardSegue",
71    feature = "NSViewController"
72))]
73unsafe impl NSSeguePerforming for NSTabViewController {}
74
75#[cfg(all(
76    feature = "NSResponder",
77    feature = "NSTabView",
78    feature = "NSViewController"
79))]
80unsafe impl NSTabViewDelegate for NSTabViewController {}
81
82#[cfg(all(
83    feature = "NSResponder",
84    feature = "NSToolbar",
85    feature = "NSViewController"
86))]
87unsafe impl NSToolbarDelegate for NSTabViewController {}
88
89#[cfg(all(
90    feature = "NSResponder",
91    feature = "NSUserInterfaceItemIdentification",
92    feature = "NSViewController"
93))]
94unsafe impl NSUserInterfaceItemIdentification for NSTabViewController {}
95
96#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
97impl NSTabViewController {
98    extern_methods!(
99        /// The style that this NSTabViewController displays its UI as. Defaults to
100        /// `NSTabViewControllerTabStyleSegmentedControlOnTop.`
101        #[unsafe(method(tabStyle))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn tabStyle(&self) -> NSTabViewControllerTabStyle;
104
105        /// Setter for [`tabStyle`][Self::tabStyle].
106        #[unsafe(method(setTabStyle:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setTabStyle(&self, tab_style: NSTabViewControllerTabStyle);
109
110        #[cfg(all(feature = "NSTabView", feature = "NSView"))]
111        /// Access to the tab view that the controller is controlling. To provide a custom NSTabView, assign the value anytime before
112        /// `self.viewLoaded`is
113        /// `YES.`Querying the value will create it on-demand, if needed. Check
114        /// `self.viewLoaded`before querying the value to avoid prematurely creating the view. Note that the
115        /// `-tabView`may not be equal to the
116        /// `viewController.view.`Properties such as the tabStyle can be directly manipulated, but calling methods that add and remove tabViewItems or changing the delegate is not allowed. The NSTabViewController will be made the delegate of the NSTabView. Internally, the NSTabView is always used to switch between displayed childViewControllers, regardless of the style displayed.
117        #[unsafe(method(tabView))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn tabView(&self) -> Retained<NSTabView>;
120
121        #[cfg(all(feature = "NSTabView", feature = "NSView"))]
122        /// Setter for [`tabView`][Self::tabView].
123        #[unsafe(method(setTabView:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setTabView(&self, tab_view: &NSTabView);
126
127        /// This defines how NSTabViewController transitions from one view to another. Transitions go through [self transitionFromViewController:toViewController:options:completionHandler:]. The default value is
128        /// `NSViewControllerTransitionCrossfade|NSViewControllerTransitionAllowUserInteraction.`
129        #[unsafe(method(transitionOptions))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn transitionOptions(&self) -> NSViewControllerTransitionOptions;
132
133        /// Setter for [`transitionOptions`][Self::transitionOptions].
134        #[unsafe(method(setTransitionOptions:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn setTransitionOptions(
137            &self,
138            transition_options: NSViewControllerTransitionOptions,
139        );
140
141        /// If YES and the receiving NSTabViewController has a nil title,
142        /// `-title`will return its selected child ViewController's title. If NO, it will continue to return nil. The default value is
143        /// `YES.`
144        #[unsafe(method(canPropagateSelectedChildViewControllerTitle))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn canPropagateSelectedChildViewControllerTitle(&self) -> bool;
147
148        /// Setter for [`canPropagateSelectedChildViewControllerTitle`][Self::canPropagateSelectedChildViewControllerTitle].
149        #[unsafe(method(setCanPropagateSelectedChildViewControllerTitle:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setCanPropagateSelectedChildViewControllerTitle(
152            &self,
153            can_propagate_selected_child_view_controller_title: bool,
154        );
155
156        #[cfg(feature = "NSTabViewItem")]
157        /// The array of tab view items that correspond to the current child view controllers. After a child view controller is added to the receiving TabViewController, a NSTabViewItem with the default values will be created for it. Once the child is removed, its corresponding tabViewItem will be removed from the tabViewItems array.
158        #[unsafe(method(tabViewItems))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn tabViewItems(&self) -> Retained<NSArray<NSTabViewItem>>;
161
162        #[cfg(feature = "NSTabViewItem")]
163        /// Setter for [`tabViewItems`][Self::tabViewItems].
164        #[unsafe(method(setTabViewItems:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setTabViewItems(&self, tab_view_items: &NSArray<NSTabViewItem>);
167
168        /// Read and write the current selected TabViewItem that is being shown. This value is KVC compliant and can be the target of a binding. For instance, a NSSegmentedControl's selection can be bound to this value with:
169        ///
170        /// ```text
171        ///  [segmentedControl bind:NSSelectedIndexBinding toObject:tabViewController withKeyPath:@“selectedTabViewItemIndex" options:nil];
172        /// ```
173        #[unsafe(method(selectedTabViewItemIndex))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn selectedTabViewItemIndex(&self) -> NSInteger;
176
177        /// Setter for [`selectedTabViewItemIndex`][Self::selectedTabViewItemIndex].
178        #[unsafe(method(setSelectedTabViewItemIndex:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setSelectedTabViewItemIndex(&self, selected_tab_view_item_index: NSInteger);
181
182        #[cfg(feature = "NSTabViewItem")]
183        /// Adds a TabViewItem to the end of the TabViewController. The tabViewItem’s viewController’s view will only be loaded once its tab is selected.
184        ///
185        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
186        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
187        #[unsafe(method(addTabViewItem:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn addTabViewItem(&self, tab_view_item: &NSTabViewItem);
190
191        #[cfg(feature = "NSTabViewItem")]
192        /// Adds a TabViewItem to a given index in the TabViewController. The tabViewItem’s viewController’s view will only be loaded once its tab is selected.
193        /// `-selectedTabViewItemIndex`will be adjusted if the insertion index is before it. Subclasses must call through
194        /// `-insertTabViewItem:atIndex:`to add a TabViewItem.
195        ///
196        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
197        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
198        ///
199        /// Parameter `index`: The index to add the TabViewItem at. Will throw an exception if
200        /// `index`<
201        /// 0 or
202        /// `index`>
203        /// `tabViewItems.count`
204        #[unsafe(method(insertTabViewItem:atIndex:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn insertTabViewItem_atIndex(
207            &self,
208            tab_view_item: &NSTabViewItem,
209            index: NSInteger,
210        );
211
212        #[cfg(feature = "NSTabViewItem")]
213        /// Removes a TabViewItem from the receiver. If the removed tabViewItem currently selected, the next (or previous, if there is no next) tabViewItem will become selected. If this is the only tabViewItem in the TabViewController, the selectedTabViewItemIndex will become
214        /// `-1.`Subclasses must call through
215        /// `-removeTabViewItem:`to remove a TabViewItem.
216        ///
217        /// Parameter `tabViewItem`: The TabViewItem to remove. An exception will be thrown if
218        /// `tabViewItem`is not in the NSTabViewController or if it is nil.
219        #[unsafe(method(removeTabViewItem:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn removeTabViewItem(&self, tab_view_item: &NSTabViewItem);
222
223        #[cfg(feature = "NSTabViewItem")]
224        /// Convenience method for getting the associated tab view item for a particular childViewController.
225        ///
226        /// Parameter `viewController`: The ViewController to look up.
227        ///
228        /// Returns: The corresponding TabViewItem. Returns nil if
229        /// `viewController`is not a child of the TabViewController.
230        #[unsafe(method(tabViewItemForViewController:))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn tabViewItemForViewController(
233            &self,
234            view_controller: &NSViewController,
235        ) -> Option<Retained<NSTabViewItem>>;
236
237        #[unsafe(method(viewDidLoad))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn viewDidLoad(&self);
240
241        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
242        #[unsafe(method(tabView:willSelectTabViewItem:))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn tabView_willSelectTabViewItem(
245            &self,
246            tab_view: &NSTabView,
247            tab_view_item: Option<&NSTabViewItem>,
248        );
249
250        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
251        #[unsafe(method(tabView:didSelectTabViewItem:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn tabView_didSelectTabViewItem(
254            &self,
255            tab_view: &NSTabView,
256            tab_view_item: Option<&NSTabViewItem>,
257        );
258
259        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
260        #[unsafe(method(tabView:shouldSelectTabViewItem:))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn tabView_shouldSelectTabViewItem(
263            &self,
264            tab_view: &NSTabView,
265            tab_view_item: Option<&NSTabViewItem>,
266        ) -> bool;
267
268        #[cfg(all(feature = "NSToolbar", feature = "NSToolbarItem"))]
269        #[unsafe(method(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(
272            &self,
273            toolbar: &NSToolbar,
274            item_identifier: &NSToolbarItemIdentifier,
275            flag: bool,
276        ) -> Option<Retained<NSToolbarItem>>;
277
278        #[cfg(feature = "NSToolbar")]
279        #[unsafe(method(toolbarDefaultItemIdentifiers:))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn toolbarDefaultItemIdentifiers(
282            &self,
283            toolbar: &NSToolbar,
284        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
285
286        #[cfg(feature = "NSToolbar")]
287        #[unsafe(method(toolbarAllowedItemIdentifiers:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn toolbarAllowedItemIdentifiers(
290            &self,
291            toolbar: &NSToolbar,
292        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
293
294        #[cfg(feature = "NSToolbar")]
295        #[unsafe(method(toolbarSelectableItemIdentifiers:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn toolbarSelectableItemIdentifiers(
298            &self,
299            toolbar: &NSToolbar,
300        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
301    );
302}
303
304/// Methods declared on superclass `NSViewController`.
305#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
306impl NSTabViewController {
307    extern_methods!(
308        #[cfg(feature = "NSNib")]
309        #[unsafe(method(initWithNibName:bundle:))]
310        #[unsafe(method_family = init)]
311        pub unsafe fn initWithNibName_bundle(
312            this: Allocated<Self>,
313            nib_name_or_nil: Option<&NSNibName>,
314            nib_bundle_or_nil: Option<&NSBundle>,
315        ) -> Retained<Self>;
316
317        #[unsafe(method(initWithCoder:))]
318        #[unsafe(method_family = init)]
319        pub unsafe fn initWithCoder(
320            this: Allocated<Self>,
321            coder: &NSCoder,
322        ) -> Option<Retained<Self>>;
323    );
324}
325
326/// Methods declared on superclass `NSResponder`.
327#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
328impl NSTabViewController {
329    extern_methods!(
330        #[unsafe(method(init))]
331        #[unsafe(method_family = init)]
332        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
333    );
334}
335
336/// Methods declared on superclass `NSObject`.
337#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
338impl NSTabViewController {
339    extern_methods!(
340        #[unsafe(method(new))]
341        #[unsafe(method_family = new)]
342        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
343    );
344}