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"))]
56extern_conformance!(
57    unsafe impl NSCoding for NSTabViewController {}
58);
59
60#[cfg(all(
61    feature = "NSKeyValueBinding",
62    feature = "NSResponder",
63    feature = "NSViewController"
64))]
65extern_conformance!(
66    unsafe impl NSEditor for NSTabViewController {}
67);
68
69#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
70extern_conformance!(
71    unsafe impl NSObjectProtocol for NSTabViewController {}
72);
73
74#[cfg(all(
75    feature = "NSResponder",
76    feature = "NSStoryboardSegue",
77    feature = "NSViewController"
78))]
79extern_conformance!(
80    unsafe impl NSSeguePerforming for NSTabViewController {}
81);
82
83#[cfg(all(
84    feature = "NSResponder",
85    feature = "NSTabView",
86    feature = "NSViewController"
87))]
88extern_conformance!(
89    unsafe impl NSTabViewDelegate for NSTabViewController {}
90);
91
92#[cfg(all(
93    feature = "NSResponder",
94    feature = "NSToolbar",
95    feature = "NSViewController"
96))]
97extern_conformance!(
98    unsafe impl NSToolbarDelegate for NSTabViewController {}
99);
100
101#[cfg(all(
102    feature = "NSResponder",
103    feature = "NSUserInterfaceItemIdentification",
104    feature = "NSViewController"
105))]
106extern_conformance!(
107    unsafe impl NSUserInterfaceItemIdentification for NSTabViewController {}
108);
109
110#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
111impl NSTabViewController {
112    extern_methods!(
113        /// The style that this NSTabViewController displays its UI as. Defaults to
114        /// `NSTabViewControllerTabStyleSegmentedControlOnTop.`
115        #[unsafe(method(tabStyle))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn tabStyle(&self) -> NSTabViewControllerTabStyle;
118
119        /// Setter for [`tabStyle`][Self::tabStyle].
120        #[unsafe(method(setTabStyle:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setTabStyle(&self, tab_style: NSTabViewControllerTabStyle);
123
124        #[cfg(all(feature = "NSTabView", feature = "NSView"))]
125        /// Access to the tab view that the controller is controlling. To provide a custom NSTabView, assign the value anytime before
126        /// `self.viewLoaded`is
127        /// `YES.`Querying the value will create it on-demand, if needed. Check
128        /// `self.viewLoaded`before querying the value to avoid prematurely creating the view. Note that the
129        /// `-tabView`may not be equal to the
130        /// `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.
131        #[unsafe(method(tabView))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn tabView(&self) -> Retained<NSTabView>;
134
135        #[cfg(all(feature = "NSTabView", feature = "NSView"))]
136        /// Setter for [`tabView`][Self::tabView].
137        #[unsafe(method(setTabView:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn setTabView(&self, tab_view: &NSTabView);
140
141        /// This defines how NSTabViewController transitions from one view to another. Transitions go through [self transitionFromViewController:toViewController:options:completionHandler:]. The default value is
142        /// `NSViewControllerTransitionCrossfade|NSViewControllerTransitionAllowUserInteraction.`
143        #[unsafe(method(transitionOptions))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn transitionOptions(&self) -> NSViewControllerTransitionOptions;
146
147        /// Setter for [`transitionOptions`][Self::transitionOptions].
148        #[unsafe(method(setTransitionOptions:))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn setTransitionOptions(
151            &self,
152            transition_options: NSViewControllerTransitionOptions,
153        );
154
155        /// If YES and the receiving NSTabViewController has a nil title,
156        /// `-title`will return its selected child ViewController's title. If NO, it will continue to return nil. The default value is
157        /// `YES.`
158        #[unsafe(method(canPropagateSelectedChildViewControllerTitle))]
159        #[unsafe(method_family = none)]
160        pub unsafe fn canPropagateSelectedChildViewControllerTitle(&self) -> bool;
161
162        /// Setter for [`canPropagateSelectedChildViewControllerTitle`][Self::canPropagateSelectedChildViewControllerTitle].
163        #[unsafe(method(setCanPropagateSelectedChildViewControllerTitle:))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn setCanPropagateSelectedChildViewControllerTitle(
166            &self,
167            can_propagate_selected_child_view_controller_title: bool,
168        );
169
170        #[cfg(feature = "NSTabViewItem")]
171        /// 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.
172        #[unsafe(method(tabViewItems))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn tabViewItems(&self) -> Retained<NSArray<NSTabViewItem>>;
175
176        #[cfg(feature = "NSTabViewItem")]
177        /// Setter for [`tabViewItems`][Self::tabViewItems].
178        #[unsafe(method(setTabViewItems:))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn setTabViewItems(&self, tab_view_items: &NSArray<NSTabViewItem>);
181
182        /// 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:
183        ///
184        /// ```text
185        ///  [segmentedControl bind:NSSelectedIndexBinding toObject:tabViewController withKeyPath:@“selectedTabViewItemIndex" options:nil];
186        /// ```
187        #[unsafe(method(selectedTabViewItemIndex))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn selectedTabViewItemIndex(&self) -> NSInteger;
190
191        /// Setter for [`selectedTabViewItemIndex`][Self::selectedTabViewItemIndex].
192        #[unsafe(method(setSelectedTabViewItemIndex:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn setSelectedTabViewItemIndex(&self, selected_tab_view_item_index: NSInteger);
195
196        #[cfg(feature = "NSTabViewItem")]
197        /// Adds a TabViewItem to the end of the TabViewController. The tabViewItem’s viewController’s view will only be loaded once its tab is selected.
198        ///
199        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
200        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
201        #[unsafe(method(addTabViewItem:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn addTabViewItem(&self, tab_view_item: &NSTabViewItem);
204
205        #[cfg(feature = "NSTabViewItem")]
206        /// 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.
207        /// `-selectedTabViewItemIndex`will be adjusted if the insertion index is before it. Subclasses must call through
208        /// `-insertTabViewItem:atIndex:`to add a TabViewItem.
209        ///
210        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
211        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
212        ///
213        /// Parameter `index`: The index to add the TabViewItem at. Will throw an exception if
214        /// `index`<
215        /// 0 or
216        /// `index`>
217        /// `tabViewItems.count`
218        #[unsafe(method(insertTabViewItem:atIndex:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn insertTabViewItem_atIndex(
221            &self,
222            tab_view_item: &NSTabViewItem,
223            index: NSInteger,
224        );
225
226        #[cfg(feature = "NSTabViewItem")]
227        /// 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
228        /// `-1.`Subclasses must call through
229        /// `-removeTabViewItem:`to remove a TabViewItem.
230        ///
231        /// Parameter `tabViewItem`: The TabViewItem to remove. An exception will be thrown if
232        /// `tabViewItem`is not in the NSTabViewController or if it is nil.
233        #[unsafe(method(removeTabViewItem:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn removeTabViewItem(&self, tab_view_item: &NSTabViewItem);
236
237        #[cfg(feature = "NSTabViewItem")]
238        /// Convenience method for getting the associated tab view item for a particular childViewController.
239        ///
240        /// Parameter `viewController`: The ViewController to look up.
241        ///
242        /// Returns: The corresponding TabViewItem. Returns nil if
243        /// `viewController`is not a child of the TabViewController.
244        #[unsafe(method(tabViewItemForViewController:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn tabViewItemForViewController(
247            &self,
248            view_controller: &NSViewController,
249        ) -> Option<Retained<NSTabViewItem>>;
250
251        #[unsafe(method(viewDidLoad))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn viewDidLoad(&self);
254
255        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
256        #[unsafe(method(tabView:willSelectTabViewItem:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn tabView_willSelectTabViewItem(
259            &self,
260            tab_view: &NSTabView,
261            tab_view_item: Option<&NSTabViewItem>,
262        );
263
264        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
265        #[unsafe(method(tabView:didSelectTabViewItem:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn tabView_didSelectTabViewItem(
268            &self,
269            tab_view: &NSTabView,
270            tab_view_item: Option<&NSTabViewItem>,
271        );
272
273        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
274        #[unsafe(method(tabView:shouldSelectTabViewItem:))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn tabView_shouldSelectTabViewItem(
277            &self,
278            tab_view: &NSTabView,
279            tab_view_item: Option<&NSTabViewItem>,
280        ) -> bool;
281
282        #[cfg(all(feature = "NSToolbar", feature = "NSToolbarItem"))]
283        #[unsafe(method(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:))]
284        #[unsafe(method_family = none)]
285        pub unsafe fn toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(
286            &self,
287            toolbar: &NSToolbar,
288            item_identifier: &NSToolbarItemIdentifier,
289            flag: bool,
290        ) -> Option<Retained<NSToolbarItem>>;
291
292        #[cfg(feature = "NSToolbar")]
293        #[unsafe(method(toolbarDefaultItemIdentifiers:))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn toolbarDefaultItemIdentifiers(
296            &self,
297            toolbar: &NSToolbar,
298        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
299
300        #[cfg(feature = "NSToolbar")]
301        #[unsafe(method(toolbarAllowedItemIdentifiers:))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn toolbarAllowedItemIdentifiers(
304            &self,
305            toolbar: &NSToolbar,
306        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
307
308        #[cfg(feature = "NSToolbar")]
309        #[unsafe(method(toolbarSelectableItemIdentifiers:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn toolbarSelectableItemIdentifiers(
312            &self,
313            toolbar: &NSToolbar,
314        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
315    );
316}
317
318/// Methods declared on superclass `NSViewController`.
319#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
320impl NSTabViewController {
321    extern_methods!(
322        #[cfg(feature = "NSNib")]
323        #[unsafe(method(initWithNibName:bundle:))]
324        #[unsafe(method_family = init)]
325        pub unsafe fn initWithNibName_bundle(
326            this: Allocated<Self>,
327            nib_name_or_nil: Option<&NSNibName>,
328            nib_bundle_or_nil: Option<&NSBundle>,
329        ) -> Retained<Self>;
330
331        #[unsafe(method(initWithCoder:))]
332        #[unsafe(method_family = init)]
333        pub unsafe fn initWithCoder(
334            this: Allocated<Self>,
335            coder: &NSCoder,
336        ) -> Option<Retained<Self>>;
337    );
338}
339
340/// Methods declared on superclass `NSResponder`.
341#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
342impl NSTabViewController {
343    extern_methods!(
344        #[unsafe(method(init))]
345        #[unsafe(method_family = init)]
346        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
347    );
348}
349
350/// Methods declared on superclass `NSObject`.
351#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
352impl NSTabViewController {
353    extern_methods!(
354        #[unsafe(method(new))]
355        #[unsafe(method_family = new)]
356        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
357    );
358}