1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10#[cfg(feature = "NSApplication")]
12pub static NSAppKitVersionNumberWithDirectionalTabs: NSAppKitVersion = 631.0 as _;
13
14#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct NSTabViewType(pub NSUInteger);
19impl NSTabViewType {
20 #[doc(alias = "NSTopTabsBezelBorder")]
21 pub const TopTabsBezelBorder: Self = Self(0);
22 #[doc(alias = "NSLeftTabsBezelBorder")]
23 pub const LeftTabsBezelBorder: Self = Self(1);
24 #[doc(alias = "NSBottomTabsBezelBorder")]
25 pub const BottomTabsBezelBorder: Self = Self(2);
26 #[doc(alias = "NSRightTabsBezelBorder")]
27 pub const RightTabsBezelBorder: Self = Self(3);
28 #[doc(alias = "NSNoTabsBezelBorder")]
29 pub const NoTabsBezelBorder: Self = Self(4);
30 #[doc(alias = "NSNoTabsLineBorder")]
31 pub const NoTabsLineBorder: Self = Self(5);
32 #[doc(alias = "NSNoTabsNoBorder")]
33 pub const NoTabsNoBorder: Self = Self(6);
34}
35
36unsafe impl Encode for NSTabViewType {
37 const ENCODING: Encoding = NSUInteger::ENCODING;
38}
39
40unsafe impl RefEncode for NSTabViewType {
41 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct NSTabPosition(pub NSUInteger);
49impl NSTabPosition {
50 #[doc(alias = "NSTabPositionNone")]
51 pub const None: Self = Self(0);
52 #[doc(alias = "NSTabPositionTop")]
53 pub const Top: Self = Self(1);
54 #[doc(alias = "NSTabPositionLeft")]
55 pub const Left: Self = Self(2);
56 #[doc(alias = "NSTabPositionBottom")]
57 pub const Bottom: Self = Self(3);
58 #[doc(alias = "NSTabPositionRight")]
59 pub const Right: Self = Self(4);
60}
61
62unsafe impl Encode for NSTabPosition {
63 const ENCODING: Encoding = NSUInteger::ENCODING;
64}
65
66unsafe impl RefEncode for NSTabPosition {
67 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
68}
69
70#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct NSTabViewBorderType(pub NSUInteger);
75impl NSTabViewBorderType {
76 #[doc(alias = "NSTabViewBorderTypeNone")]
77 pub const None: Self = Self(0);
78 #[doc(alias = "NSTabViewBorderTypeLine")]
79 pub const Line: Self = Self(1);
80 #[doc(alias = "NSTabViewBorderTypeBezel")]
81 pub const Bezel: Self = Self(2);
82}
83
84unsafe impl Encode for NSTabViewBorderType {
85 const ENCODING: Encoding = NSUInteger::ENCODING;
86}
87
88unsafe impl RefEncode for NSTabViewBorderType {
89 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
90}
91
92extern_class!(
93 #[unsafe(super(NSView, NSResponder, NSObject))]
95 #[derive(Debug, PartialEq, Eq, Hash)]
96 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
97 pub struct NSTabView;
98);
99
100#[cfg(all(
101 feature = "NSAccessibilityProtocols",
102 feature = "NSResponder",
103 feature = "NSView"
104))]
105extern_conformance!(
106 unsafe impl NSAccessibility for NSTabView {}
107);
108
109#[cfg(all(
110 feature = "NSAccessibilityProtocols",
111 feature = "NSResponder",
112 feature = "NSView"
113))]
114extern_conformance!(
115 unsafe impl NSAccessibilityElementProtocol for NSTabView {}
116);
117
118#[cfg(all(feature = "NSAnimation", feature = "NSResponder", feature = "NSView"))]
119extern_conformance!(
120 unsafe impl NSAnimatablePropertyContainer for NSTabView {}
121);
122
123#[cfg(all(feature = "NSAppearance", feature = "NSResponder", feature = "NSView"))]
124extern_conformance!(
125 unsafe impl NSAppearanceCustomization for NSTabView {}
126);
127
128#[cfg(all(feature = "NSResponder", feature = "NSView"))]
129extern_conformance!(
130 unsafe impl NSCoding for NSTabView {}
131);
132
133#[cfg(all(feature = "NSDragging", feature = "NSResponder", feature = "NSView"))]
134extern_conformance!(
135 unsafe impl NSDraggingDestination for NSTabView {}
136);
137
138#[cfg(all(feature = "NSResponder", feature = "NSView"))]
139extern_conformance!(
140 unsafe impl NSObjectProtocol for NSTabView {}
141);
142
143#[cfg(all(
144 feature = "NSResponder",
145 feature = "NSUserInterfaceItemIdentification",
146 feature = "NSView"
147))]
148extern_conformance!(
149 unsafe impl NSUserInterfaceItemIdentification for NSTabView {}
150);
151
152#[cfg(all(feature = "NSResponder", feature = "NSView"))]
153impl NSTabView {
154 extern_methods!(
155 #[cfg(feature = "NSTabViewItem")]
156 #[unsafe(method(selectTabViewItem:))]
157 #[unsafe(method_family = none)]
158 pub fn selectTabViewItem(&self, tab_view_item: Option<&NSTabViewItem>);
159
160 #[unsafe(method(selectTabViewItemAtIndex:))]
161 #[unsafe(method_family = none)]
162 pub fn selectTabViewItemAtIndex(&self, index: NSInteger);
163
164 #[unsafe(method(selectTabViewItemWithIdentifier:))]
168 #[unsafe(method_family = none)]
169 pub unsafe fn selectTabViewItemWithIdentifier(&self, identifier: &AnyObject);
170
171 #[unsafe(method(takeSelectedTabViewItemFromSender:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn takeSelectedTabViewItemFromSender(&self, sender: Option<&AnyObject>);
177
178 #[unsafe(method(selectFirstTabViewItem:))]
182 #[unsafe(method_family = none)]
183 pub unsafe fn selectFirstTabViewItem(&self, sender: Option<&AnyObject>);
184
185 #[unsafe(method(selectLastTabViewItem:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn selectLastTabViewItem(&self, sender: Option<&AnyObject>);
191
192 #[unsafe(method(selectNextTabViewItem:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn selectNextTabViewItem(&self, sender: Option<&AnyObject>);
198
199 #[unsafe(method(selectPreviousTabViewItem:))]
203 #[unsafe(method_family = none)]
204 pub unsafe fn selectPreviousTabViewItem(&self, sender: Option<&AnyObject>);
205
206 #[cfg(feature = "NSTabViewItem")]
207 #[unsafe(method(selectedTabViewItem))]
208 #[unsafe(method_family = none)]
209 pub fn selectedTabViewItem(&self) -> Option<Retained<NSTabViewItem>>;
210
211 #[cfg(feature = "NSFont")]
212 #[unsafe(method(font))]
213 #[unsafe(method_family = none)]
214 pub fn font(&self) -> Retained<NSFont>;
215
216 #[cfg(feature = "NSFont")]
217 #[unsafe(method(setFont:))]
219 #[unsafe(method_family = none)]
220 pub fn setFont(&self, font: &NSFont);
221
222 #[unsafe(method(tabViewType))]
223 #[unsafe(method_family = none)]
224 pub fn tabViewType(&self) -> NSTabViewType;
225
226 #[unsafe(method(setTabViewType:))]
228 #[unsafe(method_family = none)]
229 pub fn setTabViewType(&self, tab_view_type: NSTabViewType);
230
231 #[unsafe(method(tabPosition))]
232 #[unsafe(method_family = none)]
233 pub fn tabPosition(&self) -> NSTabPosition;
234
235 #[unsafe(method(setTabPosition:))]
237 #[unsafe(method_family = none)]
238 pub fn setTabPosition(&self, tab_position: NSTabPosition);
239
240 #[unsafe(method(tabViewBorderType))]
241 #[unsafe(method_family = none)]
242 pub fn tabViewBorderType(&self) -> NSTabViewBorderType;
243
244 #[unsafe(method(setTabViewBorderType:))]
246 #[unsafe(method_family = none)]
247 pub fn setTabViewBorderType(&self, tab_view_border_type: NSTabViewBorderType);
248
249 #[cfg(feature = "NSTabViewItem")]
250 #[unsafe(method(tabViewItems))]
251 #[unsafe(method_family = none)]
252 pub fn tabViewItems(&self) -> Retained<NSArray<NSTabViewItem>>;
253
254 #[cfg(feature = "NSTabViewItem")]
255 #[unsafe(method(setTabViewItems:))]
259 #[unsafe(method_family = none)]
260 pub fn setTabViewItems(&self, tab_view_items: &NSArray<NSTabViewItem>);
261
262 #[unsafe(method(allowsTruncatedLabels))]
263 #[unsafe(method_family = none)]
264 pub fn allowsTruncatedLabels(&self) -> bool;
265
266 #[unsafe(method(setAllowsTruncatedLabels:))]
268 #[unsafe(method_family = none)]
269 pub fn setAllowsTruncatedLabels(&self, allows_truncated_labels: bool);
270
271 #[unsafe(method(minimumSize))]
272 #[unsafe(method_family = none)]
273 pub fn minimumSize(&self) -> NSSize;
274
275 #[unsafe(method(drawsBackground))]
276 #[unsafe(method_family = none)]
277 pub fn drawsBackground(&self) -> bool;
278
279 #[unsafe(method(setDrawsBackground:))]
281 #[unsafe(method_family = none)]
282 pub fn setDrawsBackground(&self, draws_background: bool);
283
284 #[cfg(feature = "NSCell")]
285 #[unsafe(method(controlSize))]
286 #[unsafe(method_family = none)]
287 pub fn controlSize(&self) -> NSControlSize;
288
289 #[cfg(feature = "NSCell")]
290 #[unsafe(method(setControlSize:))]
292 #[unsafe(method_family = none)]
293 pub fn setControlSize(&self, control_size: NSControlSize);
294
295 #[cfg(feature = "NSTabViewItem")]
296 #[unsafe(method(addTabViewItem:))]
297 #[unsafe(method_family = none)]
298 pub fn addTabViewItem(&self, tab_view_item: &NSTabViewItem);
299
300 #[cfg(feature = "NSTabViewItem")]
301 #[unsafe(method(insertTabViewItem:atIndex:))]
302 #[unsafe(method_family = none)]
303 pub fn insertTabViewItem_atIndex(&self, tab_view_item: &NSTabViewItem, index: NSInteger);
304
305 #[cfg(feature = "NSTabViewItem")]
306 #[unsafe(method(removeTabViewItem:))]
307 #[unsafe(method_family = none)]
308 pub fn removeTabViewItem(&self, tab_view_item: &NSTabViewItem);
309
310 #[unsafe(method(delegate))]
311 #[unsafe(method_family = none)]
312 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTabViewDelegate>>>;
313
314 #[unsafe(method(setDelegate:))]
318 #[unsafe(method_family = none)]
319 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTabViewDelegate>>);
320
321 #[cfg(feature = "NSTabViewItem")]
322 #[unsafe(method(tabViewItemAtPoint:))]
323 #[unsafe(method_family = none)]
324 pub fn tabViewItemAtPoint(&self, point: NSPoint) -> Option<Retained<NSTabViewItem>>;
325
326 #[unsafe(method(contentRect))]
327 #[unsafe(method_family = none)]
328 pub fn contentRect(&self) -> NSRect;
329
330 #[unsafe(method(numberOfTabViewItems))]
331 #[unsafe(method_family = none)]
332 pub fn numberOfTabViewItems(&self) -> NSInteger;
333
334 #[cfg(feature = "NSTabViewItem")]
335 #[unsafe(method(indexOfTabViewItem:))]
336 #[unsafe(method_family = none)]
337 pub fn indexOfTabViewItem(&self, tab_view_item: &NSTabViewItem) -> NSInteger;
338
339 #[cfg(feature = "NSTabViewItem")]
340 #[unsafe(method(tabViewItemAtIndex:))]
341 #[unsafe(method_family = none)]
342 pub fn tabViewItemAtIndex(&self, index: NSInteger) -> Retained<NSTabViewItem>;
343
344 #[unsafe(method(indexOfTabViewItemWithIdentifier:))]
348 #[unsafe(method_family = none)]
349 pub unsafe fn indexOfTabViewItemWithIdentifier(&self, identifier: &AnyObject) -> NSInteger;
350
351 #[cfg(feature = "NSCell")]
352 #[deprecated = "The controlTint property is not respected on 10.14 and later."]
353 #[unsafe(method(controlTint))]
354 #[unsafe(method_family = none)]
355 pub fn controlTint(&self) -> NSControlTint;
356
357 #[cfg(feature = "NSCell")]
358 #[deprecated = "The controlTint property is not respected on 10.14 and later."]
360 #[unsafe(method(setControlTint:))]
361 #[unsafe(method_family = none)]
362 pub fn setControlTint(&self, control_tint: NSControlTint);
363 );
364}
365
366#[cfg(all(feature = "NSResponder", feature = "NSView"))]
368impl NSTabView {
369 extern_methods!(
370 #[unsafe(method(initWithFrame:))]
371 #[unsafe(method_family = init)]
372 pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
373
374 #[unsafe(method(initWithCoder:))]
378 #[unsafe(method_family = init)]
379 pub unsafe fn initWithCoder(
380 this: Allocated<Self>,
381 coder: &NSCoder,
382 ) -> Option<Retained<Self>>;
383 );
384}
385
386#[cfg(all(feature = "NSResponder", feature = "NSView"))]
388impl NSTabView {
389 extern_methods!(
390 #[unsafe(method(init))]
391 #[unsafe(method_family = init)]
392 pub fn init(this: Allocated<Self>) -> Retained<Self>;
393 );
394}
395
396#[cfg(all(feature = "NSResponder", feature = "NSView"))]
398impl NSTabView {
399 extern_methods!(
400 #[unsafe(method(new))]
401 #[unsafe(method_family = new)]
402 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
403 );
404}
405
406extern_protocol!(
407 pub unsafe trait NSTabViewDelegate: NSObjectProtocol + MainThreadOnly {
409 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
410 #[optional]
411 #[unsafe(method(tabView:shouldSelectTabViewItem:))]
412 #[unsafe(method_family = none)]
413 fn tabView_shouldSelectTabViewItem(
414 &self,
415 tab_view: &NSTabView,
416 tab_view_item: Option<&NSTabViewItem>,
417 ) -> bool;
418
419 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
420 #[optional]
421 #[unsafe(method(tabView:willSelectTabViewItem:))]
422 #[unsafe(method_family = none)]
423 fn tabView_willSelectTabViewItem(
424 &self,
425 tab_view: &NSTabView,
426 tab_view_item: Option<&NSTabViewItem>,
427 );
428
429 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
430 #[optional]
431 #[unsafe(method(tabView:didSelectTabViewItem:))]
432 #[unsafe(method_family = none)]
433 fn tabView_didSelectTabViewItem(
434 &self,
435 tab_view: &NSTabView,
436 tab_view_item: Option<&NSTabViewItem>,
437 );
438
439 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
440 #[optional]
441 #[unsafe(method(tabViewDidChangeNumberOfTabViewItems:))]
442 #[unsafe(method_family = none)]
443 fn tabViewDidChangeNumberOfTabViewItems(&self, tab_view: &NSTabView);
444 }
445);