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
69extern_conformance!(
70    unsafe impl NSCoding for UIMenuElement {}
71);
72
73extern_conformance!(
74    unsafe impl NSCopying for UIMenuElement {}
75);
76
77unsafe impl CopyingHelper for UIMenuElement {
78    type Result = Self;
79}
80
81extern_conformance!(
82    unsafe impl NSObjectProtocol for UIMenuElement {}
83);
84
85extern_conformance!(
86    unsafe impl NSSecureCoding for UIMenuElement {}
87);
88
89impl UIMenuElement {
90    extern_methods!(
91        /// The element's title.
92        #[unsafe(method(title))]
93        #[unsafe(method_family = none)]
94        pub unsafe fn title(&self) -> Retained<NSString>;
95
96        /// The element's subtitle.
97        #[unsafe(method(subtitle))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn subtitle(&self) -> Option<Retained<NSString>>;
100
101        /// Setter for [`subtitle`][Self::subtitle].
102        #[unsafe(method(setSubtitle:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setSubtitle(&self, subtitle: Option<&NSString>);
105
106        #[cfg(feature = "UIImage")]
107        /// Image to be displayed alongside the element's title.
108        #[unsafe(method(image))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
111
112        #[unsafe(method(initWithCoder:))]
113        #[unsafe(method_family = init)]
114        pub unsafe fn initWithCoder(
115            this: Allocated<Self>,
116            coder: &NSCoder,
117        ) -> Option<Retained<Self>>;
118
119        #[unsafe(method(init))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
122
123        #[unsafe(method(new))]
124        #[unsafe(method_family = new)]
125        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
126    );
127}