objc2_ui_kit/generated/
UICommand.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/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uikeymodifierflags?language=objc)
11// NS_OPTIONS
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIKeyModifierFlags(pub NSInteger);
15bitflags::bitflags! {
16    impl UIKeyModifierFlags: NSInteger {
17        #[doc(alias = "UIKeyModifierAlphaShift")]
18        const AlphaShift = 1<<16;
19        #[doc(alias = "UIKeyModifierShift")]
20        const Shift = 1<<17;
21        #[doc(alias = "UIKeyModifierControl")]
22        const Control = 1<<18;
23        #[doc(alias = "UIKeyModifierAlternate")]
24        const Alternate = 1<<19;
25        #[doc(alias = "UIKeyModifierCommand")]
26        const Command = 1<<20;
27        #[doc(alias = "UIKeyModifierNumericPad")]
28        const NumericPad = 1<<21;
29    }
30}
31
32unsafe impl Encode for UIKeyModifierFlags {
33    const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for UIKeyModifierFlags {
37    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41    /// Represents an alternate action to take for a command.
42    ///
43    /// Two alternates are equal iff their modifierFlags are equal.
44    ///
45    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommandalternate?language=objc)
46    #[unsafe(super(NSObject))]
47    #[thread_kind = MainThreadOnly]
48    #[derive(Debug, PartialEq, Eq, Hash)]
49    pub struct UICommandAlternate;
50);
51
52unsafe impl NSCoding for UICommandAlternate {}
53
54unsafe impl NSCopying for UICommandAlternate {}
55
56unsafe impl CopyingHelper for UICommandAlternate {
57    type Result = Self;
58}
59
60unsafe impl NSObjectProtocol for UICommandAlternate {}
61
62unsafe impl NSSecureCoding for UICommandAlternate {}
63
64impl UICommandAlternate {
65    extern_methods!(
66        /// Short display title.
67        #[unsafe(method(title))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn title(&self) -> Retained<NSString>;
70
71        /// Action to take on choosing this command alternate.
72        #[unsafe(method(action))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn action(&self) -> Sel;
75
76        /// Bitmask of modifier flags to choose this command alternate.
77        #[unsafe(method(modifierFlags))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn modifierFlags(&self) -> UIKeyModifierFlags;
80
81        /// Initialize an alternate action to take for a command.
82        ///
83        ///
84        /// Parameter `title`: Short display title. This should be localized.
85        ///
86        /// Parameter `action`: Action to take on choosing this command alternate.
87        ///
88        /// Parameter `modifierFlags`: Bitmask of modifier flags to choose this command alternate.
89        ///
90        /// Returns: A new command alternate.
91        #[unsafe(method(alternateWithTitle:action:modifierFlags:))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn alternateWithTitle_action_modifierFlags(
94            title: &NSString,
95            action: Sel,
96            modifier_flags: UIKeyModifierFlags,
97            mtm: MainThreadMarker,
98        ) -> Retained<Self>;
99
100        #[unsafe(method(new))]
101        #[unsafe(method_family = new)]
102        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
103
104        #[unsafe(method(init))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
107
108        #[unsafe(method(initWithCoder:))]
109        #[unsafe(method_family = init)]
110        pub unsafe fn initWithCoder(
111            this: Allocated<Self>,
112            coder: &NSCoder,
113        ) -> Option<Retained<Self>>;
114    );
115}
116
117extern_class!(
118    /// Represents an action to take.
119    ///
120    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommand?language=objc)
121    #[unsafe(super(UIMenuElement, NSObject))]
122    #[thread_kind = MainThreadOnly]
123    #[derive(Debug, PartialEq, Eq, Hash)]
124    #[cfg(feature = "UIMenuElement")]
125    pub struct UICommand;
126);
127
128#[cfg(feature = "UIMenuElement")]
129unsafe impl NSCoding for UICommand {}
130
131#[cfg(feature = "UIMenuElement")]
132unsafe impl NSCopying for UICommand {}
133
134#[cfg(feature = "UIMenuElement")]
135unsafe impl CopyingHelper for UICommand {
136    type Result = Self;
137}
138
139#[cfg(feature = "UIMenuElement")]
140unsafe impl NSObjectProtocol for UICommand {}
141
142#[cfg(feature = "UIMenuElement")]
143unsafe impl NSSecureCoding for UICommand {}
144
145#[cfg(all(feature = "UIMenuElement", feature = "UIMenuLeaf"))]
146unsafe impl UIMenuLeaf for UICommand {}
147
148#[cfg(feature = "UIMenuElement")]
149impl UICommand {
150    extern_methods!(
151        /// Short display title.
152        #[unsafe(method(title))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn title(&self) -> Retained<NSString>;
155
156        /// Setter for [`title`][Self::title].
157        #[unsafe(method(setTitle:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setTitle(&self, title: &NSString);
160
161        #[cfg(feature = "UIImage")]
162        /// Image that can appear next to this command
163        #[unsafe(method(image))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
166
167        #[cfg(feature = "UIImage")]
168        /// Setter for [`image`][Self::image].
169        #[unsafe(method(setImage:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setImage(&self, image: Option<&UIImage>);
172
173        /// Elaborated title used in keyboard shortcut overlay.
174        #[unsafe(method(discoverabilityTitle))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
177
178        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
179        #[unsafe(method(setDiscoverabilityTitle:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
182
183        /// Action to take on choosing this command.
184        #[unsafe(method(action))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn action(&self) -> Sel;
187
188        /// Property list object to distinguish commands, if needed.
189        #[unsafe(method(propertyList))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn propertyList(&self) -> Option<Retained<AnyObject>>;
192
193        /// Command attributes.
194        #[unsafe(method(attributes))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn attributes(&self) -> UIMenuElementAttributes;
197
198        /// Setter for [`attributes`][Self::attributes].
199        #[unsafe(method(setAttributes:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setAttributes(&self, attributes: UIMenuElementAttributes);
202
203        /// State that can appear next to the command.
204        #[unsafe(method(state))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn state(&self) -> UIMenuElementState;
207
208        /// Setter for [`state`][Self::state].
209        #[unsafe(method(setState:))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn setState(&self, state: UIMenuElementState);
212
213        /// Alternates that differ in modifier flags, if any.
214        #[unsafe(method(alternates))]
215        #[unsafe(method_family = none)]
216        pub unsafe fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;
217
218        #[cfg(feature = "UIImage")]
219        /// Initializes a keyless command.
220        ///
221        ///
222        /// Parameter `title`: Short display title. This should be localized.
223        ///
224        /// Parameter `image`: Image that can appear next to this command, if needed.
225        ///
226        /// Parameter `action`: Action to take on choosing this command.
227        ///
228        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
229        ///
230        /// Returns: A new keyless command.
231        #[unsafe(method(commandWithTitle:image:action:propertyList:))]
232        #[unsafe(method_family = none)]
233        pub unsafe fn commandWithTitle_image_action_propertyList(
234            title: &NSString,
235            image: Option<&UIImage>,
236            action: Sel,
237            property_list: Option<&AnyObject>,
238            mtm: MainThreadMarker,
239        ) -> Retained<Self>;
240
241        #[cfg(feature = "UIImage")]
242        /// Initializes a keyless command with alternates.
243        ///
244        ///
245        /// Parameter `title`: Short display title. This should be localized.
246        ///
247        /// Parameter `image`: Image that can appear next to this command, if needed.
248        ///
249        /// Parameter `action`: Action to take on choosing this command.
250        ///
251        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
252        ///
253        /// Parameter `alternates`: Alternates that differ in modifier flags.
254        ///
255        /// Returns: A new keyless command with alternates.
256        #[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
259            title: &NSString,
260            image: Option<&UIImage>,
261            action: Sel,
262            property_list: Option<&AnyObject>,
263            alternates: &NSArray<UICommandAlternate>,
264            mtm: MainThreadMarker,
265        ) -> Retained<Self>;
266
267        #[unsafe(method(new))]
268        #[unsafe(method_family = new)]
269        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
270
271        #[unsafe(method(init))]
272        #[unsafe(method_family = init)]
273        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
274
275        #[unsafe(method(initWithCoder:))]
276        #[unsafe(method_family = init)]
277        pub unsafe fn initWithCoder(
278            this: Allocated<Self>,
279            coder: &NSCoder,
280        ) -> Option<Retained<Self>>;
281    );
282}
283
284extern "C" {
285    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommandtagshare?language=objc)
286    pub static UICommandTagShare: &'static NSString;
287}