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
49unsafe impl NSObjectProtocol for UITextItem {}
50
51impl UITextItem {
52    extern_methods!(
53        /// The content type of the text item.
54        #[unsafe(method(contentType))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn contentType(&self) -> UITextItemContentType;
57
58        /// The range of the text item.
59        #[unsafe(method(range))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn range(&self) -> NSRange;
62
63        /// The link represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeLink`
64        #[unsafe(method(link))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn link(&self) -> Option<Retained<NSURL>>;
67
68        #[cfg(feature = "NSTextAttachment")]
69        /// The text attachment represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeTextAttachment`
70        #[unsafe(method(textAttachment))]
71        #[unsafe(method_family = none)]
72        pub unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;
73
74        /// The custom tag identifier represented by the text item. This value is `nil` if the `contentType != UITextItemContentTypeTag`
75        #[unsafe(method(tagIdentifier))]
76        #[unsafe(method_family = none)]
77        pub unsafe fn tagIdentifier(&self) -> Option<Retained<NSString>>;
78
79        #[unsafe(method(init))]
80        #[unsafe(method_family = init)]
81        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
82
83        #[unsafe(method(new))]
84        #[unsafe(method_family = new)]
85        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
86    );
87}
88
89extern_class!(
90    /// An object representing the preview for a text item.
91    ///
92    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemmenupreview?language=objc)
93    #[unsafe(super(NSObject))]
94    #[thread_kind = MainThreadOnly]
95    #[derive(Debug, PartialEq, Eq, Hash)]
96    pub struct UITextItemMenuPreview;
97);
98
99unsafe impl NSObjectProtocol for UITextItemMenuPreview {}
100
101impl UITextItemMenuPreview {
102    extern_methods!(
103        /// Show the default system preview for the given text item.
104        #[unsafe(method(defaultPreview))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn defaultPreview(mtm: MainThreadMarker) -> Retained<Self>;
107
108        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
109        /// Show the specified preview view for the given text item.
110        #[unsafe(method(initWithView:))]
111        #[unsafe(method_family = init)]
112        pub unsafe fn initWithView(this: Allocated<Self>, view: &UIView) -> Retained<Self>;
113
114        #[unsafe(method(init))]
115        #[unsafe(method_family = init)]
116        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
117
118        #[unsafe(method(new))]
119        #[unsafe(method_family = new)]
120        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
121    );
122}
123
124extern_class!(
125    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uitextitemmenuconfiguration?language=objc)
126    #[unsafe(super(NSObject))]
127    #[thread_kind = MainThreadOnly]
128    #[derive(Debug, PartialEq, Eq, Hash)]
129    pub struct UITextItemMenuConfiguration;
130);
131
132unsafe impl NSObjectProtocol for UITextItemMenuConfiguration {}
133
134impl UITextItemMenuConfiguration {
135    extern_methods!(
136        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
137        /// Creates a menu configuration with the specified menu and a default preview.
138        ///
139        ///
140        /// Parameter `menu`: The menu to be presented.
141        #[unsafe(method(configurationWithMenu:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn configurationWithMenu(menu: &UIMenu) -> Retained<Self>;
144
145        #[cfg(all(feature = "UIMenu", feature = "UIMenuElement"))]
146        /// Creates a menu configuration with the specified menu and custom preview.
147        ///
148        ///
149        /// Parameter `menu`: The menu to be presented.
150        ///
151        /// Parameter `preview`: The preview associated with the menu. Specify
152        /// `nil`for no preview.
153        #[unsafe(method(configurationWithPreview:menu:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn configurationWithPreview_menu(
156            preview: Option<&UITextItemMenuPreview>,
157            menu: &UIMenu,
158        ) -> Retained<Self>;
159
160        #[unsafe(method(init))]
161        #[unsafe(method_family = init)]
162        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
163
164        #[unsafe(method(new))]
165        #[unsafe(method_family = new)]
166        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
167    );
168}