objc2_ui_kit/generated/
UITextItem.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5use objc2_foundation::*;
6
7use crate::*;
8
9extern "C" {
10    /// The attribute name for adding a text item with a specified custom tag. The value of the attribute must be an `NSString`.
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemtagattributename?language=objc)
13    pub static UITextItemTagAttributeName: &'static NSAttributedStringKey;
14}
15
16/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemcontenttype?language=objc)
17// NS_ENUM
18#[repr(transparent)]
19#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
20pub struct UITextItemContentType(pub NSInteger);
21impl UITextItemContentType {
22    /// The text item represents a link.
23    #[doc(alias = "UITextItemContentTypeLink")]
24    pub const Link: Self = Self(0);
25    /// The text item represents a text attachment.
26    #[doc(alias = "UITextItemContentTypeTextAttachment")]
27    pub const TextAttachment: Self = Self(1);
28    /// The text item represents a custom tag.
29    #[doc(alias = "UITextItemContentTypeTag")]
30    pub const Tag: Self = Self(2);
31}
32
33unsafe impl Encode for UITextItemContentType {
34    const ENCODING: Encoding = NSInteger::ENCODING;
35}
36
37unsafe impl RefEncode for UITextItemContentType {
38    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
39}
40
41extern_class!(
42    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitem?language=objc)
43    #[unsafe(super(NSObject))]
44    #[thread_kind = MainThreadOnly]
45    #[derive(Debug, PartialEq, Eq, Hash)]
46    pub struct UITextItem;
47);
48
49extern_conformance!(
50    unsafe impl NSObjectProtocol for UITextItem {}
51);
52
53impl UITextItem {
54    extern_methods!(
55        /// The content type of the text item.
56        #[unsafe(method(contentType))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn contentType(&self) -> UITextItemContentType;
59
60        /// The range of the text item.
61        #[unsafe(method(range))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn range(&self) -> NSRange;
64
65        /// The link represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeLink`
66        #[unsafe(method(link))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn link(&self) -> Option<Retained<NSURL>>;
69
70        #[cfg(feature = "NSTextAttachment")]
71        /// The text attachment represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeTextAttachment`
72        #[unsafe(method(textAttachment))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;
75
76        /// The custom tag identifier represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeTag`
77        #[unsafe(method(tagIdentifier))]
78        #[unsafe(method_family = none)]
79        pub unsafe fn tagIdentifier(&self) -> Option<Retained<NSString>>;
80
81        #[unsafe(method(init))]
82        #[unsafe(method_family = init)]
83        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
84
85        #[unsafe(method(new))]
86        #[unsafe(method_family = new)]
87        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
88    );
89}
90
91extern_class!(
92    /// An object representing the preview for a text item.
93    ///
94    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemmenupreview?language=objc)
95    #[unsafe(super(NSObject))]
96    #[thread_kind = MainThreadOnly]
97    #[derive(Debug, PartialEq, Eq, Hash)]
98    pub struct UITextItemMenuPreview;
99);
100
101extern_conformance!(
102    unsafe impl NSObjectProtocol for UITextItemMenuPreview {}
103);
104
105impl UITextItemMenuPreview {
106    extern_methods!(
107        /// Show the default system preview for the given text item.
108        #[unsafe(method(defaultPreview))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn defaultPreview(mtm: MainThreadMarker) -> Retained<Self>;
111
112        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
113        /// Show the specified preview view for the given text item.
114        #[unsafe(method(initWithView:))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn initWithView(this: Allocated<Self>, view: &UIView) -> Retained<Self>;
117
118        #[unsafe(method(init))]
119        #[unsafe(method_family = init)]
120        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
121
122        #[unsafe(method(new))]
123        #[unsafe(method_family = new)]
124        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
125    );
126}
127
128extern_class!(
129    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemmenuconfiguration?language=objc)
130    #[unsafe(super(NSObject))]
131    #[thread_kind = MainThreadOnly]
132    #[derive(Debug, PartialEq, Eq, Hash)]
133    pub struct UITextItemMenuConfiguration;
134);
135
136extern_conformance!(
137    unsafe impl NSObjectProtocol for UITextItemMenuConfiguration {}
138);
139
140impl UITextItemMenuConfiguration {
141    extern_methods!(
142        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
143        /// Creates a menu configuration with the specified menu and a default preview.
144        ///
145        ///
146        /// Parameter `menu`: The menu to be presented.
147        #[unsafe(method(configurationWithMenu:))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn configurationWithMenu(menu: &UIMenu) -> Retained<Self>;
150
151        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
152        /// Creates a menu configuration with the specified menu and custom preview.
153        ///
154        ///
155        /// Parameter `menu`: The menu to be presented.
156        ///
157        /// Parameter `preview`: The preview associated with the menu. Specify
158        /// `nil`for no preview.
159        #[unsafe(method(configurationWithPreview:menu:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn configurationWithPreview_menu(
162            preview: Option<&UITextItemMenuPreview>,
163            menu: &UIMenu,
164        ) -> Retained<Self>;
165
166        #[unsafe(method(init))]
167        #[unsafe(method_family = init)]
168        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
169
170        #[unsafe(method(new))]
171        #[unsafe(method_family = new)]
172        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
173    );
174}