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 #[doc(alias = "NSToolbarSizeModeDefault")]
65 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
66 pub const Default: Self = Self(0);
67 #[doc(alias = "NSToolbarSizeModeRegular")]
68 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
69 pub const Regular: Self = Self(1);
70 #[doc(alias = "NSToolbarSizeModeSmall")]
71 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
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
91extern_conformance!(
92 unsafe impl NSObjectProtocol for NSToolbar {}
93);
94
95impl NSToolbar {
96 extern_methods!(
97 #[unsafe(method(initWithIdentifier:))]
100 #[unsafe(method_family = init)]
101 pub unsafe fn initWithIdentifier(
102 this: Allocated<Self>,
103 identifier: &NSToolbarIdentifier,
104 ) -> Retained<Self>;
105
106 #[unsafe(method(init))]
109 #[unsafe(method_family = init)]
110 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
111
112 #[unsafe(method(insertItemWithItemIdentifier:atIndex:))]
116 #[unsafe(method_family = none)]
117 pub unsafe fn insertItemWithItemIdentifier_atIndex(
118 &self,
119 item_identifier: &NSToolbarItemIdentifier,
120 index: NSInteger,
121 );
122
123 #[unsafe(method(removeItemAtIndex:))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn removeItemAtIndex(&self, index: NSInteger);
129
130 #[unsafe(method(removeItemWithItemIdentifier:))]
134 #[unsafe(method_family = none)]
135 pub unsafe fn removeItemWithItemIdentifier(
136 &self,
137 item_identifier: &NSToolbarItemIdentifier,
138 );
139
140 #[unsafe(method(delegate))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSToolbarDelegate>>>;
144
145 #[unsafe(method(setDelegate:))]
148 #[unsafe(method_family = none)]
149 pub unsafe fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSToolbarDelegate>>);
150
151 #[unsafe(method(isVisible))]
155 #[unsafe(method_family = none)]
156 pub unsafe fn isVisible(&self) -> bool;
157
158 #[unsafe(method(setVisible:))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn setVisible(&self, visible: bool);
162
163 #[unsafe(method(runCustomizationPalette:))]
167 #[unsafe(method_family = none)]
168 pub unsafe fn runCustomizationPalette(&self, sender: Option<&AnyObject>);
169
170 #[unsafe(method(customizationPaletteIsRunning))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn customizationPaletteIsRunning(&self) -> bool;
175
176 #[unsafe(method(displayMode))]
180 #[unsafe(method_family = none)]
181 pub unsafe fn displayMode(&self) -> NSToolbarDisplayMode;
182
183 #[unsafe(method(setDisplayMode:))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn setDisplayMode(&self, display_mode: NSToolbarDisplayMode);
187
188 #[unsafe(method(selectedItemIdentifier))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn selectedItemIdentifier(&self) -> Option<Retained<NSToolbarItemIdentifier>>;
197
198 #[unsafe(method(setSelectedItemIdentifier:))]
200 #[unsafe(method_family = none)]
201 pub unsafe fn setSelectedItemIdentifier(
202 &self,
203 selected_item_identifier: Option<&NSToolbarItemIdentifier>,
204 );
205
206 #[unsafe(method(allowsUserCustomization))]
210 #[unsafe(method_family = none)]
211 pub unsafe fn allowsUserCustomization(&self) -> bool;
212
213 #[unsafe(method(setAllowsUserCustomization:))]
215 #[unsafe(method_family = none)]
216 pub unsafe fn setAllowsUserCustomization(&self, allows_user_customization: bool);
217
218 #[unsafe(method(allowsDisplayModeCustomization))]
224 #[unsafe(method_family = none)]
225 pub unsafe fn allowsDisplayModeCustomization(&self) -> bool;
226
227 #[unsafe(method(setAllowsDisplayModeCustomization:))]
229 #[unsafe(method_family = none)]
230 pub unsafe fn setAllowsDisplayModeCustomization(
231 &self,
232 allows_display_mode_customization: bool,
233 );
234
235 #[unsafe(method(identifier))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn identifier(&self) -> Retained<NSToolbarIdentifier>;
240
241 #[cfg(feature = "NSToolbarItem")]
242 #[unsafe(method(items))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn items(&self) -> Retained<NSArray<NSToolbarItem>>;
246
247 #[cfg(feature = "NSToolbarItem")]
248 #[unsafe(method(visibleItems))]
250 #[unsafe(method_family = none)]
251 pub unsafe fn visibleItems(&self) -> Option<Retained<NSArray<NSToolbarItem>>>;
252
253 #[unsafe(method(itemIdentifiers))]
258 #[unsafe(method_family = none)]
259 pub unsafe fn itemIdentifiers(&self) -> Retained<NSArray<NSToolbarItemIdentifier>>;
260
261 #[unsafe(method(setItemIdentifiers:))]
263 #[unsafe(method_family = none)]
264 pub unsafe fn setItemIdentifiers(
265 &self,
266 item_identifiers: &NSArray<NSToolbarItemIdentifier>,
267 );
268
269 #[unsafe(method(centeredItemIdentifiers))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn centeredItemIdentifiers(&self) -> Retained<NSSet<NSToolbarItemIdentifier>>;
276
277 #[unsafe(method(setCenteredItemIdentifiers:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn setCenteredItemIdentifiers(
281 &self,
282 centered_item_identifiers: &NSSet<NSToolbarItemIdentifier>,
283 );
284
285 #[unsafe(method(autosavesConfiguration))]
290 #[unsafe(method_family = none)]
291 pub unsafe fn autosavesConfiguration(&self) -> bool;
292
293 #[unsafe(method(setAutosavesConfiguration:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn setAutosavesConfiguration(&self, autosaves_configuration: bool);
297
298 #[unsafe(method(validateVisibleItems))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn validateVisibleItems(&self);
305
306 #[unsafe(method(allowsExtensionItems))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn allowsExtensionItems(&self) -> bool;
312
313 #[unsafe(method(setAllowsExtensionItems:))]
315 #[unsafe(method_family = none)]
316 pub unsafe fn setAllowsExtensionItems(&self, allows_extension_items: bool);
317 );
318}
319
320impl NSToolbar {
322 extern_methods!(
323 #[unsafe(method(new))]
324 #[unsafe(method_family = new)]
325 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
326 );
327}
328
329extern_protocol!(
330 pub unsafe trait NSToolbarDelegate: NSObjectProtocol + MainThreadOnly {
332 #[cfg(feature = "NSToolbarItem")]
333 #[optional]
340 #[unsafe(method(toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:))]
341 #[unsafe(method_family = none)]
342 unsafe fn toolbar_itemForItemIdentifier_willBeInsertedIntoToolbar(
343 &self,
344 toolbar: &NSToolbar,
345 item_identifier: &NSToolbarItemIdentifier,
346 flag: bool,
347 ) -> Option<Retained<NSToolbarItem>>;
348
349 #[optional]
352 #[unsafe(method(toolbarDefaultItemIdentifiers:))]
353 #[unsafe(method_family = none)]
354 unsafe fn toolbarDefaultItemIdentifiers(
355 &self,
356 toolbar: &NSToolbar,
357 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
358
359 #[optional]
365 #[unsafe(method(toolbarAllowedItemIdentifiers:))]
366 #[unsafe(method_family = none)]
367 unsafe fn toolbarAllowedItemIdentifiers(
368 &self,
369 toolbar: &NSToolbar,
370 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
371
372 #[optional]
379 #[unsafe(method(toolbarSelectableItemIdentifiers:))]
380 #[unsafe(method_family = none)]
381 unsafe fn toolbarSelectableItemIdentifiers(
382 &self,
383 toolbar: &NSToolbar,
384 ) -> Retained<NSArray<NSToolbarItemIdentifier>>;
385
386 #[optional]
388 #[unsafe(method(toolbarImmovableItemIdentifiers:))]
389 #[unsafe(method_family = none)]
390 unsafe fn toolbarImmovableItemIdentifiers(
391 &self,
392 toolbar: &NSToolbar,
393 ) -> Retained<NSSet<NSToolbarItemIdentifier>>;
394
395 #[optional]
399 #[unsafe(method(toolbar:itemIdentifier:canBeInsertedAtIndex:))]
400 #[unsafe(method_family = none)]
401 unsafe fn toolbar_itemIdentifier_canBeInsertedAtIndex(
402 &self,
403 toolbar: &NSToolbar,
404 item_identifier: &NSToolbarItemIdentifier,
405 index: NSInteger,
406 ) -> bool;
407
408 #[optional]
414 #[unsafe(method(toolbarWillAddItem:))]
415 #[unsafe(method_family = none)]
416 unsafe fn toolbarWillAddItem(&self, notification: &NSNotification);
417
418 #[optional]
423 #[unsafe(method(toolbarDidRemoveItem:))]
424 #[unsafe(method_family = none)]
425 unsafe fn toolbarDidRemoveItem(&self, notification: &NSNotification);
426 }
427);
428
429extern "C" {
430 pub static NSToolbarWillAddItemNotification: &'static NSNotificationName;
434}
435
436extern "C" {
437 pub static NSToolbarDidRemoveItemNotification: &'static NSNotificationName;
439}
440
441impl NSToolbar {
443 extern_methods!(
444 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
445 #[unsafe(method(sizeMode))]
446 #[unsafe(method_family = none)]
447 pub unsafe fn sizeMode(&self) -> NSToolbarSizeMode;
448
449 #[deprecated = "NSToolbarSizeMode is no longer recommended and will be ignored in the future"]
451 #[unsafe(method(setSizeMode:))]
452 #[unsafe(method_family = none)]
453 pub unsafe fn setSizeMode(&self, size_mode: NSToolbarSizeMode);
454
455 #[deprecated = "Use the centeredItemIdentifiers property instead"]
456 #[unsafe(method(centeredItemIdentifier))]
457 #[unsafe(method_family = none)]
458 pub unsafe fn centeredItemIdentifier(&self) -> Option<Retained<NSToolbarItemIdentifier>>;
459
460 #[deprecated = "Use the centeredItemIdentifiers property instead"]
462 #[unsafe(method(setCenteredItemIdentifier:))]
463 #[unsafe(method_family = none)]
464 pub unsafe fn setCenteredItemIdentifier(
465 &self,
466 centered_item_identifier: Option<&NSToolbarItemIdentifier>,
467 );
468
469 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
470 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead"]
471 #[unsafe(method(fullScreenAccessoryView))]
472 #[unsafe(method_family = none)]
473 pub unsafe fn fullScreenAccessoryView(&self) -> Option<Retained<NSView>>;
474
475 #[cfg(all(feature = "NSResponder", feature = "NSView"))]
476 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead"]
478 #[unsafe(method(setFullScreenAccessoryView:))]
479 #[unsafe(method_family = none)]
480 pub unsafe fn setFullScreenAccessoryView(
481 &self,
482 full_screen_accessory_view: Option<&NSView>,
483 );
484
485 #[cfg(feature = "objc2-core-foundation")]
486 #[deprecated = "Use NSTitlebarAccessoryViewController and its fullScreenMinHeight property with NSWindow instead."]
487 #[unsafe(method(fullScreenAccessoryViewMinHeight))]
488 #[unsafe(method_family = none)]
489 pub unsafe fn fullScreenAccessoryViewMinHeight(&self) -> CGFloat;
490
491 #[cfg(feature = "objc2-core-foundation")]
492 #[deprecated = "Use NSTitlebarAccessoryViewController and its fullScreenMinHeight property with NSWindow instead."]
494 #[unsafe(method(setFullScreenAccessoryViewMinHeight:))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn setFullScreenAccessoryViewMinHeight(
497 &self,
498 full_screen_accessory_view_min_height: CGFloat,
499 );
500
501 #[cfg(feature = "objc2-core-foundation")]
502 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead. The max height of a titlebar accessory is implied by its view's height."]
503 #[unsafe(method(fullScreenAccessoryViewMaxHeight))]
504 #[unsafe(method_family = none)]
505 pub unsafe fn fullScreenAccessoryViewMaxHeight(&self) -> CGFloat;
506
507 #[cfg(feature = "objc2-core-foundation")]
508 #[deprecated = "Use NSTitlebarAccessoryViewController with NSWindow instead. The max height of a titlebar accessory is implied by its view's height."]
510 #[unsafe(method(setFullScreenAccessoryViewMaxHeight:))]
511 #[unsafe(method_family = none)]
512 pub unsafe fn setFullScreenAccessoryViewMaxHeight(
513 &self,
514 full_screen_accessory_view_max_height: CGFloat,
515 );
516
517 #[deprecated = "No longer supported"]
518 #[unsafe(method(showsBaselineSeparator))]
519 #[unsafe(method_family = none)]
520 pub unsafe fn showsBaselineSeparator(&self) -> bool;
521
522 #[deprecated = "No longer supported"]
524 #[unsafe(method(setShowsBaselineSeparator:))]
525 #[unsafe(method_family = none)]
526 pub unsafe fn setShowsBaselineSeparator(&self, shows_baseline_separator: bool);
527
528 #[deprecated = "Use -itemIdentifiers and -displayMode instead."]
529 #[unsafe(method(configurationDictionary))]
530 #[unsafe(method_family = none)]
531 pub unsafe fn configurationDictionary(&self)
532 -> Retained<NSDictionary<NSString, AnyObject>>;
533
534 #[deprecated = "Use -setItemIdentifiers: and -setDisplayMode: instead."]
535 #[unsafe(method(setConfigurationFromDictionary:))]
536 #[unsafe(method_family = none)]
537 pub unsafe fn setConfigurationFromDictionary(
538 &self,
539 config_dict: &NSDictionary<NSString, AnyObject>,
540 );
541 );
542}