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 unsafe fn selectTabViewItem(&self, tab_view_item: Option<&NSTabViewItem>);
159
160 #[unsafe(method(selectTabViewItemAtIndex:))]
161 #[unsafe(method_family = none)]
162 pub unsafe fn selectTabViewItemAtIndex(&self, index: NSInteger);
163
164 #[unsafe(method(selectTabViewItemWithIdentifier:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn selectTabViewItemWithIdentifier(&self, identifier: &AnyObject);
167
168 #[unsafe(method(takeSelectedTabViewItemFromSender:))]
169 #[unsafe(method_family = none)]
170 pub unsafe fn takeSelectedTabViewItemFromSender(&self, sender: Option<&AnyObject>);
171
172 #[unsafe(method(selectFirstTabViewItem:))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn selectFirstTabViewItem(&self, sender: Option<&AnyObject>);
175
176 #[unsafe(method(selectLastTabViewItem:))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn selectLastTabViewItem(&self, sender: Option<&AnyObject>);
179
180 #[unsafe(method(selectNextTabViewItem:))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn selectNextTabViewItem(&self, sender: Option<&AnyObject>);
183
184 #[unsafe(method(selectPreviousTabViewItem:))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn selectPreviousTabViewItem(&self, sender: Option<&AnyObject>);
187
188 #[cfg(feature = "NSTabViewItem")]
189 #[unsafe(method(selectedTabViewItem))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn selectedTabViewItem(&self) -> Option<Retained<NSTabViewItem>>;
192
193 #[cfg(feature = "NSFont")]
194 #[unsafe(method(font))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn font(&self) -> Retained<NSFont>;
197
198 #[cfg(feature = "NSFont")]
199 #[unsafe(method(setFont:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setFont(&self, font: &NSFont);
203
204 #[unsafe(method(tabViewType))]
205 #[unsafe(method_family = none)]
206 pub unsafe fn tabViewType(&self) -> NSTabViewType;
207
208 #[unsafe(method(setTabViewType:))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn setTabViewType(&self, tab_view_type: NSTabViewType);
212
213 #[unsafe(method(tabPosition))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn tabPosition(&self) -> NSTabPosition;
216
217 #[unsafe(method(setTabPosition:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn setTabPosition(&self, tab_position: NSTabPosition);
221
222 #[unsafe(method(tabViewBorderType))]
223 #[unsafe(method_family = none)]
224 pub unsafe fn tabViewBorderType(&self) -> NSTabViewBorderType;
225
226 #[unsafe(method(setTabViewBorderType:))]
228 #[unsafe(method_family = none)]
229 pub unsafe fn setTabViewBorderType(&self, tab_view_border_type: NSTabViewBorderType);
230
231 #[cfg(feature = "NSTabViewItem")]
232 #[unsafe(method(tabViewItems))]
233 #[unsafe(method_family = none)]
234 pub unsafe fn tabViewItems(&self) -> Retained<NSArray<NSTabViewItem>>;
235
236 #[cfg(feature = "NSTabViewItem")]
237 #[unsafe(method(setTabViewItems:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn setTabViewItems(&self, tab_view_items: &NSArray<NSTabViewItem>);
241
242 #[unsafe(method(allowsTruncatedLabels))]
243 #[unsafe(method_family = none)]
244 pub unsafe fn allowsTruncatedLabels(&self) -> bool;
245
246 #[unsafe(method(setAllowsTruncatedLabels:))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn setAllowsTruncatedLabels(&self, allows_truncated_labels: bool);
250
251 #[unsafe(method(minimumSize))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn minimumSize(&self) -> NSSize;
254
255 #[unsafe(method(drawsBackground))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn drawsBackground(&self) -> bool;
258
259 #[unsafe(method(setDrawsBackground:))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn setDrawsBackground(&self, draws_background: bool);
263
264 #[cfg(feature = "NSCell")]
265 #[unsafe(method(controlSize))]
266 #[unsafe(method_family = none)]
267 pub unsafe fn controlSize(&self) -> NSControlSize;
268
269 #[cfg(feature = "NSCell")]
270 #[unsafe(method(setControlSize:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn setControlSize(&self, control_size: NSControlSize);
274
275 #[cfg(feature = "NSTabViewItem")]
276 #[unsafe(method(addTabViewItem:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn addTabViewItem(&self, tab_view_item: &NSTabViewItem);
279
280 #[cfg(feature = "NSTabViewItem")]
281 #[unsafe(method(insertTabViewItem:atIndex:))]
282 #[unsafe(method_family = none)]
283 pub unsafe fn insertTabViewItem_atIndex(
284 &self,
285 tab_view_item: &NSTabViewItem,
286 index: NSInteger,
287 );
288
289 #[cfg(feature = "NSTabViewItem")]
290 #[unsafe(method(removeTabViewItem:))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn removeTabViewItem(&self, tab_view_item: &NSTabViewItem);
293
294 #[unsafe(method(delegate))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSTabViewDelegate>>>;
297
298 #[unsafe(method(setDelegate:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSTabViewDelegate>>);
303
304 #[cfg(feature = "NSTabViewItem")]
305 #[unsafe(method(tabViewItemAtPoint:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn tabViewItemAtPoint(&self, point: NSPoint) -> Option<Retained<NSTabViewItem>>;
308
309 #[unsafe(method(contentRect))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn contentRect(&self) -> NSRect;
312
313 #[unsafe(method(numberOfTabViewItems))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn numberOfTabViewItems(&self) -> NSInteger;
316
317 #[cfg(feature = "NSTabViewItem")]
318 #[unsafe(method(indexOfTabViewItem:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn indexOfTabViewItem(&self, tab_view_item: &NSTabViewItem) -> NSInteger;
321
322 #[cfg(feature = "NSTabViewItem")]
323 #[unsafe(method(tabViewItemAtIndex:))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn tabViewItemAtIndex(&self, index: NSInteger) -> Retained<NSTabViewItem>;
326
327 #[unsafe(method(indexOfTabViewItemWithIdentifier:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn indexOfTabViewItemWithIdentifier(&self, identifier: &AnyObject) -> NSInteger;
330
331 #[cfg(feature = "NSCell")]
332 #[deprecated = "The controlTint property is not respected on 10.14 and later."]
333 #[unsafe(method(controlTint))]
334 #[unsafe(method_family = none)]
335 pub unsafe fn controlTint(&self) -> NSControlTint;
336
337 #[cfg(feature = "NSCell")]
338 #[deprecated = "The controlTint property is not respected on 10.14 and later."]
340 #[unsafe(method(setControlTint:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn setControlTint(&self, control_tint: NSControlTint);
343 );
344}
345
346#[cfg(all(feature = "NSResponder", feature = "NSView"))]
348impl NSTabView {
349 extern_methods!(
350 #[unsafe(method(initWithFrame:))]
351 #[unsafe(method_family = init)]
352 pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
353
354 #[unsafe(method(initWithCoder:))]
355 #[unsafe(method_family = init)]
356 pub unsafe fn initWithCoder(
357 this: Allocated<Self>,
358 coder: &NSCoder,
359 ) -> Option<Retained<Self>>;
360 );
361}
362
363#[cfg(all(feature = "NSResponder", feature = "NSView"))]
365impl NSTabView {
366 extern_methods!(
367 #[unsafe(method(init))]
368 #[unsafe(method_family = init)]
369 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
370 );
371}
372
373#[cfg(all(feature = "NSResponder", feature = "NSView"))]
375impl NSTabView {
376 extern_methods!(
377 #[unsafe(method(new))]
378 #[unsafe(method_family = new)]
379 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
380 );
381}
382
383extern_protocol!(
384 pub unsafe trait NSTabViewDelegate: NSObjectProtocol + MainThreadOnly {
386 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
387 #[optional]
388 #[unsafe(method(tabView:shouldSelectTabViewItem:))]
389 #[unsafe(method_family = none)]
390 unsafe fn tabView_shouldSelectTabViewItem(
391 &self,
392 tab_view: &NSTabView,
393 tab_view_item: Option<&NSTabViewItem>,
394 ) -> bool;
395
396 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
397 #[optional]
398 #[unsafe(method(tabView:willSelectTabViewItem:))]
399 #[unsafe(method_family = none)]
400 unsafe fn tabView_willSelectTabViewItem(
401 &self,
402 tab_view: &NSTabView,
403 tab_view_item: Option<&NSTabViewItem>,
404 );
405
406 #[cfg(all(feature = "NSResponder", feature = "NSTabViewItem", feature = "NSView"))]
407 #[optional]
408 #[unsafe(method(tabView:didSelectTabViewItem:))]
409 #[unsafe(method_family = none)]
410 unsafe fn tabView_didSelectTabViewItem(
411 &self,
412 tab_view: &NSTabView,
413 tab_view_item: Option<&NSTabViewItem>,
414 );
415
416 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
417 #[optional]
418 #[unsafe(method(tabViewDidChangeNumberOfTabViewItems:))]
419 #[unsafe(method_family = none)]
420 unsafe fn tabViewDidChangeNumberOfTabViewItems(&self, tab_view: &NSTabView);
421 }
422);