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")]
68unsafe impl NSCopying for NSToolbarItemGroup {}
69
70#[cfg(feature = "NSToolbarItem")]
71unsafe impl CopyingHelper for NSToolbarItemGroup {
72    type Result = Self;
73}
74
75#[cfg(feature = "NSToolbarItem")]
76unsafe impl NSObjectProtocol for NSToolbarItemGroup {}
77
78#[cfg(feature = "NSToolbarItem")]
79impl NSToolbarItemGroup {
80    extern_methods!(
81        #[cfg(feature = "NSToolbar")]
82        /// Convenience constructors for creating segmented control based toolbar items with images or text.
83        /// The item returned will have a custom view for representing the control and automatically create subitems for the group.
84        /// The labels array, if not nil, will be used to provide individual labels under the item for each segment of the control.
85        /// When space in the toolbar is tight, the control may switch to a smaller alternate representation as necessary to remain in the toolbar.
86        #[unsafe(method(groupWithItemIdentifier:titles:selectionMode:labels:target:action:))]
87        #[unsafe(method_family = none)]
88        pub unsafe fn groupWithItemIdentifier_titles_selectionMode_labels_target_action(
89            item_identifier: &NSToolbarItemIdentifier,
90            titles: &NSArray<NSString>,
91            selection_mode: NSToolbarItemGroupSelectionMode,
92            labels: Option<&NSArray<NSString>>,
93            target: Option<&AnyObject>,
94            action: Option<Sel>,
95            mtm: MainThreadMarker,
96        ) -> Retained<Self>;
97
98        #[cfg(all(feature = "NSImage", feature = "NSToolbar"))]
99        #[unsafe(method(groupWithItemIdentifier:images:selectionMode:labels:target:action:))]
100        #[unsafe(method_family = none)]
101        pub unsafe fn groupWithItemIdentifier_images_selectionMode_labels_target_action(
102            item_identifier: &NSToolbarItemIdentifier,
103            images: &NSArray<NSImage>,
104            selection_mode: NSToolbarItemGroupSelectionMode,
105            labels: Option<&NSArray<NSString>>,
106            target: Option<&AnyObject>,
107            action: Option<Sel>,
108            mtm: MainThreadMarker,
109        ) -> Retained<Self>;
110
111        /// Set or get the array of subitems for the toolbar item.
112        /// By default, a `NSToolbarItemGroup` has an empty array of subitems.
113        /// You should call this to set the subitems before returning the item to the toolbar.
114        /// `NSToolbarItemGroups` may not contain other `NSToolbarItemGroups` as subitems.
115        #[unsafe(method(subitems))]
116        #[unsafe(method_family = none)]
117        pub unsafe fn subitems(&self) -> Retained<NSArray<NSToolbarItem>>;
118
119        /// Setter for [`subitems`][Self::subitems].
120        #[unsafe(method(setSubitems:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn setSubitems(&self, subitems: &NSArray<NSToolbarItem>);
123
124        /// The style in which this item will be represented to the user.
125        /// Defaults to `NSToolbarItemGroupControlRepresentationAutomatic`.
126        #[unsafe(method(controlRepresentation))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn controlRepresentation(&self) -> NSToolbarItemGroupControlRepresentation;
129
130        /// Setter for [`controlRepresentation`][Self::controlRepresentation].
131        #[unsafe(method(setControlRepresentation:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn setControlRepresentation(
134            &self,
135            control_representation: NSToolbarItemGroupControlRepresentation,
136        );
137
138        /// Get and set how selection is handled by the control.
139        /// Only applies when using one of the constructors to create the item with a system defined control representation.
140        #[unsafe(method(selectionMode))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn selectionMode(&self) -> NSToolbarItemGroupSelectionMode;
143
144        /// Setter for [`selectionMode`][Self::selectionMode].
145        #[unsafe(method(setSelectionMode:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn setSelectionMode(&self, selection_mode: NSToolbarItemGroupSelectionMode);
148
149        /// The most recently selected item of the group, or -1 if nothing is selected.
150        #[unsafe(method(selectedIndex))]
151        #[unsafe(method_family = none)]
152        pub unsafe fn selectedIndex(&self) -> NSInteger;
153
154        /// Setter for [`selectedIndex`][Self::selectedIndex].
155        #[unsafe(method(setSelectedIndex:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setSelectedIndex(&self, selected_index: NSInteger);
158
159        /// Get and set selection of individual subitems of the group item.
160        #[unsafe(method(setSelected:atIndex:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setSelected_atIndex(&self, selected: bool, index: NSInteger);
163
164        #[unsafe(method(isSelectedAtIndex:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn isSelectedAtIndex(&self, index: NSInteger) -> bool;
167    );
168}
169
170/// Methods declared on superclass `NSToolbarItem`.
171#[cfg(feature = "NSToolbarItem")]
172impl NSToolbarItemGroup {
173    extern_methods!(
174        #[cfg(feature = "NSToolbar")]
175        /// Initialize the toolbar item with an identifier which is a development language string used by the toolbar and its delegate for identification purposes.
176        #[unsafe(method(initWithItemIdentifier:))]
177        #[unsafe(method_family = init)]
178        pub unsafe fn initWithItemIdentifier(
179            this: Allocated<Self>,
180            item_identifier: &NSToolbarItemIdentifier,
181        ) -> Retained<Self>;
182    );
183}
184
185/// Methods declared on superclass `NSObject`.
186#[cfg(feature = "NSToolbarItem")]
187impl NSToolbarItemGroup {
188    extern_methods!(
189        #[unsafe(method(init))]
190        #[unsafe(method_family = init)]
191        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
192
193        #[unsafe(method(new))]
194        #[unsafe(method_family = new)]
195        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
196    );
197}