objc2_app_kit/generated/
NSToolbarItemGroup.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/// `NSToolbarItemGroup` is a subclass of `NSToolbarItem` which can be used to create sets of `NSToolbarItems` that are always attached to one another and that are added, removed, or reordered as a single unit.
11/// Properties that get set on the parent toolbar item, such as label or view, apply to the entire item.
12/// Otherwise, the individual properties are displayed adjacent to one another.
13/// Subitems will inherit the group's action if no action is defined on the subitem and will validate based on that action when autovalidates is enabled.
14///
15/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nstoolbaritemgroupselectionmode?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct NSToolbarItemGroupSelectionMode(pub NSInteger);
20impl NSToolbarItemGroupSelectionMode {
21    #[doc(alias = "NSToolbarItemGroupSelectionModeSelectOne")]
22    pub const SelectOne: Self = Self(0);
23    #[doc(alias = "NSToolbarItemGroupSelectionModeSelectAny")]
24    pub const SelectAny: Self = Self(1);
25    #[doc(alias = "NSToolbarItemGroupSelectionModeMomentary")]
26    pub const Momentary: Self = Self(2);
27}
28
29unsafe impl Encode for NSToolbarItemGroupSelectionMode {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for NSToolbarItemGroupSelectionMode {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstoolbaritemgroupcontrolrepresentation?language=objc)
38// NS_ENUM
39#[repr(transparent)]
40#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
41pub struct NSToolbarItemGroupControlRepresentation(pub NSInteger);
42impl NSToolbarItemGroupControlRepresentation {
43    #[doc(alias = "NSToolbarItemGroupControlRepresentationAutomatic")]
44    pub const Automatic: Self = Self(0);
45    #[doc(alias = "NSToolbarItemGroupControlRepresentationExpanded")]
46    pub const Expanded: Self = Self(1);
47    #[doc(alias = "NSToolbarItemGroupControlRepresentationCollapsed")]
48    pub const Collapsed: Self = Self(2);
49}
50
51unsafe impl Encode for NSToolbarItemGroupControlRepresentation {
52    const ENCODING: Encoding = NSInteger::ENCODING;
53}
54
55unsafe impl RefEncode for NSToolbarItemGroupControlRepresentation {
56    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
57}
58
59extern_class!(
60    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstoolbaritemgroup?language=objc)
61    #[unsafe(super(NSToolbarItem, NSObject))]
62    #[derive(Debug, PartialEq, Eq, Hash)]
63    #[cfg(feature = "NSToolbarItem")]
64    pub struct NSToolbarItemGroup;
65);
66
67#[cfg(feature = "NSToolbarItem")]
68extern_conformance!(
69    unsafe impl NSCopying for NSToolbarItemGroup {}
70);
71
72#[cfg(feature = "NSToolbarItem")]
73unsafe impl CopyingHelper for NSToolbarItemGroup {
74    type Result = Self;
75}
76
77#[cfg(feature = "NSToolbarItem")]
78extern_conformance!(
79    unsafe impl NSObjectProtocol for NSToolbarItemGroup {}
80);
81
82#[cfg(feature = "NSToolbarItem")]
83impl NSToolbarItemGroup {
84    extern_methods!(
85        #[cfg(feature = "NSToolbar")]
86        /// Convenience constructors for creating segmented control based toolbar items with images or text.
87        /// The item returned will have a custom view for representing the control and automatically create subitems for the group.
88        /// The labels array, if not nil, will be used to provide individual labels under the item for each segment of the control.
89        /// When space in the toolbar is tight, the control may switch to a smaller alternate representation as necessary to remain in the toolbar.
90        #[unsafe(method(groupWithItemIdentifier:titles:selectionMode:labels:target:action:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn groupWithItemIdentifier_titles_selectionMode_labels_target_action(
93            item_identifier: &NSToolbarItemIdentifier,
94            titles: &NSArray<NSString>,
95            selection_mode: NSToolbarItemGroupSelectionMode,
96            labels: Option<&NSArray<NSString>>,
97            target: Option<&AnyObject>,
98            action: Option<Sel>,
99            mtm: MainThreadMarker,
100        ) -> Retained<Self>;
101
102        #[cfg(all(feature = "NSImage", feature = "NSToolbar"))]
103        #[unsafe(method(groupWithItemIdentifier:images:selectionMode:labels:target:action:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn groupWithItemIdentifier_images_selectionMode_labels_target_action(
106            item_identifier: &NSToolbarItemIdentifier,
107            images: &NSArray<NSImage>,
108            selection_mode: NSToolbarItemGroupSelectionMode,
109            labels: Option<&NSArray<NSString>>,
110            target: Option<&AnyObject>,
111            action: Option<Sel>,
112            mtm: MainThreadMarker,
113        ) -> Retained<Self>;
114
115        /// Set or get the array of subitems for the toolbar item.
116        /// By default, a `NSToolbarItemGroup` has an empty array of subitems.
117        /// You should call this to set the subitems before returning the item to the toolbar.
118        /// `NSToolbarItemGroups` may not contain other `NSToolbarItemGroups` as subitems.
119        #[unsafe(method(subitems))]
120        #[unsafe(method_family = none)]
121        pub unsafe fn subitems(&self) -> Retained<NSArray<NSToolbarItem>>;
122
123        /// Setter for [`subitems`][Self::subitems].
124        #[unsafe(method(setSubitems:))]
125        #[unsafe(method_family = none)]
126        pub unsafe fn setSubitems(&self, subitems: &NSArray<NSToolbarItem>);
127
128        /// The style in which this item will be represented to the user.
129        /// Defaults to `NSToolbarItemGroupControlRepresentationAutomatic`.
130        #[unsafe(method(controlRepresentation))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn controlRepresentation(&self) -> NSToolbarItemGroupControlRepresentation;
133
134        /// Setter for [`controlRepresentation`][Self::controlRepresentation].
135        #[unsafe(method(setControlRepresentation:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setControlRepresentation(
138            &self,
139            control_representation: NSToolbarItemGroupControlRepresentation,
140        );
141
142        /// Get and set how selection is handled by the control.
143        /// Only applies when using one of the constructors to create the item with a system defined control representation.
144        #[unsafe(method(selectionMode))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn selectionMode(&self) -> NSToolbarItemGroupSelectionMode;
147
148        /// Setter for [`selectionMode`][Self::selectionMode].
149        #[unsafe(method(setSelectionMode:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setSelectionMode(&self, selection_mode: NSToolbarItemGroupSelectionMode);
152
153        /// The most recently selected item of the group, or -1 if nothing is selected.
154        #[unsafe(method(selectedIndex))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn selectedIndex(&self) -> NSInteger;
157
158        /// Setter for [`selectedIndex`][Self::selectedIndex].
159        #[unsafe(method(setSelectedIndex:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn setSelectedIndex(&self, selected_index: NSInteger);
162
163        /// Get and set selection of individual subitems of the group item.
164        #[unsafe(method(setSelected:atIndex:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn setSelected_atIndex(&self, selected: bool, index: NSInteger);
167
168        #[unsafe(method(isSelectedAtIndex:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn isSelectedAtIndex(&self, index: NSInteger) -> bool;
171    );
172}
173
174/// Methods declared on superclass `NSToolbarItem`.
175#[cfg(feature = "NSToolbarItem")]
176impl NSToolbarItemGroup {
177    extern_methods!(
178        #[cfg(feature = "NSToolbar")]
179        /// Initialize the toolbar item with an identifier which is a development language string used by the toolbar and its delegate for identification purposes.
180        #[unsafe(method(initWithItemIdentifier:))]
181        #[unsafe(method_family = init)]
182        pub unsafe fn initWithItemIdentifier(
183            this: Allocated<Self>,
184            item_identifier: &NSToolbarItemIdentifier,
185        ) -> Retained<Self>;
186    );
187}
188
189/// Methods declared on superclass `NSObject`.
190#[cfg(feature = "NSToolbarItem")]
191impl NSToolbarItemGroup {
192    extern_methods!(
193        #[unsafe(method(init))]
194        #[unsafe(method_family = init)]
195        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
196
197        #[unsafe(method(new))]
198        #[unsafe(method_family = new)]
199        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
200    );
201}