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:))]
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 #[unsafe(super(NSObject))]
70 #[derive(Debug, PartialEq, Eq, Hash)]
71 pub struct NSTextAttachment;
72);
73
74unsafe impl NSCoding for NSTextAttachment {}
75
76unsafe impl NSObjectProtocol for NSTextAttachment {}
77
78unsafe impl NSSecureCoding for NSTextAttachment {}
79
80unsafe impl NSTextAttachmentLayout for NSTextAttachment {}
81
82impl NSTextAttachment {
83 extern_methods!(
84 #[unsafe(method(initWithData:ofType:))]
86 #[unsafe(method_family = init)]
87 pub unsafe fn initWithData_ofType(
88 this: Allocated<Self>,
89 content_data: Option<&NSData>,
90 uti: Option<&NSString>,
91 ) -> Retained<Self>;
92
93 #[unsafe(method(contents))]
95 #[unsafe(method_family = none)]
96 pub unsafe fn contents(&self) -> Option<Retained<NSData>>;
97
98 #[unsafe(method(setContents:))]
100 #[unsafe(method_family = none)]
101 pub unsafe fn setContents(&self, contents: Option<&NSData>);
102
103 #[unsafe(method(fileType))]
104 #[unsafe(method_family = none)]
105 pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;
106
107 #[unsafe(method(setFileType:))]
109 #[unsafe(method_family = none)]
110 pub unsafe fn setFileType(&self, file_type: Option<&NSString>);
111
112 #[cfg(feature = "UIImage")]
113 #[unsafe(method(image))]
115 #[unsafe(method_family = none)]
116 pub unsafe fn image(&self) -> Option<Retained<UIImage>>;
117
118 #[cfg(feature = "UIImage")]
119 #[unsafe(method(setImage:))]
121 #[unsafe(method_family = none)]
122 pub unsafe fn setImage(&self, image: Option<&UIImage>);
123
124 #[cfg(feature = "objc2-core-foundation")]
125 #[unsafe(method(bounds))]
126 #[unsafe(method_family = none)]
127 pub unsafe fn bounds(&self) -> CGRect;
128
129 #[cfg(feature = "objc2-core-foundation")]
130 #[unsafe(method(setBounds:))]
132 #[unsafe(method_family = none)]
133 pub unsafe fn setBounds(&self, bounds: CGRect);
134
135 #[unsafe(method(fileWrapper))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
139
140 #[unsafe(method(setFileWrapper:))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);
144
145 #[cfg(feature = "objc2-core-foundation")]
146 #[unsafe(method(lineLayoutPadding))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn lineLayoutPadding(&self) -> CGFloat;
149
150 #[cfg(feature = "objc2-core-foundation")]
151 #[unsafe(method(setLineLayoutPadding:))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn setLineLayoutPadding(&self, line_layout_padding: CGFloat);
155
156 #[unsafe(method(textAttachmentViewProviderClassForFileType:))]
157 #[unsafe(method_family = none)]
158 pub unsafe fn textAttachmentViewProviderClassForFileType(
159 file_type: &NSString,
160 ) -> Option<&'static AnyClass>;
161
162 #[unsafe(method(registerTextAttachmentViewProviderClass:forFileType:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn registerTextAttachmentViewProviderClass_forFileType(
165 text_attachment_view_provider_class: &AnyClass,
166 file_type: &NSString,
167 );
168
169 #[unsafe(method(allowsTextAttachmentView))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn allowsTextAttachmentView(&self) -> bool;
172
173 #[unsafe(method(setAllowsTextAttachmentView:))]
175 #[unsafe(method_family = none)]
176 pub unsafe fn setAllowsTextAttachmentView(&self, allows_text_attachment_view: bool);
177
178 #[unsafe(method(usesTextAttachmentView))]
179 #[unsafe(method_family = none)]
180 pub unsafe fn usesTextAttachmentView(&self) -> bool;
181 );
182}
183
184impl NSTextAttachment {
186 extern_methods!(
187 #[unsafe(method(init))]
188 #[unsafe(method_family = init)]
189 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
190
191 #[unsafe(method(new))]
192 #[unsafe(method_family = new)]
193 pub unsafe fn new() -> Retained<Self>;
194 );
195}
196
197mod private_NSAttributedStringAttachmentConveniences {
198 pub trait Sealed {}
199}
200
201pub unsafe trait NSAttributedStringAttachmentConveniences:
203 ClassType + Sized + private_NSAttributedStringAttachmentConveniences::Sealed
204{
205 extern_methods!(
206 #[unsafe(method(attributedStringWithAttachment:))]
207 #[unsafe(method_family = none)]
208 unsafe fn attributedStringWithAttachment(
209 attachment: &NSTextAttachment,
210 ) -> Retained<NSAttributedString>;
211
212 #[unsafe(method(attributedStringWithAttachment:attributes:))]
213 #[unsafe(method_family = none)]
214 unsafe fn attributedStringWithAttachment_attributes(
215 attachment: &NSTextAttachment,
216 attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
217 ) -> Retained<Self>;
218 );
219}
220
221impl private_NSAttributedStringAttachmentConveniences::Sealed for NSAttributedString {}
222unsafe impl NSAttributedStringAttachmentConveniences for NSAttributedString {}
223
224extern_class!(
225 #[unsafe(super(NSObject))]
227 #[derive(Debug, PartialEq, Eq, Hash)]
228 pub struct NSTextAttachmentViewProvider;
229);
230
231unsafe impl NSObjectProtocol for NSTextAttachmentViewProvider {}
232
233impl NSTextAttachmentViewProvider {
234 extern_methods!(
235 #[cfg(all(
236 feature = "NSTextLayoutManager",
237 feature = "NSTextRange",
238 feature = "UIResponder",
239 feature = "UIView"
240 ))]
241 #[unsafe(method(initWithTextAttachment:parentView:textLayoutManager:location:))]
242 #[unsafe(method_family = init)]
243 pub unsafe fn initWithTextAttachment_parentView_textLayoutManager_location(
244 this: Allocated<Self>,
245 text_attachment: &NSTextAttachment,
246 parent_view: Option<&UIView>,
247 text_layout_manager: Option<&NSTextLayoutManager>,
248 location: &ProtocolObject<dyn NSTextLocation>,
249 ) -> Retained<Self>;
250
251 #[unsafe(method(init))]
252 #[unsafe(method_family = init)]
253 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
254
255 #[unsafe(method(new))]
256 #[unsafe(method_family = new)]
257 pub unsafe fn new() -> Retained<Self>;
258
259 #[unsafe(method(textAttachment))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;
262
263 #[cfg(feature = "NSTextLayoutManager")]
264 #[unsafe(method(textLayoutManager))]
265 #[unsafe(method_family = none)]
266 pub unsafe fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
267
268 #[cfg(feature = "NSTextRange")]
269 #[unsafe(method(location))]
270 #[unsafe(method_family = none)]
271 pub unsafe fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;
272
273 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
274 #[unsafe(method(view))]
275 #[unsafe(method_family = none)]
276 pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<UIView>>;
277
278 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
279 #[unsafe(method(setView:))]
281 #[unsafe(method_family = none)]
282 pub unsafe fn setView(&self, view: Option<&UIView>);
283
284 #[unsafe(method(loadView))]
285 #[unsafe(method_family = none)]
286 pub unsafe fn loadView(&self);
287
288 #[unsafe(method(tracksTextAttachmentViewBounds))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn tracksTextAttachmentViewBounds(&self) -> bool;
291
292 #[unsafe(method(setTracksTextAttachmentViewBounds:))]
294 #[unsafe(method_family = none)]
295 pub unsafe fn setTracksTextAttachmentViewBounds(
296 &self,
297 tracks_text_attachment_view_bounds: bool,
298 );
299
300 #[cfg(all(
301 feature = "NSTextContainer",
302 feature = "NSTextRange",
303 feature = "objc2-core-foundation"
304 ))]
305 #[unsafe(method(attachmentBoundsForAttributes:location:textContainer:proposedLineFragment:position:))]
306 #[unsafe(method_family = none)]
307 pub unsafe fn attachmentBoundsForAttributes_location_textContainer_proposedLineFragment_position(
308 &self,
309 attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
310 location: &ProtocolObject<dyn NSTextLocation>,
311 text_container: Option<&NSTextContainer>,
312 proposed_line_fragment: CGRect,
313 position: CGPoint,
314 ) -> CGRect;
315 );
316}
317
318extern_protocol!(
319 pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
321 #[cfg(all(
322 feature = "NSTextContainer",
323 feature = "UIImage",
324 feature = "objc2-core-foundation"
325 ))]
326 #[unsafe(method(imageForBounds:textContainer:characterIndex:))]
327 #[unsafe(method_family = none)]
328 unsafe fn imageForBounds_textContainer_characterIndex(
329 &self,
330 image_bounds: CGRect,
331 text_container: Option<&NSTextContainer>,
332 char_index: NSUInteger,
333 ) -> Option<Retained<UIImage>>;
334
335 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
336 #[unsafe(method(attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
337 #[unsafe(method_family = none)]
338 unsafe fn attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex(
339 &self,
340 text_container: Option<&NSTextContainer>,
341 line_frag: CGRect,
342 position: CGPoint,
343 char_index: NSUInteger,
344 ) -> CGRect;
345 }
346);
347
348impl NSTextAttachment {
350 extern_methods!();
351}
352
353unsafe impl NSTextAttachmentContainer for NSTextAttachment {}