objc2_ui_kit/generated/
UIMenuElement.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/uimenuelementstate?language=objc)
11// NS_ENUM
12#[repr(transparent)]
13#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
14pub struct UIMenuElementState(pub NSInteger);
15impl UIMenuElementState {
16    #[doc(alias = "UIMenuElementStateOff")]
17    pub const Off: Self = Self(0);
18    #[doc(alias = "UIMenuElementStateOn")]
19    pub const On: Self = Self(1);
20    #[doc(alias = "UIMenuElementStateMixed")]
21    pub const Mixed: Self = Self(2);
22}
23
24unsafe impl Encode for UIMenuElementState {
25    const ENCODING: Encoding = NSInteger::ENCODING;
26}
27
28unsafe impl RefEncode for UIMenuElementState {
29    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
30}
31
32/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuelementattributes?language=objc)
33// NS_OPTIONS
34#[repr(transparent)]
35#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct UIMenuElementAttributes(pub NSUInteger);
37bitflags::bitflags! {
38    impl UIMenuElementAttributes: NSUInteger {
39        #[doc(alias = "UIMenuElementAttributesDisabled")]
40        const Disabled = 1<<0;
41        #[doc(alias = "UIMenuElementAttributesDestructive")]
42        const Destructive = 1<<1;
43        #[doc(alias = "UIMenuElementAttributesHidden")]
44        const Hidden = 1<<2;
45/// Indicates that the menu should remain presented after firing
46/// the element's action rather than dismissing as it normally does.
47/// This attribute has no effect on Mac Catalyst.
48        #[doc(alias = "UIMenuElementAttributesKeepsMenuPresented")]
49        const KeepsMenuPresented = 1<<3;
50    }
51}
52
53unsafe impl Encode for UIMenuElementAttributes {
54    const ENCODING: Encoding = NSUInteger::ENCODING;
55}
56
57unsafe impl RefEncode for UIMenuElementAttributes {
58    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
59}
60
61/// Possible repeat behaviors for a menu element.
62///
63/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuelementrepeatbehavior?language=objc)
64// NS_ENUM
65#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct UIMenuElementRepeatBehavior(pub NSInteger);
68impl UIMenuElementRepeatBehavior {
69    /// Automatically uses the appropriate repeat behavior for this element.
70    #[doc(alias = "UIMenuElementRepeatBehaviorAutomatic")]
71    pub const Automatic: Self = Self(0);
72    /// The element should be allowed to repeat.
73    #[doc(alias = "UIMenuElementRepeatBehaviorRepeatable")]
74    pub const Repeatable: Self = Self(1);
75    /// The element should not be repeatable.
76    #[doc(alias = "UIMenuElementRepeatBehaviorNonRepeatable")]
77    pub const NonRepeatable: Self = Self(2);
78}
79
80unsafe impl Encode for UIMenuElementRepeatBehavior {
81    const ENCODING: Encoding = NSInteger::ENCODING;
82}
83
84unsafe impl RefEncode for UIMenuElementRepeatBehavior {
85    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
86}
87
88extern_class!(
89    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuelement?language=objc)
90    #[unsafe(super(NSObject))]
91    #[thread_kind = MainThreadOnly]
92    #[derive(Debug, PartialEq, Eq, Hash)]
93    pub struct UIMenuElement;
94);
95
96extern_conformance!(
97    unsafe impl NSCoding for UIMenuElement {}
98);
99
100extern_conformance!(
101    unsafe impl NSCopying for UIMenuElement {}
102);
103
104unsafe impl CopyingHelper for UIMenuElement {
105    type Result = Self;
106}
107
108extern_conformance!(
109    unsafe impl NSObjectProtocol for UIMenuElement {}
110);
111
112extern_conformance!(
113    unsafe impl NSSecureCoding for UIMenuElement {}
114);
115
116impl UIMenuElement {
117    extern_methods!(
118        /// The element's title.
119        #[unsafe(method(title))]
120        #[unsafe(method_family = none)]
121        pub fn title(&self) -> Retained<NSString>;
122
123        /// The element's subtitle.
124        #[unsafe(method(subtitle))]
125        #[unsafe(method_family = none)]
126        pub fn subtitle(&self) -> Option<Retained<NSString>>;
127
128        /// Setter for [`subtitle`][Self::subtitle].
129        ///
130        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
131        #[unsafe(method(setSubtitle:))]
132        #[unsafe(method_family = none)]
133        pub fn setSubtitle(&self, subtitle: Option<&NSString>);
134
135        #[cfg(feature = "UIImage")]
136        /// Image to be displayed alongside the element's title.
137        #[unsafe(method(image))]
138        #[unsafe(method_family = none)]
139        pub fn image(&self) -> Option<Retained<UIImage>>;
140
141        /// # Safety
142        ///
143        /// `coder` possibly has further requirements.
144        #[unsafe(method(initWithCoder:))]
145        #[unsafe(method_family = init)]
146        pub unsafe fn initWithCoder(
147            this: Allocated<Self>,
148            coder: &NSCoder,
149        ) -> Option<Retained<Self>>;
150
151        #[unsafe(method(init))]
152        #[unsafe(method_family = init)]
153        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
154
155        #[unsafe(method(new))]
156        #[unsafe(method_family = new)]
157        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
158    );
159}