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