objc2_app_kit/generated/
NSTabViewItem.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/nstabstate?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct NSTabState(pub NSUInteger);
15impl NSTabState {
16    #[doc(alias = "NSSelectedTab")]
17    pub const SelectedTab: Self = Self(0);
18    #[doc(alias = "NSBackgroundTab")]
19    pub const BackgroundTab: Self = Self(1);
20    #[doc(alias = "NSPressedTab")]
21    pub const PressedTab: Self = Self(2);
22}
23
24unsafe impl Encode for NSTabState {
25    const ENCODING: Encoding = NSUInteger::ENCODING;
26}
27
28unsafe impl RefEncode for NSTabState {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32extern_class!(
33    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstabviewitem?language=objc)
34    #[unsafe(super(NSObject))]
35    #[derive(Debug, PartialEq, Eq, Hash)]
36    pub struct NSTabViewItem;
37);
38
39extern_conformance!(
40    unsafe impl NSCoding for NSTabViewItem {}
41);
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for NSTabViewItem {}
45);
46
47impl NSTabViewItem {
48    extern_methods!(
49        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
50        /// Creates an autoreleased TabViewItem that wraps the provided ViewController. The viewController is set as the tab view item’s
51        /// `-viewController`property, which sets several of the tab view item’s other properties.
52        ///
53        /// Parameter `viewController`: The view controller to wrap, used to set the viewController property
54        #[unsafe(method(tabViewItemWithViewController:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn tabViewItemWithViewController(
57            view_controller: &NSViewController,
58        ) -> Retained<Self>;
59
60        #[unsafe(method(initWithIdentifier:))]
61        #[unsafe(method_family = init)]
62        pub unsafe fn initWithIdentifier(
63            this: Allocated<Self>,
64            identifier: Option<&AnyObject>,
65        ) -> Retained<Self>;
66
67        #[unsafe(method(identifier))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn identifier(&self) -> Option<Retained<AnyObject>>;
70
71        /// Setter for [`identifier`][Self::identifier].
72        #[unsafe(method(setIdentifier:))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn setIdentifier(&self, identifier: Option<&AnyObject>);
75
76        #[cfg(feature = "NSColor")]
77        #[unsafe(method(color))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn color(&self) -> Retained<NSColor>;
80
81        #[cfg(feature = "NSColor")]
82        /// Setter for [`color`][Self::color].
83        #[unsafe(method(setColor:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setColor(&self, color: &NSColor);
86
87        #[unsafe(method(label))]
88        #[unsafe(method_family = none)]
89        pub unsafe fn label(&self) -> Retained<NSString>;
90
91        /// Setter for [`label`][Self::label].
92        #[unsafe(method(setLabel:))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn setLabel(&self, label: &NSString);
95
96        #[cfg(feature = "NSImage")]
97        /// Get and set the image for this tab view item. The image may only be used in certain tab view styles and options.  The default value is nil.
98        #[unsafe(method(image))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
101
102        #[cfg(feature = "NSImage")]
103        /// Setter for [`image`][Self::image].
104        #[unsafe(method(setImage:))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn setImage(&self, image: Option<&NSImage>);
107
108        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
109        #[unsafe(method(view))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
112
113        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
114        /// Setter for [`view`][Self::view].
115        #[unsafe(method(setView:))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn setView(&self, view: Option<&NSView>);
118
119        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
120        /// The view controller wrapped by the tab view item. This property must be set if the tab view item will be added to an NSTabViewController, but can also be used if the tab view item is added to an NSTabView.
121        /// If this is set, the tab view item will forward
122        /// `-view`calls onto the viewController. Setting a viewController will also set the following properties on the tab view item:
123        /// `-identifier`from the address of the viewController,
124        /// `-label`from the viewController's title, and
125        /// `-image`based on the classname as the view controller.
126        /// An image named "ViewControllerClassName-TabViewItem" will be searched for first, followed by "ViewControllerClassName". It will search first using +[NSImage imageNamed:], then in
127        /// `viewController.nibBundle,`and lastly in the bundle containing the view controller's class.
128        /// As defined by: -[NSImage imageNamed:imageName], -[viewController.nibBundle imageForResource:imageName], -[[NSBundle bundleForClass:[viewController class]] imageForResource:imageName]. One pass with imageName as [NSStringFromClass([viewController class]) stringByAppendingString:
129        /// "
130        /// -TabViewItem"], followed by imageName as NSStringFromClass([viewController class]).
131        #[unsafe(method(viewController))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn viewController(
134            &self,
135            mtm: MainThreadMarker,
136        ) -> Option<Retained<NSViewController>>;
137
138        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
139        /// Setter for [`viewController`][Self::viewController].
140        #[unsafe(method(setViewController:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setViewController(&self, view_controller: Option<&NSViewController>);
143
144        #[unsafe(method(tabState))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn tabState(&self) -> NSTabState;
147
148        #[cfg(all(feature = "NSResponder", feature = "NSTabView", feature = "NSView"))]
149        #[unsafe(method(tabView))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn tabView(&self, mtm: MainThreadMarker) -> Option<Retained<NSTabView>>;
152
153        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
154        #[unsafe(method(initialFirstResponder))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn initialFirstResponder(
157            &self,
158            mtm: MainThreadMarker,
159        ) -> Option<Retained<NSView>>;
160
161        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
162        /// This is a [weak property][objc2::topics::weak_property].
163        /// Setter for [`initialFirstResponder`][Self::initialFirstResponder].
164        #[unsafe(method(setInitialFirstResponder:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setInitialFirstResponder(&self, initial_first_responder: Option<&NSView>);
167
168        #[unsafe(method(toolTip))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
171
172        /// Setter for [`toolTip`][Self::toolTip].
173        #[unsafe(method(setToolTip:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
176
177        #[unsafe(method(drawLabel:inRect:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn drawLabel_inRect(&self, should_truncate_label: bool, label_rect: NSRect);
180
181        #[unsafe(method(sizeOfLabel:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn sizeOfLabel(&self, compute_min: bool) -> NSSize;
184    );
185}
186
187/// Methods declared on superclass `NSObject`.
188impl NSTabViewItem {
189    extern_methods!(
190        #[unsafe(method(init))]
191        #[unsafe(method_family = init)]
192        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
193
194        #[unsafe(method(new))]
195        #[unsafe(method_family = new)]
196        pub unsafe fn new() -> Retained<Self>;
197    );
198}