objc2_app_kit/generated/
NSTextLayoutManager.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/nstextlayoutmanagersegmenttype?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSTextLayoutManagerSegmentType(pub NSInteger);
17impl NSTextLayoutManagerSegmentType {
18    #[doc(alias = "NSTextLayoutManagerSegmentTypeStandard")]
19    pub const Standard: Self = Self(0);
20    #[doc(alias = "NSTextLayoutManagerSegmentTypeSelection")]
21    pub const Selection: Self = Self(1);
22    #[doc(alias = "NSTextLayoutManagerSegmentTypeHighlight")]
23    pub const Highlight: Self = Self(2);
24}
25
26unsafe impl Encode for NSTextLayoutManagerSegmentType {
27    const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for NSTextLayoutManagerSegmentType {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34/// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextlayoutmanagersegmentoptions?language=objc)
35// NS_OPTIONS
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct NSTextLayoutManagerSegmentOptions(pub NSUInteger);
39bitflags::bitflags! {
40    impl NSTextLayoutManagerSegmentOptions: NSUInteger {
41        #[doc(alias = "NSTextLayoutManagerSegmentOptionsNone")]
42        const None = 0;
43        #[doc(alias = "NSTextLayoutManagerSegmentOptionsRangeNotRequired")]
44        const RangeNotRequired = 1<<0;
45        #[doc(alias = "NSTextLayoutManagerSegmentOptionsMiddleFragmentsExcluded")]
46        const MiddleFragmentsExcluded = 1<<1;
47        #[doc(alias = "NSTextLayoutManagerSegmentOptionsHeadSegmentExtended")]
48        const HeadSegmentExtended = 1<<2;
49        #[doc(alias = "NSTextLayoutManagerSegmentOptionsTailSegmentExtended")]
50        const TailSegmentExtended = 1<<3;
51        #[doc(alias = "NSTextLayoutManagerSegmentOptionsUpstreamAffinity")]
52        const UpstreamAffinity = 1<<4;
53    }
54}
55
56unsafe impl Encode for NSTextLayoutManagerSegmentOptions {
57    const ENCODING: Encoding = NSUInteger::ENCODING;
58}
59
60unsafe impl RefEncode for NSTextLayoutManagerSegmentOptions {
61    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64extern_class!(
65    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextlayoutmanager?language=objc)
66    #[unsafe(super(NSObject))]
67    #[derive(Debug, PartialEq, Eq, Hash)]
68    pub struct NSTextLayoutManager;
69);
70
71unsafe impl NSCoding for NSTextLayoutManager {}
72
73unsafe impl NSObjectProtocol for NSTextLayoutManager {}
74
75unsafe impl NSSecureCoding for NSTextLayoutManager {}
76
77#[cfg(feature = "NSTextSelectionNavigation")]
78unsafe impl NSTextSelectionDataSource for NSTextLayoutManager {}
79
80impl NSTextLayoutManager {
81    extern_methods!(
82        #[unsafe(method(init))]
83        #[unsafe(method_family = init)]
84        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
85
86        #[unsafe(method(initWithCoder:))]
87        #[unsafe(method_family = init)]
88        pub unsafe fn initWithCoder(
89            this: Allocated<Self>,
90            coder: &NSCoder,
91        ) -> Option<Retained<Self>>;
92
93        #[unsafe(method(delegate))]
94        #[unsafe(method_family = none)]
95        pub unsafe fn delegate(
96            &self,
97        ) -> Option<Retained<ProtocolObject<dyn NSTextLayoutManagerDelegate>>>;
98
99        /// This is a [weak property][objc2::topics::weak_property].
100        /// Setter for [`delegate`][Self::delegate].
101        #[unsafe(method(setDelegate:))]
102        #[unsafe(method_family = none)]
103        pub unsafe fn setDelegate(
104            &self,
105            delegate: Option<&ProtocolObject<dyn NSTextLayoutManagerDelegate>>,
106        );
107
108        #[unsafe(method(usesFontLeading))]
109        #[unsafe(method_family = none)]
110        pub unsafe fn usesFontLeading(&self) -> bool;
111
112        /// Setter for [`usesFontLeading`][Self::usesFontLeading].
113        #[unsafe(method(setUsesFontLeading:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn setUsesFontLeading(&self, uses_font_leading: bool);
116
117        #[unsafe(method(limitsLayoutForSuspiciousContents))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn limitsLayoutForSuspiciousContents(&self) -> bool;
120
121        /// Setter for [`limitsLayoutForSuspiciousContents`][Self::limitsLayoutForSuspiciousContents].
122        #[unsafe(method(setLimitsLayoutForSuspiciousContents:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn setLimitsLayoutForSuspiciousContents(
125            &self,
126            limits_layout_for_suspicious_contents: bool,
127        );
128
129        #[unsafe(method(usesHyphenation))]
130        #[unsafe(method_family = none)]
131        pub unsafe fn usesHyphenation(&self) -> bool;
132
133        /// Setter for [`usesHyphenation`][Self::usesHyphenation].
134        #[unsafe(method(setUsesHyphenation:))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn setUsesHyphenation(&self, uses_hyphenation: bool);
137
138        #[cfg(feature = "NSTextContentManager")]
139        #[unsafe(method(textContentManager))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn textContentManager(&self) -> Option<Retained<NSTextContentManager>>;
142
143        #[cfg(feature = "NSTextContentManager")]
144        #[unsafe(method(replaceTextContentManager:))]
145        #[unsafe(method_family = none)]
146        pub unsafe fn replaceTextContentManager(&self, text_content_manager: &NSTextContentManager);
147
148        #[cfg(feature = "NSTextContainer")]
149        #[unsafe(method(textContainer))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn textContainer(&self) -> Option<Retained<NSTextContainer>>;
152
153        #[cfg(feature = "NSTextContainer")]
154        /// Setter for [`textContainer`][Self::textContainer].
155        #[unsafe(method(setTextContainer:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setTextContainer(&self, text_container: Option<&NSTextContainer>);
158
159        #[cfg(feature = "objc2-core-foundation")]
160        #[unsafe(method(usageBoundsForTextContainer))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn usageBoundsForTextContainer(&self) -> CGRect;
163
164        #[cfg(feature = "NSTextViewportLayoutController")]
165        #[unsafe(method(textViewportLayoutController))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn textViewportLayoutController(
168            &self,
169        ) -> Retained<NSTextViewportLayoutController>;
170
171        #[unsafe(method(layoutQueue))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn layoutQueue(&self) -> Option<Retained<NSOperationQueue>>;
174
175        /// Setter for [`layoutQueue`][Self::layoutQueue].
176        #[unsafe(method(setLayoutQueue:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setLayoutQueue(&self, layout_queue: Option<&NSOperationQueue>);
179
180        #[cfg(feature = "NSTextRange")]
181        #[unsafe(method(ensureLayoutForRange:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn ensureLayoutForRange(&self, range: &NSTextRange);
184
185        #[cfg(feature = "objc2-core-foundation")]
186        #[unsafe(method(ensureLayoutForBounds:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn ensureLayoutForBounds(&self, bounds: CGRect);
189
190        #[cfg(feature = "NSTextRange")]
191        #[unsafe(method(invalidateLayoutForRange:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn invalidateLayoutForRange(&self, range: &NSTextRange);
194
195        #[cfg(all(feature = "NSTextLayoutFragment", feature = "objc2-core-foundation"))]
196        #[unsafe(method(textLayoutFragmentForPosition:))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn textLayoutFragmentForPosition(
199            &self,
200            position: CGPoint,
201        ) -> Option<Retained<NSTextLayoutFragment>>;
202
203        #[cfg(all(feature = "NSTextLayoutFragment", feature = "NSTextRange"))]
204        #[unsafe(method(textLayoutFragmentForLocation:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn textLayoutFragmentForLocation(
207            &self,
208            location: &ProtocolObject<dyn NSTextLocation>,
209        ) -> Option<Retained<NSTextLayoutFragment>>;
210
211        #[cfg(all(
212            feature = "NSTextLayoutFragment",
213            feature = "NSTextRange",
214            feature = "block2"
215        ))]
216        #[unsafe(method(enumerateTextLayoutFragmentsFromLocation:options:usingBlock:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn enumerateTextLayoutFragmentsFromLocation_options_usingBlock(
219            &self,
220            location: Option<&ProtocolObject<dyn NSTextLocation>>,
221            options: NSTextLayoutFragmentEnumerationOptions,
222            block: &block2::Block<dyn Fn(NonNull<NSTextLayoutFragment>) -> Bool + '_>,
223        ) -> Option<Retained<ProtocolObject<dyn NSTextLocation>>>;
224
225        #[cfg(feature = "NSTextSelection")]
226        #[unsafe(method(textSelections))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn textSelections(&self) -> Retained<NSArray<NSTextSelection>>;
229
230        #[cfg(feature = "NSTextSelection")]
231        /// Setter for [`textSelections`][Self::textSelections].
232        #[unsafe(method(setTextSelections:))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn setTextSelections(&self, text_selections: &NSArray<NSTextSelection>);
235
236        #[cfg(feature = "NSTextSelectionNavigation")]
237        #[unsafe(method(textSelectionNavigation))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn textSelectionNavigation(&self) -> Retained<NSTextSelectionNavigation>;
240
241        #[cfg(feature = "NSTextSelectionNavigation")]
242        /// Setter for [`textSelectionNavigation`][Self::textSelectionNavigation].
243        #[unsafe(method(setTextSelectionNavigation:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setTextSelectionNavigation(
246            &self,
247            text_selection_navigation: &NSTextSelectionNavigation,
248        );
249
250        #[cfg(all(feature = "NSTextRange", feature = "block2"))]
251        #[unsafe(method(enumerateRenderingAttributesFromLocation:reverse:usingBlock:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn enumerateRenderingAttributesFromLocation_reverse_usingBlock(
254            &self,
255            location: &ProtocolObject<dyn NSTextLocation>,
256            reverse: bool,
257            block: &block2::Block<
258                dyn Fn(
259                        NonNull<NSTextLayoutManager>,
260                        NonNull<NSDictionary<NSAttributedStringKey, AnyObject>>,
261                        NonNull<NSTextRange>,
262                    ) -> Bool
263                    + '_,
264            >,
265        );
266
267        #[cfg(feature = "NSTextRange")]
268        #[unsafe(method(setRenderingAttributes:forTextRange:))]
269        #[unsafe(method_family = none)]
270        pub unsafe fn setRenderingAttributes_forTextRange(
271            &self,
272            rendering_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
273            text_range: &NSTextRange,
274        );
275
276        #[cfg(feature = "NSTextRange")]
277        #[unsafe(method(addRenderingAttribute:value:forTextRange:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn addRenderingAttribute_value_forTextRange(
280            &self,
281            rendering_attribute: &NSAttributedStringKey,
282            value: Option<&AnyObject>,
283            text_range: &NSTextRange,
284        );
285
286        #[cfg(feature = "NSTextRange")]
287        #[unsafe(method(removeRenderingAttribute:forTextRange:))]
288        #[unsafe(method_family = none)]
289        pub unsafe fn removeRenderingAttribute_forTextRange(
290            &self,
291            rendering_attribute: &NSAttributedStringKey,
292            text_range: &NSTextRange,
293        );
294
295        #[cfg(feature = "NSTextRange")]
296        #[unsafe(method(invalidateRenderingAttributesForTextRange:))]
297        #[unsafe(method_family = none)]
298        pub unsafe fn invalidateRenderingAttributesForTextRange(&self, text_range: &NSTextRange);
299
300        #[cfg(all(feature = "NSTextLayoutFragment", feature = "block2"))]
301        #[unsafe(method(renderingAttributesValidator))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn renderingAttributesValidator(
304            &self,
305        ) -> *mut block2::Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>;
306
307        #[cfg(all(feature = "NSTextLayoutFragment", feature = "block2"))]
308        /// Setter for [`renderingAttributesValidator`][Self::renderingAttributesValidator].
309        #[unsafe(method(setRenderingAttributesValidator:))]
310        #[unsafe(method_family = none)]
311        pub unsafe fn setRenderingAttributesValidator(
312            &self,
313            rendering_attributes_validator: Option<
314                &block2::Block<dyn Fn(NonNull<NSTextLayoutManager>, NonNull<NSTextLayoutFragment>)>,
315            >,
316        );
317
318        #[unsafe(method(linkRenderingAttributes))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn linkRenderingAttributes(
321        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
322
323        #[cfg(feature = "NSTextRange")]
324        #[unsafe(method(renderingAttributesForLink:atLocation:))]
325        #[unsafe(method_family = none)]
326        pub unsafe fn renderingAttributesForLink_atLocation(
327            &self,
328            link: &AnyObject,
329            location: &ProtocolObject<dyn NSTextLocation>,
330        ) -> Retained<NSDictionary<NSAttributedStringKey, AnyObject>>;
331
332        #[cfg(all(
333            feature = "NSTextContainer",
334            feature = "NSTextRange",
335            feature = "block2",
336            feature = "objc2-core-foundation"
337        ))]
338        #[unsafe(method(enumerateTextSegmentsInRange:type:options:usingBlock:))]
339        #[unsafe(method_family = none)]
340        pub unsafe fn enumerateTextSegmentsInRange_type_options_usingBlock(
341            &self,
342            text_range: &NSTextRange,
343            r#type: NSTextLayoutManagerSegmentType,
344            options: NSTextLayoutManagerSegmentOptions,
345            block: &block2::Block<
346                dyn Fn(*mut NSTextRange, CGRect, CGFloat, NonNull<NSTextContainer>) -> Bool + '_,
347            >,
348        );
349
350        #[cfg(all(feature = "NSTextElement", feature = "NSTextRange"))]
351        #[unsafe(method(replaceContentsInRange:withTextElements:))]
352        #[unsafe(method_family = none)]
353        pub unsafe fn replaceContentsInRange_withTextElements(
354            &self,
355            range: &NSTextRange,
356            text_elements: &NSArray<NSTextElement>,
357        );
358
359        #[cfg(feature = "NSTextRange")]
360        #[unsafe(method(replaceContentsInRange:withAttributedString:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn replaceContentsInRange_withAttributedString(
363            &self,
364            range: &NSTextRange,
365            attributed_string: &NSAttributedString,
366        );
367    );
368}
369
370/// Methods declared on superclass `NSObject`.
371impl NSTextLayoutManager {
372    extern_methods!(
373        #[unsafe(method(new))]
374        #[unsafe(method_family = new)]
375        pub unsafe fn new() -> Retained<Self>;
376    );
377}
378
379extern_protocol!(
380    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nstextlayoutmanagerdelegate?language=objc)
381    pub unsafe trait NSTextLayoutManagerDelegate: NSObjectProtocol {
382        #[cfg(all(
383            feature = "NSTextElement",
384            feature = "NSTextLayoutFragment",
385            feature = "NSTextRange"
386        ))]
387        #[optional]
388        #[unsafe(method(textLayoutManager:textLayoutFragmentForLocation:inTextElement:))]
389        #[unsafe(method_family = none)]
390        unsafe fn textLayoutManager_textLayoutFragmentForLocation_inTextElement(
391            &self,
392            text_layout_manager: &NSTextLayoutManager,
393            location: &ProtocolObject<dyn NSTextLocation>,
394            text_element: &NSTextElement,
395        ) -> Retained<NSTextLayoutFragment>;
396
397        #[cfg(feature = "NSTextRange")]
398        #[optional]
399        #[unsafe(method(textLayoutManager:shouldBreakLineBeforeLocation:hyphenating:))]
400        #[unsafe(method_family = none)]
401        unsafe fn textLayoutManager_shouldBreakLineBeforeLocation_hyphenating(
402            &self,
403            text_layout_manager: &NSTextLayoutManager,
404            location: &ProtocolObject<dyn NSTextLocation>,
405            hyphenating: bool,
406        ) -> bool;
407
408        #[cfg(feature = "NSTextRange")]
409        #[optional]
410        #[unsafe(method(textLayoutManager:renderingAttributesForLink:atLocation:defaultAttributes:))]
411        #[unsafe(method_family = none)]
412        unsafe fn textLayoutManager_renderingAttributesForLink_atLocation_defaultAttributes(
413            &self,
414            text_layout_manager: &NSTextLayoutManager,
415            link: &AnyObject,
416            location: &ProtocolObject<dyn NSTextLocation>,
417            rendering_attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
418        ) -> Option<Retained<NSDictionary<NSAttributedStringKey, AnyObject>>>;
419    }
420);