objc2_app_kit/generated/
NSToolbar.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12pub type NSToolbarIdentifier = NSString;
14
15pub type NSToolbarItemIdentifier = NSString;
18
19pub type NSToolbarUserInfoKey = NSString;
22
23extern "C" {
24 pub static NSToolbarItemKey: &'static NSToolbarUserInfoKey;
26}
27
28extern "C" {
29 pub static NSToolbarNewIndexKey: &'static NSToolbarUserInfoKey;
31}
32
33#[repr(transparent)]
36#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
37pub struct NSToolbarDisplayMode(pub NSUInteger);
38impl NSToolbarDisplayMode {
39 #[doc(alias = "NSToolbarDisplayModeDefault")]
40 pub const Default: Self = Self(0);
41 #[doc(alias = "NSToolbarDisplayModeIconAndLabel")]
42 pub const IconAndLabel: Self = Self(1);
43 #[doc(alias = "NSToolbarDisplayModeIconOnly")]
44 pub const IconOnly: Self = Self(2);
45 #[doc(alias = "NSToolbarDisplayModeLabelOnly")]
46 pub const LabelOnly: Self = Self(3);
47}
48
49unsafe impl Encode for NSToolbarDisplayMode {
50 const ENCODING: Encoding = NSUInteger::ENCODING;
51}
52
53unsafe impl RefEncode for NSToolbarDisplayMode {
54 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
55}
56
57#[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
60#[repr(transparent)]
61#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
62pub struct NSToolbarSizeMode(pub NSUInteger);
63impl NSToolbarSizeMode {
64 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
65 #[doc(alias = "NSToolbarSizeModeDefault")]
66 pub const Default: Self = Self(0);
67 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
68 #[doc(alias = "NSToolbarSizeModeRegular")]
69 pub const Regular: Self = Self(1);
70 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
71 #[doc(alias = "NSToolbarSizeModeSmall")]
72 pub const Small: Self = Self(2);
73}
74
75unsafe impl Encode for NSToolbarSizeMode {
76 const ENCODING: Encoding = NSUInteger::ENCODING;
77}
78
79unsafe impl RefEncode for NSToolbarSizeMode {
80 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
81}
82
83extern_class!(
84 #[unsafe(super(NSObject))]
86 #[thread_kind = MainThreadOnly]
87 #[derive(Debug, PartialEq, Eq, Hash)]
88 pub struct NSToolbar;
89);
90
91unsafe impl NSObjectProtocol for NSToolbar {}
92
93impl NSToolbar {
94 extern_methods!(
95 #[unsafe(method(initWithIdentifier:))]
98 #[unsafe(method_family = init)]
99 pub unsafe fn initWithIdentifier(
100 this: Allocated<Self>,
101 identifier: &NSToolbarIdentifier,
102 ) -> Retained<Self>;
103
104 #[unsafe(method(init))]
107 #[unsafe(method_family = init)]
108 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
109
110 #[unsafe(method(insertItemWithItemIdentifier:atIndex:))]
114 #[unsafe(method_family = none)]
115 pub unsafe fn insertItemWithItemIdentifier_atIndex(
116 &self,
117 item_identifier: &NSToolbarItemIdentifier,
118 index: NSInteger,
119 );
120
121 #[unsafe(method(removeItemAtIndex:))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
127
128 #[unsafe(method(removeItemWithItemIdentifier:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn removeItemWithItemIdentifier(
134 &self,
135 item_identifier: &NSToolbarItemIdentifier,
136 );
137
138 #[unsafe(method(delegate))]
140 #[unsafe(method_family = none)]
141 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSToolbarDelegate>>>;
142
143 #[unsafe(method(setDelegate:))]
146 #[unsafe(method_family = none)]
147 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSToolbarDelegate>>);
148
149 #[unsafe(method(isVisible))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn isVisible(&self) -> bool;
155
156 #[unsafe(method(setVisible:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn setVisible(&self, visible: bool);
160
161 #[unsafe(method(runCustomizationPalette:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn runCustomizationPalette(&self, sender: Option<&AnyObject>);
167
168 #[unsafe(method(customizationPaletteIsRunning))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn customizationPaletteIsRunning(&self) -> bool;
173
174 #[unsafe(method(displayMode))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn displayMode(&self) -> NSToolbarDisplayMode;
180
181 #[unsafe(method(setDisplayMode:))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn setDisplayMode(&self, display_mode: NSToolbarDisplayMode);
185
186 #[unsafe(method(selectedItemIdentifier))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn selectedItemIdentifier(&self) -> Option<Retained<NSToolbarItemIdentifier>>;
195
196 #[unsafe(method(setSelectedItemIdentifier:))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn setSelectedItemIdentifier(
200 &self,
201 selected_item_identifier: Option<&NSToolbarItemIdentifier>,
202 );
203
204 #[unsafe(method(allowsUserCustomization))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn allowsUserCustomization(&self) -> bool;
210
211 #[unsafe(method(setAllowsUserCustomization:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setAllowsUserCustomization(&self, allows_user_customization: bool);
215
216 #[unsafe(method(allowsDisplayModeCustomization))]
222 #[unsafe(method_family = none)]
223 pub unsafe fn allowsDisplayModeCustomization(&self) -> bool;
224
225 #[unsafe(method(setAllowsDisplayModeCustomization:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn setAllowsDisplayModeCustomization(
229 &self,
230 allows_display_mode_customization: bool,
231 );
232
233 #[unsafe(method(identifier))]
236 #[unsafe(method_family = none)]
237 pub unsafe fn identifier(&self) -> Retained<NSToolbarIdentifier>;
238
239 #[cfg(feature = "NSToolbarItem")]
240 #[unsafe(method(items))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn items(&self) -> Retained<NSArray<NSToolbarItem>>;
244
245 #[cfg(feature = "NSToolbarItem")]
246 #[unsafe(method(visibleItems))]
248 #[unsafe(method_family = none)]
249 pub unsafe fn visibleItems(&self) -> Option<Retained<NSArray<NSToolbarItem>>>;
250
251 #[unsafe(method(itemIdentifiers))]
256 #[unsafe(method_family = none)]
257 pub unsafe fn itemIdentifiers(&self) -> Retained<NSArray<NSToolbarItemIdentifier>>;
258
259 #[unsafe(method(setItemIdentifiers:))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn setItemIdentifiers(
263 &self,
264 item_identifiers: &NSArray<NSToolbarItemIdentifier>,
265 );
266
267 #[unsafe(method(centeredItemIdentifiers))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn centeredItemIdentifiers(&self) -> Retained<NSSet<NSToolbarItemIdentifier>>;
274
275 #[unsafe(method(setCenteredItemIdentifiers:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn setCenteredItemIdentifiers(
279 &self,
280 centered_item_identifiers: &NSSet<NSToolbarItemIdentifier>,
281 );
282
283 #[unsafe(method(autosavesConfiguration))]
288 #[unsafe(method_family = none)]
289 pub unsafe fn autosavesConfiguration(&self) -> bool;
290
291 #[unsafe(method(setAutosavesConfiguration:))]
293 #[unsafe(method_family = none)]
294 pub unsafe fn setAutosavesConfiguration(&self, autosaves_configuration: bool);
295
296 #[unsafe(method(validateVisibleItems))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn validateVisibleItems(&self);
303
304 #[unsafe(method(allowsExtensionItems))]
308 #[unsafe(method_family = none)]
309 pub unsafe fn allowsExtensionItems(&self) -> bool;
310
311 #[unsafe(method(setAllowsExtensionItems:))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn setAllowsExtensionItems(&self, allows_extension_items: bool);
315 );
316}
317
318impl NSToolbar {
320 extern_methods!(
321 #[unsafe(method(new))]
322 #[unsafe(method_family = new)]
323 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
324 );
325}
326
327extern_protocol!(
328 pub unsafe trait NSToolbarDelegate: NSObjectProtocol + MainThreadOnly {
330 #[cfg(feature = "NSToolbarItem")]
331 #[optional]
338 #[unsafe(method(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:))]
339 #[unsafe(method_family = none)]
340 unsafe fn toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(
341 &self,
342 toolbar: &NSToolbar,
343 item_identifier: &NSToolbarItemIdentifier,
344 flag: bool,
345 ) -> Option<Retained<NSToolbarItem>>;
346
347 #[optional]
350 #[unsafe(method(toolbarDefaultItemIdentifiers:))]
351 #[unsafe(method_family = none)]
352 unsafe fn toolbarDefaultItemIdentifiers(
353 &self,
354 toolbar: &NSToolbar,
355 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
356
357 #[optional]
363 #[unsafe(method(toolbarAllowedItemIdentifiers:))]
364 #[unsafe(method_family = none)]
365 unsafe fn toolbarAllowedItemIdentifiers(
366 &self,
367 toolbar: &NSToolbar,
368 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
369
370 #[optional]
377 #[unsafe(method(toolbarSelectableItemIdentifiers:))]
378 #[unsafe(method_family = none)]
379 unsafe fn toolbarSelectableItemIdentifiers(
380 &self,
381 toolbar: &NSToolbar,
382 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
383
384 #[optional]
386 #[unsafe(method(toolbarImmovableItemIdentifiers:))]
387 #[unsafe(method_family = none)]
388 unsafe fn toolbarImmovableItemIdentifiers(
389 &self,
390 toolbar: &NSToolbar,
391 ) -> Retained<NSSet<NSToolbarItemIdentifier>>;
392
393 #[optional]
397 #[unsafe(method(toolbar:itemIdentifier:canBeInsertedAtIndex:))]
398 #[unsafe(method_family = none)]
399 unsafe fn toolbar_itemIdentifier_canBeInsertedAtIndex(
400 &self,
401 toolbar: &NSToolbar,
402 item_identifier: &NSToolbarItemIdentifier,
403 index: NSInteger,
404 ) -> bool;
405
406 #[optional]
412 #[unsafe(method(toolbarWillAddItem:))]
413 #[unsafe(method_family = none)]
414 unsafe fn toolbarWillAddItem(&self, notification: &NSNotification);
415
416 #[optional]
421 #[unsafe(method(toolbarDidRemoveItem:))]
422 #[unsafe(method_family = none)]
423 unsafe fn toolbarDidRemoveItem(&self, notification: &NSNotification);
424 }
425);
426
427extern "C" {
428 pub static NSToolbarWillAddItemNotification: &'static NSNotificationName;
432}
433
434extern "C" {
435 pub static NSToolbarDidRemoveItemNotification: &'static NSNotificationName;
437}
438
439impl NSToolbar {
441 extern_methods!(
442 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
443 #[unsafe(method(sizeMode))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn sizeMode(&self) -> NSToolbarSizeMode;
446
447 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
449 #[unsafe(method(setSizeMode:))]
450 #[unsafe(method_family = none)]
451 pub unsafe fn setSizeMode(&self, size_mode: NSToolbarSizeMode);
452
453 #[deprecated = "Use the centeredItemIdentifiers property instead"]
454 #[unsafe(method(centeredItemIdentifier))]
455 #[unsafe(method_family = none)]
456 pub unsafe fn centeredItemIdentifier(&self) -> Option<Retained<NSToolbarItemIdentifier>>;
457
458 #[deprecated = "Use the centeredItemIdentifiers property instead"]
460 #[unsafe(method(setCenteredItemIdentifier:))]
461 #[unsafe(method_family = none)]
462 pub unsafe fn setCenteredItemIdentifier(
463 &self,
464 centered_item_identifier: Option<&NSToolbarItemIdentifier>,
465 );
466
467 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
468 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead"]
469 #[unsafe(method(fullScreenAccessoryView))]
470 #[unsafe(method_family = none)]
471 pub unsafe fn fullScreenAccessoryView(&self) -> Option<Retained<NSView>>;
472
473 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
474 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead"]
476 #[unsafe(method(setFullScreenAccessoryView:))]
477 #[unsafe(method_family = none)]
478 pub unsafe fn setFullScreenAccessoryView(
479 &self,
480 full_screen_accessory_view: Option<&NSView>,
481 );
482
483 #[cfg(feature = "objc2-core-foundation")]
484 #[deprecated = "Use NSTitlebarAccessoryViewController and its fullScreenMinHeight property with NSWindow instead."]
485 #[unsafe(method(fullScreenAccessoryViewMinHeight))]
486 #[unsafe(method_family = none)]
487 pub unsafe fn fullScreenAccessoryViewMinHeight(&self) -> CGFloat;
488
489 #[cfg(feature = "objc2-core-foundation")]
490 #[deprecated = "Use NSTitlebarAccessoryViewController and its fullScreenMinHeight property with NSWindow instead."]
492 #[unsafe(method(setFullScreenAccessoryViewMinHeight:))]
493 #[unsafe(method_family = none)]
494 pub unsafe fn setFullScreenAccessoryViewMinHeight(
495 &self,
496 full_screen_accessory_view_min_height: CGFloat,
497 );
498
499 #[cfg(feature = "objc2-core-foundation")]
500 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead. The max height of a titlebar accessory is implied by its view's height."]
501 #[unsafe(method(fullScreenAccessoryViewMaxHeight))]
502 #[unsafe(method_family = none)]
503 pub unsafe fn fullScreenAccessoryViewMaxHeight(&self) -> CGFloat;
504
505 #[cfg(feature = "objc2-core-foundation")]
506 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead. The max height of a titlebar accessory is implied by its view's height."]
508 #[unsafe(method(setFullScreenAccessoryViewMaxHeight:))]
509 #[unsafe(method_family = none)]
510 pub unsafe fn setFullScreenAccessoryViewMaxHeight(
511 &self,
512 full_screen_accessory_view_max_height: CGFloat,
513 );
514
515 #[deprecated = "No longer supported"]
516 #[unsafe(method(showsBaselineSeparator))]
517 #[unsafe(method_family = none)]
518 pub unsafe fn showsBaselineSeparator(&self) -> bool;
519
520 #[deprecated = "No longer supported"]
522 #[unsafe(method(setShowsBaselineSeparator:))]
523 #[unsafe(method_family = none)]
524 pub unsafe fn setShowsBaselineSeparator(&self, shows_baseline_separator: bool);
525
526 #[deprecated = "Use -itemIdentifiers and -displayMode instead."]
527 #[unsafe(method(configurationDictionary))]
528 #[unsafe(method_family = none)]
529 pub unsafe fn configurationDictionary(&self)
530 -> Retained<NSDictionary<NSString, AnyObject>>;
531
532 #[deprecated = "Use -setItemIdentifiers: and -setDisplayMode: instead."]
533 #[unsafe(method(setConfigurationFromDictionary:))]
534 #[unsafe(method_family = none)]
535 pub unsafe fn setConfigurationFromDictionary(
536 &self,
537 config_dict: &NSDictionary<NSString, AnyObject>,
538 );
539 );
540}