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