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