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
61extern_class!(
62    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uimenuelement?language=objc)
63    #[unsafe(super(NSObject))]
64    #[thread_kind = MainThreadOnly]
65    #[derive(Debug, PartialEq, Eq, Hash)]
66    pub struct UIMenuElement;
67);
68
69unsafe impl NSCoding for UIMenuElement {}
70
71unsafe impl NSCopying for UIMenuElement {}
72
73unsafe impl CopyingHelper for UIMenuElement {
74    type Result = Self;
75}
76
77unsafe impl NSObjectProtocol for UIMenuElement {}
78
79unsafe impl NSSecureCoding for UIMenuElement {}
80
81impl UIMenuElement {
82    extern_methods!(
83        /// The element's title.
84        #[unsafe(method(title))]
85        #[unsafe(method_family = none)]
86        pub unsafe fn title(&self) -> Retained<NSString>;
87
88        /// The element's subtitle.
89        #[unsafe(method(subtitle))]
90        #[unsafe(method_family = none)]
91        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
92
93        /// Setter for [`subtitle`][Self::subtitle].
94        #[unsafe(method(setSubtitle:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);
97
98        #[cfg(feature = "UIImage")]
99        /// Image to be displayed alongside the element's title.
100        #[unsafe(method(image))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
103
104        #[unsafe(method(initWithCoder:))]
105        #[unsafe(method_family = init)]
106        pub unsafe fn initWithCoder(
107            this: Allocated<Self>,
108            coder: &NSCoder,
109        ) -> Option<Retained<Self>>;
110
111        #[unsafe(method(init))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
114
115        #[unsafe(method(new))]
116        #[unsafe(method_family = new)]
117        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
118    );
119}