objc2_ui_kit/generated/
NSTextAttachment.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::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nsattachmentcharacter?language=objc)
13pub const NSAttachmentCharacter: c_uint = 0xFFFC;
14
15extern_protocol!(
16    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachmentlayout?language=objc)
17    pub unsafe trait NSTextAttachmentLayout: NSObjectProtocol {
18        #[cfg(all(
19            feature = "NSTextContainer",
20            feature = "NSTextRange",
21            feature = "UIImage",
22            feature = "objc2-core-foundation"
23        ))]
24        #[unsafe(method(imageForBounds:attributes:location:textContainer:))]
25        #[unsafe(method_family = none)]
26        unsafe fn imageForBounds_attributes_location_textContainer(
27            &self,
28            bounds: CGRect,
29            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
30            location: &ProtocolObject<dyn NSTextLocation>,
31            text_container: Option<&NSTextContainer>,
32        ) -> Option<Retained<UIImage>>;
33
34        #[cfg(all(
35            feature = "NSTextContainer",
36            feature = "NSTextRange",
37            feature = "objc2-core-foundation"
38        ))]
39        #[unsafe(method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:))]
40        #[unsafe(method_family = none)]
41        unsafe fn attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position(
42            &self,
43            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
44            location: &ProtocolObject<dyn NSTextLocation>,
45            text_container: Option<&NSTextContainer>,
46            proposed_line_fragment: CGRect,
47            position: CGPoint,
48        ) -> CGRect;
49
50        #[cfg(all(
51            feature = "NSTextContainer",
52            feature = "NSTextRange",
53            feature = "UIResponder",
54            feature = "UIView"
55        ))]
56        #[unsafe(method(viewProviderForParentView:location:textContainer:))]
57        #[unsafe(method_family = none)]
58        unsafe fn viewProviderForParentView_location_textContainer(
59            &self,
60            parent_view: Option<&UIView>,
61            location: &ProtocolObject<dyn NSTextLocation>,
62            text_container: Option<&NSTextContainer>,
63        ) -> Option<Retained<NSTextAttachmentViewProvider>>;
64    }
65);
66
67extern_class!(
68    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachment?language=objc)
69    #[unsafe(super(NSObject))]
70    #[derive(Debug, PartialEq, Eq, Hash)]
71    pub struct NSTextAttachment;
72);
73
74extern_conformance!(
75    unsafe impl NSCoding for NSTextAttachment {}
76);
77
78extern_conformance!(
79    unsafe impl NSObjectProtocol for NSTextAttachment {}
80);
81
82extern_conformance!(
83    unsafe impl NSSecureCoding for NSTextAttachment {}
84);
85
86extern_conformance!(
87    unsafe impl NSTextAttachmentLayout for NSTextAttachment {}
88);
89
90impl NSTextAttachment {
91    extern_methods!(
92        /// ************************** Initialization ***************************
93        #[unsafe(method(initWithData:ofType:))]
94        #[unsafe(method_family = init)]
95        pub unsafe fn initWithData_ofType(
96            this: Allocated<Self>,
97            content_data: Option<&NSData>,
98            uti: Option<&NSString>,
99        ) -> Retained<Self>;
100
101        /// ************************** Content properties ***************************
102        #[unsafe(method(contents))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn contents(&self) -> Option<Retained<NSData>>;
105
106        /// Setter for [`contents`][Self::contents].
107        #[unsafe(method(setContents:))]
108        #[unsafe(method_family = none)]
109        pub unsafe fn setContents(&self, contents: Option<&NSData>);
110
111        #[unsafe(method(fileType))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;
114
115        /// Setter for [`fileType`][Self::fileType].
116        #[unsafe(method(setFileType:))]
117        #[unsafe(method_family = none)]
118        pub unsafe fn setFileType(&self, file_type: Option<&NSString>);
119
120        #[cfg(feature = "UIImage")]
121        /// ************************** Rendering/layout properties ***************************
122        #[unsafe(method(image))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
125
126        #[cfg(feature = "UIImage")]
127        /// Setter for [`image`][Self::image].
128        #[unsafe(method(setImage:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setImage(&self, image: Option<&UIImage>);
131
132        #[cfg(feature = "objc2-core-foundation")]
133        #[unsafe(method(bounds))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn bounds(&self) -> CGRect;
136
137        #[cfg(feature = "objc2-core-foundation")]
138        /// Setter for [`bounds`][Self::bounds].
139        #[unsafe(method(setBounds:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setBounds(&self, bounds: CGRect);
142
143        /// ************************** Non-image contents properties ***************************
144        #[unsafe(method(fileWrapper))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
147
148        /// Setter for [`fileWrapper`][Self::fileWrapper].
149        #[unsafe(method(setFileWrapper:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);
152
153        #[cfg(feature = "objc2-core-foundation")]
154        #[unsafe(method(lineLayoutPadding))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn lineLayoutPadding(&self) -> CGFloat;
157
158        #[cfg(feature = "objc2-core-foundation")]
159        /// Setter for [`lineLayoutPadding`][Self::lineLayoutPadding].
160        #[unsafe(method(setLineLayoutPadding:))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn setLineLayoutPadding(&self, line_layout_padding: CGFloat);
163
164        #[unsafe(method(textAttachmentViewProviderClassForFileType:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn textAttachmentViewProviderClassForFileType(
167            file_type: &NSString,
168        ) -> Option<&'static AnyClass>;
169
170        #[unsafe(method(registerTextAttachmentViewProviderClass:forFileType:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn registerTextAttachmentViewProviderClass_forFileType(
173            text_attachment_view_provider_class: &AnyClass,
174            file_type: &NSString,
175        );
176
177        #[unsafe(method(allowsTextAttachmentView))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn allowsTextAttachmentView(&self) -> bool;
180
181        /// Setter for [`allowsTextAttachmentView`][Self::allowsTextAttachmentView].
182        #[unsafe(method(setAllowsTextAttachmentView:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setAllowsTextAttachmentView(&self, allows_text_attachment_view: bool);
185
186        #[unsafe(method(usesTextAttachmentView))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn usesTextAttachmentView(&self) -> bool;
189    );
190}
191
192/// Methods declared on superclass `NSObject`.
193impl NSTextAttachment {
194    extern_methods!(
195        #[unsafe(method(init))]
196        #[unsafe(method_family = init)]
197        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
198
199        #[unsafe(method(new))]
200        #[unsafe(method_family = new)]
201        pub unsafe fn new() -> Retained<Self>;
202    );
203}
204
205mod private_NSAttributedStringAttachmentConveniences {
206    pub trait Sealed {}
207}
208
209/// Category on [`NSAttributedString`].
210pub unsafe trait NSAttributedStringAttachmentConveniences:
211    ClassType + Sized + private_NSAttributedStringAttachmentConveniences::Sealed
212{
213    extern_methods!(
214        #[unsafe(method(attributedStringWithAttachment:))]
215        #[unsafe(method_family = none)]
216        unsafe fn attributedStringWithAttachment(
217            attachment: &NSTextAttachment,
218        ) -> Retained<NSAttributedString>;
219
220        #[unsafe(method(attributedStringWithAttachment:attributes:))]
221        #[unsafe(method_family = none)]
222        unsafe fn attributedStringWithAttachment_attributes(
223            attachment: &NSTextAttachment,
224            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
225        ) -> Retained<Self>;
226    );
227}
228
229impl private_NSAttributedStringAttachmentConveniences::Sealed for NSAttributedString {}
230unsafe impl NSAttributedStringAttachmentConveniences for NSAttributedString {}
231
232extern_class!(
233    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachmentviewprovider?language=objc)
234    #[unsafe(super(NSObject))]
235    #[derive(Debug, PartialEq, Eq, Hash)]
236    pub struct NSTextAttachmentViewProvider;
237);
238
239extern_conformance!(
240    unsafe impl NSObjectProtocol for NSTextAttachmentViewProvider {}
241);
242
243impl NSTextAttachmentViewProvider {
244    extern_methods!(
245        #[cfg(all(
246            feature = "NSTextLayoutManager",
247            feature = "NSTextRange",
248            feature = "UIResponder",
249            feature = "UIView"
250        ))]
251        #[unsafe(method(initWithTextAttachment:parentView:textLayoutManager:location:))]
252        #[unsafe(method_family = init)]
253        pub unsafe fn initWithTextAttachment_parentView_textLayoutManager_location(
254            this: Allocated<Self>,
255            text_attachment: &NSTextAttachment,
256            parent_view: Option<&UIView>,
257            text_layout_manager: Option<&NSTextLayoutManager>,
258            location: &ProtocolObject<dyn NSTextLocation>,
259        ) -> Retained<Self>;
260
261        #[unsafe(method(init))]
262        #[unsafe(method_family = init)]
263        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
264
265        #[unsafe(method(new))]
266        #[unsafe(method_family = new)]
267        pub unsafe fn new() -> Retained<Self>;
268
269        #[unsafe(method(textAttachment))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;
272
273        #[cfg(feature = "NSTextLayoutManager")]
274        #[unsafe(method(textLayoutManager))]
275        #[unsafe(method_family = none)]
276        pub unsafe fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
277
278        #[cfg(feature = "NSTextRange")]
279        #[unsafe(method(location))]
280        #[unsafe(method_family = none)]
281        pub unsafe fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;
282
283        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
284        #[unsafe(method(view))]
285        #[unsafe(method_family = none)]
286        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<UIView>>;
287
288        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
289        /// Setter for [`view`][Self::view].
290        #[unsafe(method(setView:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn setView(&self, view: Option<&UIView>);
293
294        #[unsafe(method(loadView))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn loadView(&self);
297
298        #[unsafe(method(tracksTextAttachmentViewBounds))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn tracksTextAttachmentViewBounds(&self) -> bool;
301
302        /// Setter for [`tracksTextAttachmentViewBounds`][Self::tracksTextAttachmentViewBounds].
303        #[unsafe(method(setTracksTextAttachmentViewBounds:))]
304        #[unsafe(method_family = none)]
305        pub unsafe fn setTracksTextAttachmentViewBounds(
306            &self,
307            tracks_text_attachment_view_bounds: bool,
308        );
309
310        #[cfg(all(
311            feature = "NSTextContainer",
312            feature = "NSTextRange",
313            feature = "objc2-core-foundation"
314        ))]
315        #[unsafe(method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position(
318            &self,
319            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
320            location: &ProtocolObject<dyn NSTextLocation>,
321            text_container: Option<&NSTextContainer>,
322            proposed_line_fragment: CGRect,
323            position: CGPoint,
324        ) -> CGRect;
325    );
326}
327
328extern_protocol!(
329    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextattachmentcontainer?language=objc)
330    pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
331        #[cfg(all(
332            feature = "NSTextContainer",
333            feature = "UIImage",
334            feature = "objc2-core-foundation"
335        ))]
336        #[unsafe(method(imageForBounds:textContainer:characterIndex:))]
337        #[unsafe(method_family = none)]
338        unsafe fn imageForBounds_textContainer_characterIndex(
339            &self,
340            image_bounds: CGRect,
341            text_container: Option<&NSTextContainer>,
342            char_index: NSUInteger,
343        ) -> Option<Retained<UIImage>>;
344
345        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
346        #[unsafe(method(attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
347        #[unsafe(method_family = none)]
348        unsafe fn attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex(
349            &self,
350            text_container: Option<&NSTextContainer>,
351            line_frag: CGRect,
352            position: CGPoint,
353            char_index: NSUInteger,
354        ) -> CGRect;
355    }
356);
357
358/// NSTextAttachment_Deprecation.
359impl NSTextAttachment {
360    extern_methods!();
361}
362
363extern_conformance!(
364    unsafe impl NSTextAttachmentContainer for NSTextAttachment {}
365);