objc2_ui_kit/generated/
UIMenu.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/uimenuidentifier?language=objc)
11// NS_TYPED_EXTENSIBLE_ENUM
12pub type UIMenuIdentifier = NSString;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuoptions?language=objc)
15// NS_OPTIONS
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct UIMenuOptions(pub NSUInteger);
19bitflags::bitflags! {
20    impl UIMenuOptions: NSUInteger {
21/// Show children inline in parent, instead of hierarchically
22        #[doc(alias = "UIMenuOptionsDisplayInline")]
23        const DisplayInline = 1<<0;
24/// Indicates whether the menu should be rendered with a destructive appearance in its parent
25        #[doc(alias = "UIMenuOptionsDestructive")]
26        const Destructive = 1<<1;
27/// Indicates whether the menu (and any submenus) should only allow a single "on" menu item.
28        #[doc(alias = "UIMenuOptionsSingleSelection")]
29        const SingleSelection = 1<<5;
30/// Indicates that this menu should be rendered as a palette.
31        #[doc(alias = "UIMenuOptionsDisplayAsPalette")]
32        const DisplayAsPalette = 1<<7;
33    }
34}
35
36unsafe impl Encode for UIMenuOptions {
37    const ENCODING: Encoding = NSUInteger::ENCODING;
38}
39
40unsafe impl RefEncode for UIMenuOptions {
41    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
42}
43
44/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuelementsize?language=objc)
45// NS_ENUM
46#[repr(transparent)]
47#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct UIMenuElementSize(pub NSInteger);
49impl UIMenuElementSize {
50    #[doc(alias = "UIMenuElementSizeSmall")]
51    pub const Small: Self = Self(0);
52    #[doc(alias = "UIMenuElementSizeMedium")]
53    pub const Medium: Self = Self(1);
54    #[doc(alias = "UIMenuElementSizeLarge")]
55    pub const Large: Self = Self(2);
56    /// Automatically determine the appropriate element size for the current context.
57    #[doc(alias = "UIMenuElementSizeAutomatic")]
58    pub const Automatic: Self = Self(-1);
59}
60
61unsafe impl Encode for UIMenuElementSize {
62    const ENCODING: Encoding = NSInteger::ENCODING;
63}
64
65unsafe impl RefEncode for UIMenuElementSize {
66    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
67}
68
69extern_class!(
70    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenu?language=objc)
71    #[unsafe(super(UIMenuElement, NSObject))]
72    #[thread_kind = MainThreadOnly]
73    #[derive(Debug, PartialEq, Eq, Hash)]
74    #[cfg(feature = "UIMenuElement")]
75    pub struct UIMenu;
76);
77
78#[cfg(feature = "UIMenuElement")]
79extern_conformance!(
80    unsafe impl NSCoding for UIMenu {}
81);
82
83#[cfg(feature = "UIMenuElement")]
84extern_conformance!(
85    unsafe impl NSCopying for UIMenu {}
86);
87
88#[cfg(feature = "UIMenuElement")]
89unsafe impl CopyingHelper for UIMenu {
90    type Result = Self;
91}
92
93#[cfg(feature = "UIMenuElement")]
94extern_conformance!(
95    unsafe impl NSObjectProtocol for UIMenu {}
96);
97
98#[cfg(feature = "UIMenuElement")]
99extern_conformance!(
100    unsafe impl NSSecureCoding for UIMenu {}
101);
102
103#[cfg(feature = "UIMenuElement")]
104impl UIMenu {
105    extern_methods!(
106        /// Unique identifier.
107        #[unsafe(method(identifier))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn identifier(&self) -> Retained<UIMenuIdentifier>;
110
111        /// Options.
112        #[unsafe(method(options))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn options(&self) -> UIMenuOptions;
115
116        /// Size of this menu's child elements. This property has no effect on Mac Catalyst.
117        #[unsafe(method(preferredElementSize))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn preferredElementSize(&self) -> UIMenuElementSize;
120
121        /// Setter for [`preferredElementSize`][Self::preferredElementSize].
122        #[unsafe(method(setPreferredElementSize:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setPreferredElementSize(&self, preferred_element_size: UIMenuElementSize);
125
126        /// The menu's sub-elements and sub-menus. On iOS 14.0, elements of your own menus are mutable, -copying a menu will produce mutable elements, and UIKit will take immutable copies of menus it receives. Prior to iOS 14.0, menus are always fully immutable.
127        #[unsafe(method(children))]
128        #[unsafe(method_family = none)]
129        pub unsafe fn children(&self) -> Retained<NSArray<UIMenuElement>>;
130
131        /// The element(s) in the menu and sub-menus that have an "on" menu item state.
132        #[unsafe(method(selectedElements))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn selectedElements(&self) -> Retained<NSArray<UIMenuElement>>;
135
136        #[cfg(feature = "UIMenuDisplayPreferences")]
137        /// Display preferences for this menu's immediate children. Preferences are not inherited by sub menus,
138        /// and may be ignored or overridden by the system in certain element sizes or menu layouts.
139        #[unsafe(method(displayPreferences))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn displayPreferences(&self) -> Option<Retained<UIMenuDisplayPreferences>>;
142
143        #[cfg(feature = "UIMenuDisplayPreferences")]
144        /// Setter for [`displayPreferences`][Self::displayPreferences].
145        #[unsafe(method(setDisplayPreferences:))]
146        #[unsafe(method_family = none)]
147        pub unsafe fn setDisplayPreferences(
148            &self,
149            display_preferences: Option<&UIMenuDisplayPreferences>,
150        );
151
152        /// Creates a UIMenu with an empty title, nil image, automatically generated identifier, and default options.
153        ///
154        ///
155        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
156        ///
157        ///
158        /// Returns: A new UIMenu.
159        #[unsafe(method(menuWithChildren:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn menuWithChildren(
162            children: &NSArray<UIMenuElement>,
163            mtm: MainThreadMarker,
164        ) -> Retained<UIMenu>;
165
166        /// Creates a UIMenu with the given arguments.
167        ///
168        ///
169        /// Parameter `title`: The menu's title.
170        ///
171        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
172        ///
173        ///
174        /// Returns: A new UIMenu.
175        #[unsafe(method(menuWithTitle:children:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn menuWithTitle_children(
178            title: &NSString,
179            children: &NSArray<UIMenuElement>,
180            mtm: MainThreadMarker,
181        ) -> Retained<UIMenu>;
182
183        #[cfg(feature = "UIImage")]
184        /// Creates a UIMenu with the given arguments.
185        ///
186        ///
187        /// Parameter `title`: The menu's title.
188        ///
189        /// Parameter `image`: Image to be displayed alongside the menu's title.
190        ///
191        /// Parameter `identifier`: The menu's unique identifier. Pass nil to use an auto-generated identifier.
192        ///
193        /// Parameter `options`: The menu's options.
194        ///
195        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
196        ///
197        ///
198        /// Returns: A new UIMenu.
199        #[unsafe(method(menuWithTitle:image:identifier:options:children:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn menuWithTitle_image_identifier_options_children(
202            title: &NSString,
203            image: Option<&UIImage>,
204            identifier: Option<&UIMenuIdentifier>,
205            options: UIMenuOptions,
206            children: &NSArray<UIMenuElement>,
207            mtm: MainThreadMarker,
208        ) -> Retained<UIMenu>;
209
210        #[unsafe(method(initWithCoder:))]
211        #[unsafe(method_family = init)]
212        pub unsafe fn initWithCoder(
213            this: Allocated<Self>,
214            coder: &NSCoder,
215        ) -> Option<Retained<Self>>;
216
217        #[unsafe(method(init))]
218        #[unsafe(method_family = init)]
219        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
220
221        #[unsafe(method(new))]
222        #[unsafe(method_family = new)]
223        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
224
225        /// Copies this menu and replaces its children.
226        ///
227        ///
228        /// Parameter `newChildren`: The replacement children.
229        ///
230        ///
231        /// Returns: A copy of this menu with updated children.
232        #[unsafe(method(menuByReplacingChildren:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn menuByReplacingChildren(
235            &self,
236            new_children: &NSArray<UIMenuElement>,
237        ) -> Retained<UIMenu>;
238    );
239}
240
241extern "C" {
242    /// Application menu top-level menu
243    ///
244    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuapplication?language=objc)
245    pub static UIMenuApplication: &'static UIMenuIdentifier;
246}
247
248extern "C" {
249    /// File menu top-level menu
250    ///
251    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufile?language=objc)
252    pub static UIMenuFile: &'static UIMenuIdentifier;
253}
254
255extern "C" {
256    /// Edit menu top-level menu
257    ///
258    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuedit?language=objc)
259    pub static UIMenuEdit: &'static UIMenuIdentifier;
260}
261
262extern "C" {
263    /// View menu top-level menu
264    ///
265    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuview?language=objc)
266    pub static UIMenuView: &'static UIMenuIdentifier;
267}
268
269extern "C" {
270    /// Window menu top-level menu
271    ///
272    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuwindow?language=objc)
273    pub static UIMenuWindow: &'static UIMenuIdentifier;
274}
275
276extern "C" {
277    /// Help menu top-level menu
278    ///
279    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuhelp?language=objc)
280    pub static UIMenuHelp: &'static UIMenuIdentifier;
281}
282
283extern "C" {
284    /// About menu
285    ///
286    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuabout?language=objc)
287    pub static UIMenuAbout: &'static UIMenuIdentifier;
288}
289
290extern "C" {
291    /// Preferences menu
292    ///
293    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenupreferences?language=objc)
294    pub static UIMenuPreferences: &'static UIMenuIdentifier;
295}
296
297extern "C" {
298    /// Services menu
299    ///
300    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuservices?language=objc)
301    pub static UIMenuServices: &'static UIMenuIdentifier;
302}
303
304extern "C" {
305    /// Hide, Hide Others, Show All menu
306    ///
307    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuhide?language=objc)
308    pub static UIMenuHide: &'static UIMenuIdentifier;
309}
310
311extern "C" {
312    /// Quit menu
313    ///
314    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuquit?language=objc)
315    pub static UIMenuQuit: &'static UIMenuIdentifier;
316}
317
318extern "C" {
319    /// New scene menu
320    ///
321    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenunewscene?language=objc)
322    pub static UIMenuNewScene: &'static UIMenuIdentifier;
323}
324
325extern "C" {
326    /// Open menu
327    ///
328    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuopen?language=objc)
329    pub static UIMenuOpen: &'static UIMenuIdentifier;
330}
331
332extern "C" {
333    /// Open Recent menu
334    ///
335    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuopenrecent?language=objc)
336    pub static UIMenuOpenRecent: &'static UIMenuIdentifier;
337}
338
339extern "C" {
340    /// Close menu
341    ///
342    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuclose?language=objc)
343    pub static UIMenuClose: &'static UIMenuIdentifier;
344}
345
346extern "C" {
347    /// Print menu
348    ///
349    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuprint?language=objc)
350    pub static UIMenuPrint: &'static UIMenuIdentifier;
351}
352
353extern "C" {
354    /// Document-related menu items: Duplicate, Move, Rename, Export. The `.document` menu is added to Mac Catalyst applications by default. iOS Apps on the Mac will have the `.document` menu inserted when and if `UINavigationItem.titleMenuProvider` is set to a nonnull value, and from launch on subsequent executions.
355    ///
356    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenudocument?language=objc)
357    pub static UIMenuDocument: &'static UIMenuIdentifier;
358}
359
360extern "C" {
361    /// Undo, Redo menu
362    ///
363    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuundoredo?language=objc)
364    pub static UIMenuUndoRedo: &'static UIMenuIdentifier;
365}
366
367extern "C" {
368    /// Cut, Copy, Paste, Delete, Select, Select All menu
369    ///
370    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenustandardedit?language=objc)
371    pub static UIMenuStandardEdit: &'static UIMenuIdentifier;
372}
373
374extern "C" {
375    /// Find menu; empty in the default menubar configuration. Applications should use this when adding their own Find-related menu items.
376    ///
377    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufind?language=objc)
378    pub static UIMenuFind: &'static UIMenuIdentifier;
379}
380
381extern "C" {
382    /// Replace..., Transliterate Chinese menu
383    ///
384    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenureplace?language=objc)
385    pub static UIMenuReplace: &'static UIMenuIdentifier;
386}
387
388extern "C" {
389    /// Share menu
390    ///
391    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenushare?language=objc)
392    pub static UIMenuShare: &'static UIMenuIdentifier;
393}
394
395extern "C" {
396    /// Bold, Italics, Underline  menu
397    ///
398    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextstyle?language=objc)
399    pub static UIMenuTextStyle: &'static UIMenuIdentifier;
400}
401
402extern "C" {
403    /// Spelling menu contained within Edit menu
404    ///
405    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspelling?language=objc)
406    pub static UIMenuSpelling: &'static UIMenuIdentifier;
407}
408
409extern "C" {
410    /// Show Spelling, Check Document Now menu
411    ///
412    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspellingpanel?language=objc)
413    pub static UIMenuSpellingPanel: &'static UIMenuIdentifier;
414}
415
416extern "C" {
417    /// Check Spelling While Typing and other spelling and grammar-checking options menu
418    ///
419    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspellingoptions?language=objc)
420    pub static UIMenuSpellingOptions: &'static UIMenuIdentifier;
421}
422
423extern "C" {
424    /// Substitutions menu contained within Edit menu
425    ///
426    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutions?language=objc)
427    pub static UIMenuSubstitutions: &'static UIMenuIdentifier;
428}
429
430extern "C" {
431    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutionspanel?language=objc)
432    pub static UIMenuSubstitutionsPanel: &'static UIMenuIdentifier;
433}
434
435extern "C" {
436    /// Smart Copy, Smart Paste, Smart Quotes, and other substitution options menu
437    ///
438    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutionoptions?language=objc)
439    pub static UIMenuSubstitutionOptions: &'static UIMenuIdentifier;
440}
441
442extern "C" {
443    /// Transformations menu contained within Edit menu (contains Make Uppercase, Make Lowercase, Capitalize)
444    ///
445    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutransformations?language=objc)
446    pub static UIMenuTransformations: &'static UIMenuIdentifier;
447}
448
449extern "C" {
450    /// Speech menu contained within Edit menu (contains Speak, Speak..., Pause)
451    ///
452    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspeech?language=objc)
453    pub static UIMenuSpeech: &'static UIMenuIdentifier;
454}
455
456extern "C" {
457    /// Lookup menu
458    ///
459    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenulookup?language=objc)
460    pub static UIMenuLookup: &'static UIMenuIdentifier;
461}
462
463extern "C" {
464    /// Learn menu
465    ///
466    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenulearn?language=objc)
467    pub static UIMenuLearn: &'static UIMenuIdentifier;
468}
469
470extern "C" {
471    /// Format top-level menu
472    ///
473    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuformat?language=objc)
474    pub static UIMenuFormat: &'static UIMenuIdentifier;
475}
476
477extern "C" {
478    /// AutoFill menu
479    ///
480    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuautofill?language=objc)
481    pub static UIMenuAutoFill: &'static UIMenuIdentifier;
482}
483
484extern "C" {
485    /// Font menu contained within Format menu (contains UIMenuTextStyle)
486    ///
487    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufont?language=objc)
488    pub static UIMenuFont: &'static UIMenuIdentifier;
489}
490
491extern "C" {
492    /// Bigger and Smaller menu
493    ///
494    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextsize?language=objc)
495    pub static UIMenuTextSize: &'static UIMenuIdentifier;
496}
497
498extern "C" {
499    /// Show Colors menu
500    ///
501    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextcolor?language=objc)
502    pub static UIMenuTextColor: &'static UIMenuIdentifier;
503}
504
505extern "C" {
506    /// Copy Style and Paste Style menu
507    ///
508    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextstylepasteboard?language=objc)
509    pub static UIMenuTextStylePasteboard: &'static UIMenuIdentifier;
510}
511
512extern "C" {
513    /// Text menu contained within Format menu (contains UIMenuAlignment and UIMenuWritingDirection)
514    ///
515    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutext?language=objc)
516    pub static UIMenuText: &'static UIMenuIdentifier;
517}
518
519extern "C" {
520    /// Default, Right to Left, Left to Right menu
521    ///
522    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuwritingdirection?language=objc)
523    pub static UIMenuWritingDirection: &'static UIMenuIdentifier;
524}
525
526extern "C" {
527    /// Align Left, Center, Justify, Align Right menu
528    ///
529    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenualignment?language=objc)
530    pub static UIMenuAlignment: &'static UIMenuIdentifier;
531}
532
533extern "C" {
534    /// Show/Hide and Customize Toolbar menu
535    ///
536    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutoolbar?language=objc)
537    pub static UIMenuToolbar: &'static UIMenuIdentifier;
538}
539
540extern "C" {
541    /// Sidebar menu
542    ///
543    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusidebar?language=objc)
544    pub static UIMenuSidebar: &'static UIMenuIdentifier;
545}
546
547extern "C" {
548    /// Fullscreen menu
549    ///
550    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufullscreen?language=objc)
551    pub static UIMenuFullscreen: &'static UIMenuIdentifier;
552}
553
554extern "C" {
555    /// Minimize, Zoom menu
556    ///
557    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuminimizeandzoom?language=objc)
558    pub static UIMenuMinimizeAndZoom: &'static UIMenuIdentifier;
559}
560
561extern "C" {
562    /// Bring All to Front, Arrange in Front menu
563    ///
564    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenubringalltofront?language=objc)
565    pub static UIMenuBringAllToFront: &'static UIMenuIdentifier;
566}
567
568extern "C" {
569    /// Root-level menu
570    ///
571    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuroot?language=objc)
572    pub static UIMenuRoot: &'static UIMenuIdentifier;
573}