objc2_app_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/appkit/nsattachmentcharacter?language=objc)
13pub const NSAttachmentCharacter: c_uint = 0xFFFC;
14
15extern_protocol!(
16    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextattachmentlayout?language=objc)
17    pub unsafe trait NSTextAttachmentLayout: NSObjectProtocol {
18        #[cfg(all(
19            feature = "NSImage",
20            feature = "NSTextContainer",
21            feature = "NSTextRange",
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<NSImage>>;
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 = "NSResponder",
52            feature = "NSTextContainer",
53            feature = "NSTextRange",
54            feature = "NSView"
55        ))]
56        #[unsafe(method(viewProviderForParentView:location:textContainer:))]
57        #[unsafe(method_family = none)]
58        unsafe fn viewProviderForParentView_location_textContainer(
59            &self,
60            parent_view: Option<&NSView>,
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/appkit/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        #[unsafe(method(initWithFileWrapper:))]
102        #[unsafe(method_family = init)]
103        pub unsafe fn initWithFileWrapper(
104            this: Allocated<Self>,
105            file_wrapper: Option<&NSFileWrapper>,
106        ) -> Retained<Self>;
107
108        /// ************************** Content properties ***************************
109        #[unsafe(method(contents))]
110        #[unsafe(method_family = none)]
111        pub unsafe fn contents(&self) -> Option<Retained<NSData>>;
112
113        /// Setter for [`contents`][Self::contents].
114        #[unsafe(method(setContents:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn setContents(&self, contents: Option<&NSData>);
117
118        #[unsafe(method(fileType))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn fileType(&self) -> Option<Retained<NSString>>;
121
122        /// Setter for [`fileType`][Self::fileType].
123        #[unsafe(method(setFileType:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setFileType(&self, file_type: Option<&NSString>);
126
127        #[cfg(feature = "NSImage")]
128        /// ************************** Rendering/layout properties ***************************
129        #[unsafe(method(image))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
132
133        #[cfg(feature = "NSImage")]
134        /// Setter for [`image`][Self::image].
135        #[unsafe(method(setImage:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setImage(&self, image: Option<&NSImage>);
138
139        #[cfg(feature = "objc2-core-foundation")]
140        #[unsafe(method(bounds))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn bounds(&self) -> CGRect;
143
144        #[cfg(feature = "objc2-core-foundation")]
145        /// Setter for [`bounds`][Self::bounds].
146        #[unsafe(method(setBounds:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setBounds(&self, bounds: CGRect);
149
150        /// ************************** Non-image contents properties ***************************
151        #[unsafe(method(fileWrapper))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn fileWrapper(&self) -> Option<Retained<NSFileWrapper>>;
154
155        /// Setter for [`fileWrapper`][Self::fileWrapper].
156        #[unsafe(method(setFileWrapper:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn setFileWrapper(&self, file_wrapper: Option<&NSFileWrapper>);
159
160        #[cfg(feature = "NSTextAttachmentCell")]
161        #[unsafe(method(attachmentCell))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn attachmentCell(
164            &self,
165        ) -> Option<Retained<ProtocolObject<dyn NSTextAttachmentCellProtocol>>>;
166
167        #[cfg(feature = "NSTextAttachmentCell")]
168        /// Setter for [`attachmentCell`][Self::attachmentCell].
169        #[unsafe(method(setAttachmentCell:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setAttachmentCell(
172            &self,
173            attachment_cell: Option<&ProtocolObject<dyn NSTextAttachmentCellProtocol>>,
174        );
175
176        #[cfg(feature = "objc2-core-foundation")]
177        #[unsafe(method(lineLayoutPadding))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn lineLayoutPadding(&self) -> CGFloat;
180
181        #[cfg(feature = "objc2-core-foundation")]
182        /// Setter for [`lineLayoutPadding`][Self::lineLayoutPadding].
183        #[unsafe(method(setLineLayoutPadding:))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn setLineLayoutPadding(&self, line_layout_padding: CGFloat);
186
187        #[unsafe(method(textAttachmentViewProviderClassForFileType:))]
188        #[unsafe(method_family = none)]
189        pub unsafe fn textAttachmentViewProviderClassForFileType(
190            file_type: &NSString,
191        ) -> Option<&'static AnyClass>;
192
193        #[unsafe(method(registerTextAttachmentViewProviderClass:forFileType:))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn registerTextAttachmentViewProviderClass_forFileType(
196            text_attachment_view_provider_class: &AnyClass,
197            file_type: &NSString,
198        );
199
200        #[unsafe(method(allowsTextAttachmentView))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn allowsTextAttachmentView(&self) -> bool;
203
204        /// Setter for [`allowsTextAttachmentView`][Self::allowsTextAttachmentView].
205        #[unsafe(method(setAllowsTextAttachmentView:))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn setAllowsTextAttachmentView(&self, allows_text_attachment_view: bool);
208
209        #[unsafe(method(usesTextAttachmentView))]
210        #[unsafe(method_family = none)]
211        pub unsafe fn usesTextAttachmentView(&self) -> bool;
212    );
213}
214
215/// Methods declared on superclass `NSObject`.
216impl NSTextAttachment {
217    extern_methods!(
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221
222        #[unsafe(method(new))]
223        #[unsafe(method_family = new)]
224        pub unsafe fn new() -> Retained<Self>;
225    );
226}
227
228mod private_NSAttributedStringAttachmentConveniences {
229    pub trait Sealed {}
230}
231
232/// Category on [`NSAttributedString`].
233pub unsafe trait NSAttributedStringAttachmentConveniences:
234    ClassType + Sized + private_NSAttributedStringAttachmentConveniences::Sealed
235{
236    extern_methods!(
237        #[unsafe(method(attributedStringWithAttachment:))]
238        #[unsafe(method_family = none)]
239        unsafe fn attributedStringWithAttachment(
240            attachment: &NSTextAttachment,
241        ) -> Retained<NSAttributedString>;
242
243        #[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    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextattachmentviewprovider?language=objc)
257    #[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 = "NSResponder",
270            feature = "NSTextLayoutManager",
271            feature = "NSTextRange",
272            feature = "NSView"
273        ))]
274        #[unsafe(method(initWithTextAttachment:parentView:textLayoutManager:location:))]
275        #[unsafe(method_family = init)]
276        pub unsafe fn initWithTextAttachment_parentView_textLayoutManager_location(
277            this: Allocated<Self>,
278            text_attachment: &NSTextAttachment,
279            parent_view: Option<&NSView>,
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 unsafe fn textAttachment(&self) -> Option<Retained<NSTextAttachment>>;
295
296        #[cfg(feature = "NSTextLayoutManager")]
297        #[unsafe(method(textLayoutManager))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn textLayoutManager(&self) -> Option<Retained<NSTextLayoutManager>>;
300
301        #[cfg(feature = "NSTextRange")]
302        #[unsafe(method(location))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn location(&self) -> Retained<ProtocolObject<dyn NSTextLocation>>;
305
306        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
307        #[unsafe(method(view))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn view(&self, mtm: MainThreadMarker) -> Option<Retained<NSView>>;
310
311        #[cfg(all(feature = "NSResponder", feature = "NSView"))]
312        /// Setter for [`view`][Self::view].
313        #[unsafe(method(setView:))]
314        #[unsafe(method_family = none)]
315        pub unsafe fn setView(&self, view: Option<&NSView>);
316
317        #[unsafe(method(loadView))]
318        #[unsafe(method_family = none)]
319        pub unsafe fn loadView(&self);
320
321        #[unsafe(method(tracksTextAttachmentViewBounds))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn tracksTextAttachmentViewBounds(&self) -> bool;
324
325        /// Setter for [`tracksTextAttachmentViewBounds`][Self::tracksTextAttachmentViewBounds].
326        #[unsafe(method(setTracksTextAttachmentViewBounds:))]
327        #[unsafe(method_family = none)]
328        pub unsafe fn setTracksTextAttachmentViewBounds(
329            &self,
330            tracks_text_attachment_view_bounds: bool,
331        );
332
333        #[cfg(all(
334            feature = "NSTextContainer",
335            feature = "NSTextRange",
336            feature = "objc2-core-foundation"
337        ))]
338        #[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
351mod private_NSMutableAttributedStringAttachmentConveniences {
352    pub trait Sealed {}
353}
354
355/// Category on [`NSMutableAttributedString`].
356pub unsafe trait NSMutableAttributedStringAttachmentConveniences:
357    ClassType + Sized + private_NSMutableAttributedStringAttachmentConveniences::Sealed
358{
359    extern_methods!(
360        #[unsafe(method(updateAttachmentsFromPath:))]
361        #[unsafe(method_family = none)]
362        unsafe fn updateAttachmentsFromPath(&self, path: &NSString);
363    );
364}
365
366impl private_NSMutableAttributedStringAttachmentConveniences::Sealed for NSMutableAttributedString {}
367unsafe impl NSMutableAttributedStringAttachmentConveniences for NSMutableAttributedString {}
368
369extern_protocol!(
370    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextattachmentcontainer?language=objc)
371    pub unsafe trait NSTextAttachmentContainer: NSObjectProtocol {
372        #[cfg(all(
373            feature = "NSImage",
374            feature = "NSTextContainer",
375            feature = "objc2-core-foundation"
376        ))]
377        #[unsafe(method(imageForBounds:textContainer:characterIndex:))]
378        #[unsafe(method_family = none)]
379        unsafe fn imageForBounds_textContainer_characterIndex(
380            &self,
381            image_bounds: CGRect,
382            text_container: Option<&NSTextContainer>,
383            char_index: NSUInteger,
384        ) -> Option<Retained<NSImage>>;
385
386        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
387        #[unsafe(method(attachmentBoundsForTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
388        #[unsafe(method_family = none)]
389        unsafe fn attachmentBoundsForTextContainer_proposedLineFragment_glyphPosition_characterIndex(
390            &self,
391            text_container: Option<&NSTextContainer>,
392            line_frag: CGRect,
393            position: CGPoint,
394            char_index: NSUInteger,
395        ) -> CGRect;
396    }
397);
398
399/// NSTextAttachment_Deprecation.
400impl NSTextAttachment {
401    extern_methods!();
402}
403
404extern_conformance!(
405    unsafe impl NSTextAttachmentContainer for NSTextAttachment {}
406);