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
52extern_conformance!(
53    unsafe impl NSCoding for UICommandAlternate {}
54);
55
56extern_conformance!(
57    unsafe impl NSCopying for UICommandAlternate {}
58);
59
60unsafe impl CopyingHelper for UICommandAlternate {
61    type Result = Self;
62}
63
64extern_conformance!(
65    unsafe impl NSObjectProtocol for UICommandAlternate {}
66);
67
68extern_conformance!(
69    unsafe impl NSSecureCoding for UICommandAlternate {}
70);
71
72impl UICommandAlternate {
73    extern_methods!(
74        /// Short display title.
75        #[unsafe(method(title))]
76        #[unsafe(method_family = none)]
77        pub fn title(&self) -> Retained<NSString>;
78
79        /// Action to take on choosing this command alternate.
80        #[unsafe(method(action))]
81        #[unsafe(method_family = none)]
82        pub fn action(&self) -> Sel;
83
84        /// Bitmask of modifier flags to choose this command alternate.
85        #[unsafe(method(modifierFlags))]
86        #[unsafe(method_family = none)]
87        pub fn modifierFlags(&self) -> UIKeyModifierFlags;
88
89        /// Initialize an alternate action to take for a command.
90        ///
91        ///
92        /// Parameter `title`: Short display title. This should be localized.
93        ///
94        /// Parameter `action`: Action to take on choosing this command alternate.
95        ///
96        /// Parameter `modifierFlags`: Bitmask of modifier flags to choose this command alternate.
97        ///
98        /// Returns: A new command alternate.
99        ///
100        /// # Safety
101        ///
102        /// `action` must be a valid selector.
103        #[unsafe(method(alternateWithTitle:action:modifierFlags:))]
104        #[unsafe(method_family = none)]
105        pub unsafe fn alternateWithTitle_action_modifierFlags(
106            title: &NSString,
107            action: Sel,
108            modifier_flags: UIKeyModifierFlags,
109            mtm: MainThreadMarker,
110        ) -> Retained<Self>;
111
112        #[unsafe(method(new))]
113        #[unsafe(method_family = new)]
114        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
115
116        #[unsafe(method(init))]
117        #[unsafe(method_family = init)]
118        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
119
120        /// # Safety
121        ///
122        /// `coder` possibly has further requirements.
123        #[unsafe(method(initWithCoder:))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn initWithCoder(
126            this: Allocated<Self>,
127            coder: &NSCoder,
128        ) -> Option<Retained<Self>>;
129    );
130}
131
132extern_class!(
133    /// Represents an action to take.
134    ///
135    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommand?language=objc)
136    #[unsafe(super(UIMenuElement, NSObject))]
137    #[thread_kind = MainThreadOnly]
138    #[derive(Debug, PartialEq, Eq, Hash)]
139    #[cfg(feature = "UIMenuElement")]
140    pub struct UICommand;
141);
142
143#[cfg(feature = "UIMenuElement")]
144extern_conformance!(
145    unsafe impl NSCoding for UICommand {}
146);
147
148#[cfg(feature = "UIMenuElement")]
149extern_conformance!(
150    unsafe impl NSCopying for UICommand {}
151);
152
153#[cfg(feature = "UIMenuElement")]
154unsafe impl CopyingHelper for UICommand {
155    type Result = Self;
156}
157
158#[cfg(feature = "UIMenuElement")]
159extern_conformance!(
160    unsafe impl NSObjectProtocol for UICommand {}
161);
162
163#[cfg(feature = "UIMenuElement")]
164extern_conformance!(
165    unsafe impl NSSecureCoding for UICommand {}
166);
167
168#[cfg(all(feature = "UIMenuElement", feature = "UIMenuLeaf"))]
169extern_conformance!(
170    unsafe impl UIMenuLeaf for UICommand {}
171);
172
173#[cfg(feature = "UIMenuElement")]
174impl UICommand {
175    extern_methods!(
176        /// Short display title.
177        #[unsafe(method(title))]
178        #[unsafe(method_family = none)]
179        pub fn title(&self) -> Retained<NSString>;
180
181        /// Setter for [`title`][Self::title].
182        ///
183        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
184        #[unsafe(method(setTitle:))]
185        #[unsafe(method_family = none)]
186        pub fn setTitle(&self, title: &NSString);
187
188        #[cfg(feature = "UIImage")]
189        /// Image that can appear next to this command
190        #[unsafe(method(image))]
191        #[unsafe(method_family = none)]
192        pub fn image(&self) -> Option<Retained<UIImage>>;
193
194        #[cfg(feature = "UIImage")]
195        /// Setter for [`image`][Self::image].
196        ///
197        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
198        #[unsafe(method(setImage:))]
199        #[unsafe(method_family = none)]
200        pub fn setImage(&self, image: Option<&UIImage>);
201
202        /// Elaborated title used in keyboard shortcut overlay.
203        #[unsafe(method(discoverabilityTitle))]
204        #[unsafe(method_family = none)]
205        pub fn discoverabilityTitle(&self) -> Option<Retained<NSString>>;
206
207        /// Setter for [`discoverabilityTitle`][Self::discoverabilityTitle].
208        ///
209        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
210        #[unsafe(method(setDiscoverabilityTitle:))]
211        #[unsafe(method_family = none)]
212        pub fn setDiscoverabilityTitle(&self, discoverability_title: Option<&NSString>);
213
214        /// Action to take on choosing this command.
215        #[unsafe(method(action))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn action(&self) -> Sel;
218
219        /// Property list object to distinguish commands, if needed.
220        #[unsafe(method(propertyList))]
221        #[unsafe(method_family = none)]
222        pub fn propertyList(&self) -> Option<Retained<AnyObject>>;
223
224        /// Command attributes.
225        #[unsafe(method(attributes))]
226        #[unsafe(method_family = none)]
227        pub fn attributes(&self) -> UIMenuElementAttributes;
228
229        /// Setter for [`attributes`][Self::attributes].
230        #[unsafe(method(setAttributes:))]
231        #[unsafe(method_family = none)]
232        pub fn setAttributes(&self, attributes: UIMenuElementAttributes);
233
234        /// State that can appear next to the command.
235        #[unsafe(method(state))]
236        #[unsafe(method_family = none)]
237        pub fn state(&self) -> UIMenuElementState;
238
239        /// Setter for [`state`][Self::state].
240        #[unsafe(method(setState:))]
241        #[unsafe(method_family = none)]
242        pub fn setState(&self, state: UIMenuElementState);
243
244        /// Alternates that differ in modifier flags, if any.
245        #[unsafe(method(alternates))]
246        #[unsafe(method_family = none)]
247        pub fn alternates(&self) -> Retained<NSArray<UICommandAlternate>>;
248
249        #[cfg(feature = "UIImage")]
250        /// Initializes a keyless command.
251        ///
252        ///
253        /// Parameter `title`: Short display title. This should be localized.
254        ///
255        /// Parameter `image`: Image that can appear next to this command, if needed.
256        ///
257        /// Parameter `action`: Action to take on choosing this command.
258        ///
259        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
260        ///
261        /// Returns: A new keyless command.
262        ///
263        /// # Safety
264        ///
265        /// - `action` must be a valid selector.
266        /// - `property_list` should be of the correct type.
267        #[unsafe(method(commandWithTitle:image:action:propertyList:))]
268        #[unsafe(method_family = none)]
269        pub unsafe fn commandWithTitle_image_action_propertyList(
270            title: &NSString,
271            image: Option<&UIImage>,
272            action: Sel,
273            property_list: Option<&AnyObject>,
274            mtm: MainThreadMarker,
275        ) -> Retained<Self>;
276
277        #[cfg(feature = "UIImage")]
278        /// Initializes a keyless command with alternates.
279        ///
280        ///
281        /// Parameter `title`: Short display title. This should be localized.
282        ///
283        /// Parameter `image`: Image that can appear next to this command, if needed.
284        ///
285        /// Parameter `action`: Action to take on choosing this command.
286        ///
287        /// Parameter `propertyList`: Property list object to distinguish commands, if needed.
288        ///
289        /// Parameter `alternates`: Alternates that differ in modifier flags.
290        ///
291        /// Returns: A new keyless command with alternates.
292        ///
293        /// # Safety
294        ///
295        /// - `action` must be a valid selector.
296        /// - `property_list` should be of the correct type.
297        #[unsafe(method(commandWithTitle:image:action:propertyList:alternates:))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn commandWithTitle_image_action_propertyList_alternates(
300            title: &NSString,
301            image: Option<&UIImage>,
302            action: Sel,
303            property_list: Option<&AnyObject>,
304            alternates: &NSArray<UICommandAlternate>,
305            mtm: MainThreadMarker,
306        ) -> Retained<Self>;
307
308        #[unsafe(method(new))]
309        #[unsafe(method_family = new)]
310        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
311
312        #[unsafe(method(init))]
313        #[unsafe(method_family = init)]
314        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
315
316        /// # Safety
317        ///
318        /// `coder` possibly has further requirements.
319        #[unsafe(method(initWithCoder:))]
320        #[unsafe(method_family = init)]
321        pub unsafe fn initWithCoder(
322            this: Allocated<Self>,
323            coder: &NSCoder,
324        ) -> Option<Retained<Self>>;
325    );
326}
327
328extern "C" {
329    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uicommandtagshare?language=objc)
330    pub static UICommandTagShare: &'static NSString;
331}