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 fn identifier(&self) -> Retained<UIMenuIdentifier>;
110
111        /// Options.
112        #[unsafe(method(options))]
113        #[unsafe(method_family = none)]
114        pub 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 fn preferredElementSize(&self) -> UIMenuElementSize;
120
121        /// Setter for [`preferredElementSize`][Self::preferredElementSize].
122        #[unsafe(method(setPreferredElementSize:))]
123        #[unsafe(method_family = none)]
124        pub 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 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 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 fn displayPreferences(&self) -> Option<Retained<UIMenuDisplayPreferences>>;
142
143        #[cfg(feature = "UIMenuDisplayPreferences")]
144        /// Setter for [`displayPreferences`][Self::displayPreferences].
145        ///
146        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
147        #[unsafe(method(setDisplayPreferences:))]
148        #[unsafe(method_family = none)]
149        pub fn setDisplayPreferences(&self, display_preferences: Option<&UIMenuDisplayPreferences>);
150
151        /// Creates a UIMenu with an empty title, nil image, automatically generated identifier, and default options.
152        ///
153        ///
154        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
155        ///
156        ///
157        /// Returns: A new UIMenu.
158        #[unsafe(method(menuWithChildren:))]
159        #[unsafe(method_family = none)]
160        pub fn menuWithChildren(
161            children: &NSArray<UIMenuElement>,
162            mtm: MainThreadMarker,
163        ) -> Retained<UIMenu>;
164
165        /// Creates a UIMenu with the given arguments.
166        ///
167        ///
168        /// Parameter `title`: The menu's title.
169        ///
170        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
171        ///
172        ///
173        /// Returns: A new UIMenu.
174        #[unsafe(method(menuWithTitle:children:))]
175        #[unsafe(method_family = none)]
176        pub fn menuWithTitle_children(
177            title: &NSString,
178            children: &NSArray<UIMenuElement>,
179            mtm: MainThreadMarker,
180        ) -> Retained<UIMenu>;
181
182        #[cfg(feature = "UIImage")]
183        /// Creates a UIMenu with the given arguments.
184        ///
185        ///
186        /// Parameter `title`: The menu's title.
187        ///
188        /// Parameter `image`: Image to be displayed alongside the menu's title.
189        ///
190        /// Parameter `identifier`: The menu's unique identifier. Pass nil to use an auto-generated identifier.
191        ///
192        /// Parameter `options`: The menu's options.
193        ///
194        /// Parameter `children`: The menu's action-based sub-elements and sub-menus.
195        ///
196        ///
197        /// Returns: A new UIMenu.
198        #[unsafe(method(menuWithTitle:image:identifier:options:children:))]
199        #[unsafe(method_family = none)]
200        pub fn menuWithTitle_image_identifier_options_children(
201            title: &NSString,
202            image: Option<&UIImage>,
203            identifier: Option<&UIMenuIdentifier>,
204            options: UIMenuOptions,
205            children: &NSArray<UIMenuElement>,
206            mtm: MainThreadMarker,
207        ) -> Retained<UIMenu>;
208
209        /// # Safety
210        ///
211        /// `coder` possibly has further requirements.
212        #[unsafe(method(initWithCoder:))]
213        #[unsafe(method_family = init)]
214        pub unsafe fn initWithCoder(
215            this: Allocated<Self>,
216            coder: &NSCoder,
217        ) -> Option<Retained<Self>>;
218
219        #[unsafe(method(init))]
220        #[unsafe(method_family = init)]
221        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
222
223        #[unsafe(method(new))]
224        #[unsafe(method_family = new)]
225        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
226
227        /// Copies this menu and replaces its children.
228        ///
229        ///
230        /// Parameter `newChildren`: The replacement children.
231        ///
232        ///
233        /// Returns: A copy of this menu with updated children.
234        #[unsafe(method(menuByReplacingChildren:))]
235        #[unsafe(method_family = none)]
236        pub fn menuByReplacingChildren(
237            &self,
238            new_children: &NSArray<UIMenuElement>,
239        ) -> Retained<UIMenu>;
240    );
241}
242
243extern "C" {
244    /// Application menu top-level menu
245    ///
246    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuapplication?language=objc)
247    pub static UIMenuApplication: &'static UIMenuIdentifier;
248}
249
250extern "C" {
251    /// File menu top-level menu
252    ///
253    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufile?language=objc)
254    pub static UIMenuFile: &'static UIMenuIdentifier;
255}
256
257extern "C" {
258    /// Edit menu top-level menu
259    ///
260    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuedit?language=objc)
261    pub static UIMenuEdit: &'static UIMenuIdentifier;
262}
263
264extern "C" {
265    /// View menu top-level menu
266    ///
267    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuview?language=objc)
268    pub static UIMenuView: &'static UIMenuIdentifier;
269}
270
271extern "C" {
272    /// Window menu top-level menu
273    ///
274    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuwindow?language=objc)
275    pub static UIMenuWindow: &'static UIMenuIdentifier;
276}
277
278extern "C" {
279    /// Help menu top-level menu
280    ///
281    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuhelp?language=objc)
282    pub static UIMenuHelp: &'static UIMenuIdentifier;
283}
284
285extern "C" {
286    /// About menu
287    ///
288    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuabout?language=objc)
289    pub static UIMenuAbout: &'static UIMenuIdentifier;
290}
291
292extern "C" {
293    /// Preferences menu
294    ///
295    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenupreferences?language=objc)
296    pub static UIMenuPreferences: &'static UIMenuIdentifier;
297}
298
299extern "C" {
300    /// Services menu
301    ///
302    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuservices?language=objc)
303    pub static UIMenuServices: &'static UIMenuIdentifier;
304}
305
306extern "C" {
307    /// Hide, Hide Others, Show All menu
308    ///
309    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuhide?language=objc)
310    pub static UIMenuHide: &'static UIMenuIdentifier;
311}
312
313extern "C" {
314    /// Quit menu
315    ///
316    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuquit?language=objc)
317    pub static UIMenuQuit: &'static UIMenuIdentifier;
318}
319
320extern "C" {
321    /// New item menu
322    ///
323    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenunewitem?language=objc)
324    pub static UIMenuNewItem: &'static UIMenuIdentifier;
325}
326
327extern "C" {
328    /// New scene menu
329    ///
330    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenunewscene?language=objc)
331    #[deprecated]
332    pub static UIMenuNewScene: &'static UIMenuIdentifier;
333}
334
335extern "C" {
336    /// Open menu
337    ///
338    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuopen?language=objc)
339    pub static UIMenuOpen: &'static UIMenuIdentifier;
340}
341
342extern "C" {
343    /// Open Recent menu
344    ///
345    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuopenrecent?language=objc)
346    pub static UIMenuOpenRecent: &'static UIMenuIdentifier;
347}
348
349extern "C" {
350    /// Close menu
351    ///
352    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuclose?language=objc)
353    pub static UIMenuClose: &'static UIMenuIdentifier;
354}
355
356extern "C" {
357    /// Print menu
358    ///
359    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuprint?language=objc)
360    pub static UIMenuPrint: &'static UIMenuIdentifier;
361}
362
363extern "C" {
364    /// 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.
365    ///
366    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenudocument?language=objc)
367    pub static UIMenuDocument: &'static UIMenuIdentifier;
368}
369
370extern "C" {
371    /// Undo, Redo menu
372    ///
373    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuundoredo?language=objc)
374    pub static UIMenuUndoRedo: &'static UIMenuIdentifier;
375}
376
377extern "C" {
378    /// Cut, Copy, Paste, Delete, Select, Select All menu
379    ///
380    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenustandardedit?language=objc)
381    pub static UIMenuStandardEdit: &'static UIMenuIdentifier;
382}
383
384extern "C" {
385    /// Find menu, containing Find Panel items and other finding operations like Use Selection for Find
386    ///
387    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufind?language=objc)
388    pub static UIMenuFind: &'static UIMenuIdentifier;
389}
390
391extern "C" {
392    /// Find panel menu (Find, Find and Replace, Find Next, Find Previous)
393    ///
394    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufindpanel?language=objc)
395    pub static UIMenuFindPanel: &'static UIMenuIdentifier;
396}
397
398extern "C" {
399    /// Replace..., Transliterate Chinese menu
400    ///
401    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenureplace?language=objc)
402    pub static UIMenuReplace: &'static UIMenuIdentifier;
403}
404
405extern "C" {
406    /// Share menu
407    ///
408    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenushare?language=objc)
409    pub static UIMenuShare: &'static UIMenuIdentifier;
410}
411
412extern "C" {
413    /// Bold, Italics, Underline  menu
414    ///
415    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextstyle?language=objc)
416    pub static UIMenuTextStyle: &'static UIMenuIdentifier;
417}
418
419extern "C" {
420    /// Spelling menu contained within Edit menu
421    ///
422    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspelling?language=objc)
423    pub static UIMenuSpelling: &'static UIMenuIdentifier;
424}
425
426extern "C" {
427    /// Show Spelling, Check Document Now menu
428    ///
429    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspellingpanel?language=objc)
430    pub static UIMenuSpellingPanel: &'static UIMenuIdentifier;
431}
432
433extern "C" {
434    /// Check Spelling While Typing and other spelling and grammar-checking options menu
435    ///
436    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspellingoptions?language=objc)
437    pub static UIMenuSpellingOptions: &'static UIMenuIdentifier;
438}
439
440extern "C" {
441    /// Substitutions menu contained within Edit menu
442    ///
443    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutions?language=objc)
444    pub static UIMenuSubstitutions: &'static UIMenuIdentifier;
445}
446
447extern "C" {
448    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutionspanel?language=objc)
449    pub static UIMenuSubstitutionsPanel: &'static UIMenuIdentifier;
450}
451
452extern "C" {
453    /// Smart Copy, Smart Paste, Smart Quotes, and other substitution options menu
454    ///
455    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusubstitutionoptions?language=objc)
456    pub static UIMenuSubstitutionOptions: &'static UIMenuIdentifier;
457}
458
459extern "C" {
460    /// Transformations menu contained within Edit menu (contains Make Uppercase, Make Lowercase, Capitalize)
461    ///
462    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutransformations?language=objc)
463    pub static UIMenuTransformations: &'static UIMenuIdentifier;
464}
465
466extern "C" {
467    /// Speech menu contained within Edit menu (contains Speak, Speak..., Pause)
468    ///
469    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuspeech?language=objc)
470    pub static UIMenuSpeech: &'static UIMenuIdentifier;
471}
472
473extern "C" {
474    /// Lookup menu
475    ///
476    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenulookup?language=objc)
477    pub static UIMenuLookup: &'static UIMenuIdentifier;
478}
479
480extern "C" {
481    /// Learn menu
482    ///
483    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenulearn?language=objc)
484    pub static UIMenuLearn: &'static UIMenuIdentifier;
485}
486
487extern "C" {
488    /// Format top-level menu
489    ///
490    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuformat?language=objc)
491    pub static UIMenuFormat: &'static UIMenuIdentifier;
492}
493
494extern "C" {
495    /// AutoFill menu
496    ///
497    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuautofill?language=objc)
498    pub static UIMenuAutoFill: &'static UIMenuIdentifier;
499}
500
501extern "C" {
502    /// Font menu contained within Format menu (contains UIMenuTextStyle)
503    ///
504    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufont?language=objc)
505    pub static UIMenuFont: &'static UIMenuIdentifier;
506}
507
508extern "C" {
509    /// Bigger and Smaller menu
510    ///
511    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextsize?language=objc)
512    pub static UIMenuTextSize: &'static UIMenuIdentifier;
513}
514
515extern "C" {
516    /// Show Colors menu
517    ///
518    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextcolor?language=objc)
519    pub static UIMenuTextColor: &'static UIMenuIdentifier;
520}
521
522extern "C" {
523    /// Copy Style and Paste Style menu
524    ///
525    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutextstylepasteboard?language=objc)
526    pub static UIMenuTextStylePasteboard: &'static UIMenuIdentifier;
527}
528
529extern "C" {
530    /// Text menu contained within Format menu (contains UIMenuAlignment and UIMenuWritingDirection)
531    ///
532    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutext?language=objc)
533    pub static UIMenuText: &'static UIMenuIdentifier;
534}
535
536extern "C" {
537    /// Default, Right to Left, Left to Right menu
538    ///
539    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuwritingdirection?language=objc)
540    pub static UIMenuWritingDirection: &'static UIMenuIdentifier;
541}
542
543extern "C" {
544    /// Align Left, Center, Justify, Align Right menu
545    ///
546    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenualignment?language=objc)
547    pub static UIMenuAlignment: &'static UIMenuIdentifier;
548}
549
550extern "C" {
551    /// Show/Hide and Customize Toolbar menu
552    ///
553    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenutoolbar?language=objc)
554    pub static UIMenuToolbar: &'static UIMenuIdentifier;
555}
556
557extern "C" {
558    /// Sidebar menu
559    ///
560    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenusidebar?language=objc)
561    pub static UIMenuSidebar: &'static UIMenuIdentifier;
562}
563
564extern "C" {
565    /// Fullscreen menu
566    ///
567    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenufullscreen?language=objc)
568    pub static UIMenuFullscreen: &'static UIMenuIdentifier;
569}
570
571extern "C" {
572    /// Minimize, Zoom menu
573    ///
574    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuminimizeandzoom?language=objc)
575    pub static UIMenuMinimizeAndZoom: &'static UIMenuIdentifier;
576}
577
578extern "C" {
579    /// Bring All to Front, Arrange in Front menu
580    ///
581    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenubringalltofront?language=objc)
582    pub static UIMenuBringAllToFront: &'static UIMenuIdentifier;
583}
584
585extern "C" {
586    /// Root-level menu
587    ///
588    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuroot?language=objc)
589    pub static UIMenuRoot: &'static UIMenuIdentifier;
590}