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 fn tabStyle(&self) -> NSTabViewControllerTabStyle;
118
119        /// Setter for [`tabStyle`][Self::tabStyle].
120        #[unsafe(method(setTabStyle:))]
121        #[unsafe(method_family = none)]
122        pub 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 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 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 fn transitionOptions(&self) -> NSViewControllerTransitionOptions;
146
147        /// Setter for [`transitionOptions`][Self::transitionOptions].
148        #[unsafe(method(setTransitionOptions:))]
149        #[unsafe(method_family = none)]
150        pub fn setTransitionOptions(&self, transition_options: NSViewControllerTransitionOptions);
151
152        /// If YES and the receiving NSTabViewController has a nil title,
153        /// `-title`will return its selected child ViewController's title. If NO, it will continue to return nil. The default value is
154        /// `YES.`
155        #[unsafe(method(canPropagateSelectedChildViewControllerTitle))]
156        #[unsafe(method_family = none)]
157        pub fn canPropagateSelectedChildViewControllerTitle(&self) -> bool;
158
159        /// Setter for [`canPropagateSelectedChildViewControllerTitle`][Self::canPropagateSelectedChildViewControllerTitle].
160        #[unsafe(method(setCanPropagateSelectedChildViewControllerTitle:))]
161        #[unsafe(method_family = none)]
162        pub fn setCanPropagateSelectedChildViewControllerTitle(
163            &self,
164            can_propagate_selected_child_view_controller_title: bool,
165        );
166
167        #[cfg(feature = "NSTabViewItem")]
168        /// 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.
169        #[unsafe(method(tabViewItems))]
170        #[unsafe(method_family = none)]
171        pub fn tabViewItems(&self) -> Retained<NSArray<NSTabViewItem>>;
172
173        #[cfg(feature = "NSTabViewItem")]
174        /// Setter for [`tabViewItems`][Self::tabViewItems].
175        ///
176        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
177        #[unsafe(method(setTabViewItems:))]
178        #[unsafe(method_family = none)]
179        pub fn setTabViewItems(&self, tab_view_items: &NSArray<NSTabViewItem>);
180
181        /// 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:
182        ///
183        /// ```text
184        ///  [segmentedControl bind:NSSelectedIndexBinding toObject:tabViewController withKeyPath:@“selectedTabViewItemIndex" options:nil];
185        /// ```
186        #[unsafe(method(selectedTabViewItemIndex))]
187        #[unsafe(method_family = none)]
188        pub fn selectedTabViewItemIndex(&self) -> NSInteger;
189
190        /// Setter for [`selectedTabViewItemIndex`][Self::selectedTabViewItemIndex].
191        #[unsafe(method(setSelectedTabViewItemIndex:))]
192        #[unsafe(method_family = none)]
193        pub fn setSelectedTabViewItemIndex(&self, selected_tab_view_item_index: NSInteger);
194
195        #[cfg(feature = "NSTabViewItem")]
196        /// Adds a TabViewItem to the end of the TabViewController. The tabViewItem’s viewController’s view will only be loaded once its tab is selected.
197        ///
198        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
199        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
200        #[unsafe(method(addTabViewItem:))]
201        #[unsafe(method_family = none)]
202        pub fn addTabViewItem(&self, tab_view_item: &NSTabViewItem);
203
204        #[cfg(feature = "NSTabViewItem")]
205        /// 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.
206        /// `-selectedTabViewItemIndex`will be adjusted if the insertion index is before it. Subclasses must call through
207        /// `-insertTabViewItem:atIndex:`to add a TabViewItem.
208        ///
209        /// Parameter `tabViewItem`: The TabViewItem to add. It must have a
210        /// `viewController`set by the time it is added or an exception will be thrown. An exception will also be thrown if tabViewItem is nil.
211        ///
212        /// Parameter `index`: The index to add the TabViewItem at. Will throw an exception if
213        /// `index`<
214        /// 0 or
215        /// `index`>
216        /// `tabViewItems.count`
217        #[unsafe(method(insertTabViewItem:atIndex:))]
218        #[unsafe(method_family = none)]
219        pub fn insertTabViewItem_atIndex(&self, tab_view_item: &NSTabViewItem, index: NSInteger);
220
221        #[cfg(feature = "NSTabViewItem")]
222        /// 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
223        /// `-1.`Subclasses must call through
224        /// `-removeTabViewItem:`to remove a TabViewItem.
225        ///
226        /// Parameter `tabViewItem`: The TabViewItem to remove. An exception will be thrown if
227        /// `tabViewItem`is not in the NSTabViewController or if it is nil.
228        #[unsafe(method(removeTabViewItem:))]
229        #[unsafe(method_family = none)]
230        pub fn removeTabViewItem(&self, tab_view_item: &NSTabViewItem);
231
232        #[cfg(feature = "NSTabViewItem")]
233        /// Convenience method for getting the associated tab view item for a particular childViewController.
234        ///
235        /// Parameter `viewController`: The ViewController to look up.
236        ///
237        /// Returns: The corresponding TabViewItem. Returns nil if
238        /// `viewController`is not a child of the TabViewController.
239        #[unsafe(method(tabViewItemForViewController:))]
240        #[unsafe(method_family = none)]
241        pub fn tabViewItemForViewController(
242            &self,
243            view_controller: &NSViewController,
244        ) -> Option<Retained<NSTabViewItem>>;
245
246        #[unsafe(method(viewDidLoad))]
247        #[unsafe(method_family = none)]
248        pub fn viewDidLoad(&self);
249
250        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
251        #[unsafe(method(tabView:willSelectTabViewItem:))]
252        #[unsafe(method_family = none)]
253        pub fn tabView_willSelectTabViewItem(
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:didSelectTabViewItem:))]
261        #[unsafe(method_family = none)]
262        pub fn tabView_didSelectTabViewItem(
263            &self,
264            tab_view: &NSTabView,
265            tab_view_item: Option<&NSTabViewItem>,
266        );
267
268        #[cfg(all(feature = "NSTabView", feature = "NSTabViewItem", feature = "NSView"))]
269        #[unsafe(method(tabView:shouldSelectTabViewItem:))]
270        #[unsafe(method_family = none)]
271        pub fn tabView_shouldSelectTabViewItem(
272            &self,
273            tab_view: &NSTabView,
274            tab_view_item: Option<&NSTabViewItem>,
275        ) -> bool;
276
277        #[cfg(all(feature = "NSToolbar", feature = "NSToolbarItem"))]
278        #[unsafe(method(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:))]
279        #[unsafe(method_family = none)]
280        pub fn toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(
281            &self,
282            toolbar: &NSToolbar,
283            item_identifier: &NSToolbarItemIdentifier,
284            flag: bool,
285        ) -> Option<Retained<NSToolbarItem>>;
286
287        #[cfg(feature = "NSToolbar")]
288        #[unsafe(method(toolbarDefaultItemIdentifiers:))]
289        #[unsafe(method_family = none)]
290        pub fn toolbarDefaultItemIdentifiers(
291            &self,
292            toolbar: &NSToolbar,
293        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
294
295        #[cfg(feature = "NSToolbar")]
296        #[unsafe(method(toolbarAllowedItemIdentifiers:))]
297        #[unsafe(method_family = none)]
298        pub fn toolbarAllowedItemIdentifiers(
299            &self,
300            toolbar: &NSToolbar,
301        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
302
303        #[cfg(feature = "NSToolbar")]
304        #[unsafe(method(toolbarSelectableItemIdentifiers:))]
305        #[unsafe(method_family = none)]
306        pub fn toolbarSelectableItemIdentifiers(
307            &self,
308            toolbar: &NSToolbar,
309        ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
310    );
311}
312
313/// Methods declared on superclass `NSViewController`.
314#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
315impl NSTabViewController {
316    extern_methods!(
317        #[cfg(feature = "NSNib")]
318        #[unsafe(method(initWithNibName:bundle:))]
319        #[unsafe(method_family = init)]
320        pub fn initWithNibName_bundle(
321            this: Allocated<Self>,
322            nib_name_or_nil: Option<&NSNibName>,
323            nib_bundle_or_nil: Option<&NSBundle>,
324        ) -> Retained<Self>;
325
326        /// # Safety
327        ///
328        /// `coder` possibly has further requirements.
329        #[unsafe(method(initWithCoder:))]
330        #[unsafe(method_family = init)]
331        pub unsafe fn initWithCoder(
332            this: Allocated<Self>,
333            coder: &NSCoder,
334        ) -> Option<Retained<Self>>;
335    );
336}
337
338/// Methods declared on superclass `NSResponder`.
339#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
340impl NSTabViewController {
341    extern_methods!(
342        #[unsafe(method(init))]
343        #[unsafe(method_family = init)]
344        pub fn init(this: Allocated<Self>) -> Retained<Self>;
345    );
346}
347
348/// Methods declared on superclass `NSObject`.
349#[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
350impl NSTabViewController {
351    extern_methods!(
352        #[unsafe(method(new))]
353        #[unsafe(method_family = new)]
354        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
355    );
356}