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
39unsafe impl NSCoding for NSTabViewItem {}
40
41unsafe impl NSObjectProtocol for NSTabViewItem {}
42
43impl NSTabViewItem {
44    extern_methods!(
45        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
46        /// Creates an autoreleased TabViewItem that wraps the provided ViewController. The viewController is set as the tab view item’s
47        /// `-viewController`property, which sets several of the tab view item’s other properties.
48        ///
49        /// Parameter `viewController`: The view controller to wrap, used to set the viewController property
50        #[unsafe(method(tabViewItemWithViewController:))]
51        #[unsafe(method_family = none)]
52        pub unsafe fn tabViewItemWithViewController(
53            view_controller: &NSViewController,
54        ) -> Retained<Self>;
55
56        #[unsafe(method(initWithIdentifier:))]
57        #[unsafe(method_family = init)]
58        pub unsafe fn initWithIdentifier(
59            this: Allocated<Self>,
60            identifier: Option<&AnyObject>,
61        ) -> Retained<Self>;
62
63        #[unsafe(method(identifier))]
64        #[unsafe(method_family = none)]
65        pub unsafe fn identifier(&self) -> Option<Retained<AnyObject>>;
66
67        /// Setter for [`identifier`][Self::identifier].
68        #[unsafe(method(setIdentifier:))]
69        #[unsafe(method_family = none)]
70        pub unsafe fn setIdentifier(&self, identifier: Option<&AnyObject>);
71
72        #[cfg(feature = "NSColor")]
73        #[unsafe(method(color))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn color(&self) -> Retained<NSColor>;
76
77        #[cfg(feature = "NSColor")]
78        /// Setter for [`color`][Self::color].
79        #[unsafe(method(setColor:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn setColor(&self, color: &NSColor);
82
83        #[unsafe(method(label))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn label(&self) -> Retained<NSString>;
86
87        /// Setter for [`label`][Self::label].
88        #[unsafe(method(setLabel:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setLabel(&self, label: &NSString);
91
92        #[cfg(feature = "NSImage")]
93        /// 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.
94        #[unsafe(method(image))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
97
98        #[cfg(feature = "NSImage")]
99        /// Setter for [`image`][Self::image].
100        #[unsafe(method(setImage:))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn setImage(&self, image: Option<&NSImage>);
103
104        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
105        #[unsafe(method(view))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
108
109        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
110        /// Setter for [`view`][Self::view].
111        #[unsafe(method(setView:))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn setView(&self, view: Option<&NSView>);
114
115        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
116        /// 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.
117        /// If this is set, the tab view item will forward
118        /// `-view`calls onto the viewController. Setting a viewController will also set the following properties on the tab view item:
119        /// `-identifier`from the address of the viewController,
120        /// `-label`from the viewController's title, and
121        /// `-image`based on the classname as the view controller.
122        /// An image named "ViewControllerClassName-TabViewItem" will be searched for first, followed by "ViewControllerClassName". It will search first using +[NSImage imageNamed:], then in
123        /// `viewController.nibBundle,`and lastly in the bundle containing the view controller's class.
124        /// 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:
125        /// "
126        /// -TabViewItem"], followed by imageName as NSStringFromClass([viewController class]).
127        #[unsafe(method(viewController))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn viewController(
130            &self,
131            mtm: MainThreadMarker,
132        ) -> Option<Retained<NSViewController>>;
133
134        #[cfg(all(feature = "NSResponder", feature = "NSViewController"))]
135        /// Setter for [`viewController`][Self::viewController].
136        #[unsafe(method(setViewController:))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn setViewController(&self, view_controller: Option<&NSViewController>);
139
140        #[unsafe(method(tabState))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn tabState(&self) -> NSTabState;
143
144        #[cfg(all(feature = "NSResponder", feature = "NSTabView", feature = "NSView"))]
145        #[unsafe(method(tabView))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn tabView(&self, mtm: MainThreadMarker) -> Option<Retained<NSTabView>>;
148
149        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
150        #[unsafe(method(initialFirstResponder))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn initialFirstResponder(
153            &self,
154            mtm: MainThreadMarker,
155        ) -> Option<Retained<NSView>>;
156
157        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
158        /// This is a [weak property][objc2::topics::weak_property].
159        /// Setter for [`initialFirstResponder`][Self::initialFirstResponder].
160        #[unsafe(method(setInitialFirstResponder:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setInitialFirstResponder(&self, initial_first_responder: Option<&NSView>);
163
164        #[unsafe(method(toolTip))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn toolTip(&self) -> Option<Retained<NSString>>;
167
168        /// Setter for [`toolTip`][Self::toolTip].
169        #[unsafe(method(setToolTip:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setToolTip(&self, tool_tip: Option<&NSString>);
172
173        #[unsafe(method(drawLabel:inRect:))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn drawLabel_inRect(&self, should_truncate_label: bool, label_rect: NSRect);
176
177        #[unsafe(method(sizeOfLabel:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn sizeOfLabel(&self, compute_min: bool) -> NSSize;
180    );
181}
182
183/// Methods declared on superclass `NSObject`.
184impl NSTabViewItem {
185    extern_methods!(
186        #[unsafe(method(init))]
187        #[unsafe(method_family = init)]
188        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
189
190        #[unsafe(method(new))]
191        #[unsafe(method_family = new)]
192        pub unsafe fn new() -> Retained<Self>;
193    );
194}