objc2_ui_kit/generated/
NSLayoutManager.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::*;
8#[cfg(feature = "objc2-core-graphics")]
9use objc2_core_graphics::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextlayoutorientation?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct NSTextLayoutOrientation(pub NSInteger);
19impl NSTextLayoutOrientation {
20    #[doc(alias = "NSTextLayoutOrientationHorizontal")]
21    pub const Horizontal: Self = Self(0);
22    #[doc(alias = "NSTextLayoutOrientationVertical")]
23    pub const Vertical: Self = Self(1);
24}
25
26unsafe impl Encode for NSTextLayoutOrientation {
27    const ENCODING: Encoding = NSInteger::ENCODING;
28}
29
30unsafe impl RefEncode for NSTextLayoutOrientation {
31    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
32}
33
34/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nsglyphproperty?language=objc)
35// NS_OPTIONS
36#[repr(transparent)]
37#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
38pub struct NSGlyphProperty(pub NSInteger);
39bitflags::bitflags! {
40    impl NSGlyphProperty: NSInteger {
41        #[doc(alias = "NSGlyphPropertyNull")]
42        const Null = 1<<0;
43        #[doc(alias = "NSGlyphPropertyControlCharacter")]
44        const ControlCharacter = 1<<1;
45        #[doc(alias = "NSGlyphPropertyElastic")]
46        const Elastic = 1<<2;
47        #[doc(alias = "NSGlyphPropertyNonBaseCharacter")]
48        const NonBaseCharacter = 1<<3;
49    }
50}
51
52unsafe impl Encode for NSGlyphProperty {
53    const ENCODING: Encoding = NSInteger::ENCODING;
54}
55
56unsafe impl RefEncode for NSGlyphProperty {
57    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacteraction?language=objc)
61// NS_OPTIONS
62#[repr(transparent)]
63#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
64pub struct NSControlCharacterAction(pub NSInteger);
65bitflags::bitflags! {
66    impl NSControlCharacterAction: NSInteger {
67        #[doc(alias = "NSControlCharacterActionZeroAdvancement")]
68        const ZeroAdvancement = 1<<0;
69        #[doc(alias = "NSControlCharacterActionWhitespace")]
70        const Whitespace = 1<<1;
71        #[doc(alias = "NSControlCharacterActionHorizontalTab")]
72        const HorizontalTab = 1<<2;
73        #[doc(alias = "NSControlCharacterActionLineBreak")]
74        const LineBreak = 1<<3;
75        #[doc(alias = "NSControlCharacterActionParagraphBreak")]
76        const ParagraphBreak = 1<<4;
77        #[doc(alias = "NSControlCharacterActionContainerBreak")]
78        const ContainerBreak = 1<<5;
79    }
80}
81
82unsafe impl Encode for NSControlCharacterAction {
83    const ENCODING: Encoding = NSInteger::ENCODING;
84}
85
86unsafe impl RefEncode for NSControlCharacterAction {
87    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
88}
89
90extern_protocol!(
91    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nstextlayoutorientationprovider?language=objc)
92    pub unsafe trait NSTextLayoutOrientationProvider {
93        #[unsafe(method(layoutOrientation))]
94        #[unsafe(method_family = none)]
95        unsafe fn layoutOrientation(&self) -> NSTextLayoutOrientation;
96    }
97);
98
99extern_class!(
100    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutmanager?language=objc)
101    #[unsafe(super(NSObject))]
102    #[derive(Debug, PartialEq, Eq, Hash)]
103    pub struct NSLayoutManager;
104);
105
106extern_conformance!(
107    unsafe impl NSCoding for NSLayoutManager {}
108);
109
110extern_conformance!(
111    unsafe impl NSObjectProtocol for NSLayoutManager {}
112);
113
114extern_conformance!(
115    unsafe impl NSSecureCoding for NSLayoutManager {}
116);
117
118impl NSLayoutManager {
119    extern_methods!(
120        /// ************************** Initialization ***************************
121        #[unsafe(method(init))]
122        #[unsafe(method_family = init)]
123        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
124
125        #[unsafe(method(initWithCoder:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithCoder(
128            this: Allocated<Self>,
129            coder: &NSCoder,
130        ) -> Option<Retained<Self>>;
131
132        #[cfg(feature = "NSTextStorage")]
133        /// ************************* Text storage **************************
134        #[unsafe(method(textStorage))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
137
138        #[cfg(feature = "NSTextStorage")]
139        /// Setter for [`textStorage`][Self::textStorage].
140        #[unsafe(method(setTextStorage:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
143
144        #[cfg(feature = "NSTextContainer")]
145        /// ************************** Text containers ***************************
146        #[unsafe(method(textContainers))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn textContainers(&self) -> Retained<NSArray<NSTextContainer>>;
149
150        #[cfg(feature = "NSTextContainer")]
151        #[unsafe(method(addTextContainer:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn addTextContainer(&self, container: &NSTextContainer);
154
155        #[cfg(feature = "NSTextContainer")]
156        #[unsafe(method(insertTextContainer:atIndex:))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn insertTextContainer_atIndex(
159            &self,
160            container: &NSTextContainer,
161            index: NSUInteger,
162        );
163
164        #[unsafe(method(removeTextContainerAtIndex:))]
165        #[unsafe(method_family = none)]
166        pub unsafe fn removeTextContainerAtIndex(&self, index: NSUInteger);
167
168        #[cfg(feature = "NSTextContainer")]
169        #[unsafe(method(textContainerChangedGeometry:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn textContainerChangedGeometry(&self, container: &NSTextContainer);
172
173        /// ************************** Delegate ***************************
174        #[unsafe(method(delegate))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn delegate(
177            &self,
178        ) -> Option<Retained<ProtocolObject<dyn NSLayoutManagerDelegate>>>;
179
180        /// This is a [weak property][objc2::topics::weak_property].
181        /// Setter for [`delegate`][Self::delegate].
182        #[unsafe(method(setDelegate:))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn setDelegate(
185            &self,
186            delegate: Option<&ProtocolObject<dyn NSLayoutManagerDelegate>>,
187        );
188
189        /// ********************* Global layout manager options **********************
190        #[unsafe(method(showsInvisibleCharacters))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn showsInvisibleCharacters(&self) -> bool;
193
194        /// Setter for [`showsInvisibleCharacters`][Self::showsInvisibleCharacters].
195        #[unsafe(method(setShowsInvisibleCharacters:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn setShowsInvisibleCharacters(&self, shows_invisible_characters: bool);
198
199        #[unsafe(method(showsControlCharacters))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn showsControlCharacters(&self) -> bool;
202
203        /// Setter for [`showsControlCharacters`][Self::showsControlCharacters].
204        #[unsafe(method(setShowsControlCharacters:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setShowsControlCharacters(&self, shows_control_characters: bool);
207
208        #[unsafe(method(usesFontLeading))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn usesFontLeading(&self) -> bool;
211
212        /// Setter for [`usesFontLeading`][Self::usesFontLeading].
213        #[unsafe(method(setUsesFontLeading:))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn setUsesFontLeading(&self, uses_font_leading: bool);
216
217        #[unsafe(method(allowsNonContiguousLayout))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn allowsNonContiguousLayout(&self) -> bool;
220
221        /// Setter for [`allowsNonContiguousLayout`][Self::allowsNonContiguousLayout].
222        #[unsafe(method(setAllowsNonContiguousLayout:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setAllowsNonContiguousLayout(&self, allows_non_contiguous_layout: bool);
225
226        #[unsafe(method(hasNonContiguousLayout))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn hasNonContiguousLayout(&self) -> bool;
229
230        #[unsafe(method(limitsLayoutForSuspiciousContents))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn limitsLayoutForSuspiciousContents(&self) -> bool;
233
234        /// Setter for [`limitsLayoutForSuspiciousContents`][Self::limitsLayoutForSuspiciousContents].
235        #[unsafe(method(setLimitsLayoutForSuspiciousContents:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn setLimitsLayoutForSuspiciousContents(
238            &self,
239            limits_layout_for_suspicious_contents: bool,
240        );
241
242        #[unsafe(method(usesDefaultHyphenation))]
243        #[unsafe(method_family = none)]
244        pub unsafe fn usesDefaultHyphenation(&self) -> bool;
245
246        /// Setter for [`usesDefaultHyphenation`][Self::usesDefaultHyphenation].
247        #[unsafe(method(setUsesDefaultHyphenation:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setUsesDefaultHyphenation(&self, uses_default_hyphenation: bool);
250
251        /// ************************ Invalidation *************************
252        #[unsafe(method(invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:))]
253        #[unsafe(method_family = none)]
254        pub unsafe fn invalidateGlyphsForCharacterRange_changeInLength_actualCharacterRange(
255            &self,
256            char_range: NSRange,
257            delta: NSInteger,
258            actual_char_range: NSRangePointer,
259        );
260
261        #[unsafe(method(invalidateLayoutForCharacterRange:actualCharacterRange:))]
262        #[unsafe(method_family = none)]
263        pub unsafe fn invalidateLayoutForCharacterRange_actualCharacterRange(
264            &self,
265            char_range: NSRange,
266            actual_char_range: NSRangePointer,
267        );
268
269        #[unsafe(method(invalidateDisplayForCharacterRange:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn invalidateDisplayForCharacterRange(&self, char_range: NSRange);
272
273        #[unsafe(method(invalidateDisplayForGlyphRange:))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn invalidateDisplayForGlyphRange(&self, glyph_range: NSRange);
276
277        #[cfg(feature = "NSTextStorage")]
278        #[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
281            &self,
282            text_storage: &NSTextStorage,
283            edit_mask: NSTextStorageEditActions,
284            new_char_range: NSRange,
285            delta: NSInteger,
286            invalidated_char_range: NSRange,
287        );
288
289        /// ********************** Causing glyph generation and layout ***********************
290        #[unsafe(method(ensureGlyphsForCharacterRange:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn ensureGlyphsForCharacterRange(&self, char_range: NSRange);
293
294        #[unsafe(method(ensureGlyphsForGlyphRange:))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn ensureGlyphsForGlyphRange(&self, glyph_range: NSRange);
297
298        #[unsafe(method(ensureLayoutForCharacterRange:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn ensureLayoutForCharacterRange(&self, char_range: NSRange);
301
302        #[unsafe(method(ensureLayoutForGlyphRange:))]
303        #[unsafe(method_family = none)]
304        pub unsafe fn ensureLayoutForGlyphRange(&self, glyph_range: NSRange);
305
306        #[cfg(feature = "NSTextContainer")]
307        #[unsafe(method(ensureLayoutForTextContainer:))]
308        #[unsafe(method_family = none)]
309        pub unsafe fn ensureLayoutForTextContainer(&self, container: &NSTextContainer);
310
311        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
312        #[unsafe(method(ensureLayoutForBoundingRect:inTextContainer:))]
313        #[unsafe(method_family = none)]
314        pub unsafe fn ensureLayoutForBoundingRect_inTextContainer(
315            &self,
316            bounds: CGRect,
317            container: &NSTextContainer,
318        );
319
320        #[cfg(all(feature = "UIFont", feature = "objc2-core-graphics"))]
321        /// ********************** Set glyphs and glyph properties ***********************
322        #[unsafe(method(setGlyphs:properties:characterIndexes:font:forGlyphRange:))]
323        #[unsafe(method_family = none)]
324        pub unsafe fn setGlyphs_properties_characterIndexes_font_forGlyphRange(
325            &self,
326            glyphs: NonNull<CGGlyph>,
327            props: NonNull<NSGlyphProperty>,
328            char_indexes: NonNull<NSUInteger>,
329            a_font: &UIFont,
330            glyph_range: NSRange,
331        );
332
333        /// ********************** Get glyphs and glyph properties ***********************
334        #[unsafe(method(numberOfGlyphs))]
335        #[unsafe(method_family = none)]
336        pub unsafe fn numberOfGlyphs(&self) -> NSUInteger;
337
338        #[cfg(feature = "objc2-core-graphics")]
339        #[unsafe(method(CGGlyphAtIndex:isValidIndex:))]
340        #[unsafe(method_family = none)]
341        pub unsafe fn CGGlyphAtIndex_isValidIndex(
342            &self,
343            glyph_index: NSUInteger,
344            is_valid_index: *mut Bool,
345        ) -> CGGlyph;
346
347        #[cfg(feature = "objc2-core-graphics")]
348        #[unsafe(method(CGGlyphAtIndex:))]
349        #[unsafe(method_family = none)]
350        pub unsafe fn CGGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGGlyph;
351
352        #[unsafe(method(isValidGlyphIndex:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn isValidGlyphIndex(&self, glyph_index: NSUInteger) -> bool;
355
356        #[unsafe(method(propertyForGlyphAtIndex:))]
357        #[unsafe(method_family = none)]
358        pub unsafe fn propertyForGlyphAtIndex(&self, glyph_index: NSUInteger) -> NSGlyphProperty;
359
360        #[unsafe(method(characterIndexForGlyphAtIndex:))]
361        #[unsafe(method_family = none)]
362        pub unsafe fn characterIndexForGlyphAtIndex(&self, glyph_index: NSUInteger) -> NSUInteger;
363
364        #[unsafe(method(glyphIndexForCharacterAtIndex:))]
365        #[unsafe(method_family = none)]
366        pub unsafe fn glyphIndexForCharacterAtIndex(&self, char_index: NSUInteger) -> NSUInteger;
367
368        #[cfg(feature = "objc2-core-graphics")]
369        #[unsafe(method(getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:))]
370        #[unsafe(method_family = none)]
371        pub unsafe fn getGlyphsInRange_glyphs_properties_characterIndexes_bidiLevels(
372            &self,
373            glyph_range: NSRange,
374            glyph_buffer: *mut CGGlyph,
375            props: *mut NSGlyphProperty,
376            char_index_buffer: *mut NSUInteger,
377            bidi_level_buffer: *mut c_uchar,
378        ) -> NSUInteger;
379
380        #[cfg(feature = "NSTextContainer")]
381        #[unsafe(method(setTextContainer:forGlyphRange:))]
382        #[unsafe(method_family = none)]
383        pub unsafe fn setTextContainer_forGlyphRange(
384            &self,
385            container: &NSTextContainer,
386            glyph_range: NSRange,
387        );
388
389        #[cfg(feature = "objc2-core-foundation")]
390        #[unsafe(method(setLineFragmentRect:forGlyphRange:usedRect:))]
391        #[unsafe(method_family = none)]
392        pub unsafe fn setLineFragmentRect_forGlyphRange_usedRect(
393            &self,
394            fragment_rect: CGRect,
395            glyph_range: NSRange,
396            used_rect: CGRect,
397        );
398
399        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
400        #[unsafe(method(setExtraLineFragmentRect:usedRect:textContainer:))]
401        #[unsafe(method_family = none)]
402        pub unsafe fn setExtraLineFragmentRect_usedRect_textContainer(
403            &self,
404            fragment_rect: CGRect,
405            used_rect: CGRect,
406            container: &NSTextContainer,
407        );
408
409        #[cfg(feature = "objc2-core-foundation")]
410        #[unsafe(method(setLocation:forStartOfGlyphRange:))]
411        #[unsafe(method_family = none)]
412        pub unsafe fn setLocation_forStartOfGlyphRange(
413            &self,
414            location: CGPoint,
415            glyph_range: NSRange,
416        );
417
418        #[unsafe(method(setNotShownAttribute:forGlyphAtIndex:))]
419        #[unsafe(method_family = none)]
420        pub unsafe fn setNotShownAttribute_forGlyphAtIndex(
421            &self,
422            flag: bool,
423            glyph_index: NSUInteger,
424        );
425
426        #[unsafe(method(setDrawsOutsideLineFragment:forGlyphAtIndex:))]
427        #[unsafe(method_family = none)]
428        pub unsafe fn setDrawsOutsideLineFragment_forGlyphAtIndex(
429            &self,
430            flag: bool,
431            glyph_index: NSUInteger,
432        );
433
434        #[cfg(feature = "objc2-core-foundation")]
435        #[unsafe(method(setAttachmentSize:forGlyphRange:))]
436        #[unsafe(method_family = none)]
437        pub unsafe fn setAttachmentSize_forGlyphRange(
438            &self,
439            attachment_size: CGSize,
440            glyph_range: NSRange,
441        );
442
443        /// ********************** Get layout information ***********************
444        #[unsafe(method(getFirstUnlaidCharacterIndex:glyphIndex:))]
445        #[unsafe(method_family = none)]
446        pub unsafe fn getFirstUnlaidCharacterIndex_glyphIndex(
447            &self,
448            char_index: *mut NSUInteger,
449            glyph_index: *mut NSUInteger,
450        );
451
452        #[unsafe(method(firstUnlaidCharacterIndex))]
453        #[unsafe(method_family = none)]
454        pub unsafe fn firstUnlaidCharacterIndex(&self) -> NSUInteger;
455
456        #[unsafe(method(firstUnlaidGlyphIndex))]
457        #[unsafe(method_family = none)]
458        pub unsafe fn firstUnlaidGlyphIndex(&self) -> NSUInteger;
459
460        #[cfg(feature = "NSTextContainer")]
461        #[unsafe(method(textContainerForGlyphAtIndex:effectiveRange:))]
462        #[unsafe(method_family = none)]
463        pub unsafe fn textContainerForGlyphAtIndex_effectiveRange(
464            &self,
465            glyph_index: NSUInteger,
466            effective_glyph_range: NSRangePointer,
467        ) -> Option<Retained<NSTextContainer>>;
468
469        #[cfg(feature = "NSTextContainer")]
470        #[unsafe(method(textContainerForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
471        #[unsafe(method_family = none)]
472        pub unsafe fn textContainerForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
473            &self,
474            glyph_index: NSUInteger,
475            effective_glyph_range: NSRangePointer,
476            flag: bool,
477        ) -> Option<Retained<NSTextContainer>>;
478
479        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
480        #[unsafe(method(usedRectForTextContainer:))]
481        #[unsafe(method_family = none)]
482        pub unsafe fn usedRectForTextContainer(&self, container: &NSTextContainer) -> CGRect;
483
484        #[cfg(feature = "objc2-core-foundation")]
485        #[unsafe(method(lineFragmentRectForGlyphAtIndex:effectiveRange:))]
486        #[unsafe(method_family = none)]
487        pub unsafe fn lineFragmentRectForGlyphAtIndex_effectiveRange(
488            &self,
489            glyph_index: NSUInteger,
490            effective_glyph_range: NSRangePointer,
491        ) -> CGRect;
492
493        #[cfg(feature = "objc2-core-foundation")]
494        #[unsafe(method(lineFragmentRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
495        #[unsafe(method_family = none)]
496        pub unsafe fn lineFragmentRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
497            &self,
498            glyph_index: NSUInteger,
499            effective_glyph_range: NSRangePointer,
500            flag: bool,
501        ) -> CGRect;
502
503        #[cfg(feature = "objc2-core-foundation")]
504        #[unsafe(method(lineFragmentUsedRectForGlyphAtIndex:effectiveRange:))]
505        #[unsafe(method_family = none)]
506        pub unsafe fn lineFragmentUsedRectForGlyphAtIndex_effectiveRange(
507            &self,
508            glyph_index: NSUInteger,
509            effective_glyph_range: NSRangePointer,
510        ) -> CGRect;
511
512        #[cfg(feature = "objc2-core-foundation")]
513        #[unsafe(method(lineFragmentUsedRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
514        #[unsafe(method_family = none)]
515        pub unsafe fn lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
516            &self,
517            glyph_index: NSUInteger,
518            effective_glyph_range: NSRangePointer,
519            flag: bool,
520        ) -> CGRect;
521
522        #[cfg(feature = "objc2-core-foundation")]
523        #[unsafe(method(extraLineFragmentRect))]
524        #[unsafe(method_family = none)]
525        pub unsafe fn extraLineFragmentRect(&self) -> CGRect;
526
527        #[cfg(feature = "objc2-core-foundation")]
528        #[unsafe(method(extraLineFragmentUsedRect))]
529        #[unsafe(method_family = none)]
530        pub unsafe fn extraLineFragmentUsedRect(&self) -> CGRect;
531
532        #[cfg(feature = "NSTextContainer")]
533        #[unsafe(method(extraLineFragmentTextContainer))]
534        #[unsafe(method_family = none)]
535        pub unsafe fn extraLineFragmentTextContainer(&self) -> Option<Retained<NSTextContainer>>;
536
537        #[cfg(feature = "objc2-core-foundation")]
538        #[unsafe(method(locationForGlyphAtIndex:))]
539        #[unsafe(method_family = none)]
540        pub unsafe fn locationForGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGPoint;
541
542        #[unsafe(method(notShownAttributeForGlyphAtIndex:))]
543        #[unsafe(method_family = none)]
544        pub unsafe fn notShownAttributeForGlyphAtIndex(&self, glyph_index: NSUInteger) -> bool;
545
546        #[unsafe(method(drawsOutsideLineFragmentForGlyphAtIndex:))]
547        #[unsafe(method_family = none)]
548        pub unsafe fn drawsOutsideLineFragmentForGlyphAtIndex(
549            &self,
550            glyph_index: NSUInteger,
551        ) -> bool;
552
553        #[cfg(feature = "objc2-core-foundation")]
554        #[unsafe(method(attachmentSizeForGlyphAtIndex:))]
555        #[unsafe(method_family = none)]
556        pub unsafe fn attachmentSizeForGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGSize;
557
558        #[unsafe(method(truncatedGlyphRangeInLineFragmentForGlyphAtIndex:))]
559        #[unsafe(method_family = none)]
560        pub unsafe fn truncatedGlyphRangeInLineFragmentForGlyphAtIndex(
561            &self,
562            glyph_index: NSUInteger,
563        ) -> NSRange;
564
565        /// ********************** More sophisticated queries ***********************
566        #[unsafe(method(glyphRangeForCharacterRange:actualCharacterRange:))]
567        #[unsafe(method_family = none)]
568        pub unsafe fn glyphRangeForCharacterRange_actualCharacterRange(
569            &self,
570            char_range: NSRange,
571            actual_char_range: NSRangePointer,
572        ) -> NSRange;
573
574        #[unsafe(method(characterRangeForGlyphRange:actualGlyphRange:))]
575        #[unsafe(method_family = none)]
576        pub unsafe fn characterRangeForGlyphRange_actualGlyphRange(
577            &self,
578            glyph_range: NSRange,
579            actual_glyph_range: NSRangePointer,
580        ) -> NSRange;
581
582        #[cfg(feature = "NSTextContainer")]
583        #[unsafe(method(glyphRangeForTextContainer:))]
584        #[unsafe(method_family = none)]
585        pub unsafe fn glyphRangeForTextContainer(&self, container: &NSTextContainer) -> NSRange;
586
587        #[unsafe(method(rangeOfNominallySpacedGlyphsContainingIndex:))]
588        #[unsafe(method_family = none)]
589        pub unsafe fn rangeOfNominallySpacedGlyphsContainingIndex(
590            &self,
591            glyph_index: NSUInteger,
592        ) -> NSRange;
593
594        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
595        #[unsafe(method(boundingRectForGlyphRange:inTextContainer:))]
596        #[unsafe(method_family = none)]
597        pub unsafe fn boundingRectForGlyphRange_inTextContainer(
598            &self,
599            glyph_range: NSRange,
600            container: &NSTextContainer,
601        ) -> CGRect;
602
603        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
604        #[unsafe(method(glyphRangeForBoundingRect:inTextContainer:))]
605        #[unsafe(method_family = none)]
606        pub unsafe fn glyphRangeForBoundingRect_inTextContainer(
607            &self,
608            bounds: CGRect,
609            container: &NSTextContainer,
610        ) -> NSRange;
611
612        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
613        #[unsafe(method(glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:))]
614        #[unsafe(method_family = none)]
615        pub unsafe fn glyphRangeForBoundingRectWithoutAdditionalLayout_inTextContainer(
616            &self,
617            bounds: CGRect,
618            container: &NSTextContainer,
619        ) -> NSRange;
620
621        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
622        #[unsafe(method(glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:))]
623        #[unsafe(method_family = none)]
624        pub unsafe fn glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph(
625            &self,
626            point: CGPoint,
627            container: &NSTextContainer,
628            partial_fraction: *mut CGFloat,
629        ) -> NSUInteger;
630
631        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
632        #[unsafe(method(glyphIndexForPoint:inTextContainer:))]
633        #[unsafe(method_family = none)]
634        pub unsafe fn glyphIndexForPoint_inTextContainer(
635            &self,
636            point: CGPoint,
637            container: &NSTextContainer,
638        ) -> NSUInteger;
639
640        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
641        #[unsafe(method(fractionOfDistanceThroughGlyphForPoint:inTextContainer:))]
642        #[unsafe(method_family = none)]
643        pub unsafe fn fractionOfDistanceThroughGlyphForPoint_inTextContainer(
644            &self,
645            point: CGPoint,
646            container: &NSTextContainer,
647        ) -> CGFloat;
648
649        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
650        #[unsafe(method(characterIndexForPoint:inTextContainer:fractionOfDistanceBetweenInsertionPoints:))]
651        #[unsafe(method_family = none)]
652        pub unsafe fn characterIndexForPoint_inTextContainer_fractionOfDistanceBetweenInsertionPoints(
653            &self,
654            point: CGPoint,
655            container: &NSTextContainer,
656            partial_fraction: *mut CGFloat,
657        ) -> NSUInteger;
658
659        #[cfg(feature = "objc2-core-foundation")]
660        #[unsafe(method(getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:inDisplayOrder:positions:characterIndexes:))]
661        #[unsafe(method_family = none)]
662        pub unsafe fn getLineFragmentInsertionPointsForCharacterAtIndex_alternatePositions_inDisplayOrder_positions_characterIndexes(
663            &self,
664            char_index: NSUInteger,
665            a_flag: bool,
666            d_flag: bool,
667            positions: *mut CGFloat,
668            char_indexes: *mut NSUInteger,
669        ) -> NSUInteger;
670
671        #[cfg(all(
672            feature = "NSTextContainer",
673            feature = "block2",
674            feature = "objc2-core-foundation"
675        ))]
676        #[unsafe(method(enumerateLineFragmentsForGlyphRange:usingBlock:))]
677        #[unsafe(method_family = none)]
678        pub unsafe fn enumerateLineFragmentsForGlyphRange_usingBlock(
679            &self,
680            glyph_range: NSRange,
681            block: &block2::DynBlock<
682                dyn Fn(CGRect, CGRect, NonNull<NSTextContainer>, NSRange, NonNull<Bool>),
683            >,
684        );
685
686        #[cfg(all(
687            feature = "NSTextContainer",
688            feature = "block2",
689            feature = "objc2-core-foundation"
690        ))]
691        #[unsafe(method(enumerateEnclosingRectsForGlyphRange:withinSelectedGlyphRange:inTextContainer:usingBlock:))]
692        #[unsafe(method_family = none)]
693        pub unsafe fn enumerateEnclosingRectsForGlyphRange_withinSelectedGlyphRange_inTextContainer_usingBlock(
694            &self,
695            glyph_range: NSRange,
696            selected_range: NSRange,
697            text_container: &NSTextContainer,
698            block: &block2::DynBlock<dyn Fn(CGRect, NonNull<Bool>)>,
699        );
700
701        #[cfg(feature = "objc2-core-foundation")]
702        /// ********************** Drawing support ***********************
703        #[unsafe(method(drawBackgroundForGlyphRange:atPoint:))]
704        #[unsafe(method_family = none)]
705        pub unsafe fn drawBackgroundForGlyphRange_atPoint(
706            &self,
707            glyphs_to_show: NSRange,
708            origin: CGPoint,
709        );
710
711        #[cfg(feature = "objc2-core-foundation")]
712        #[unsafe(method(drawGlyphsForGlyphRange:atPoint:))]
713        #[unsafe(method_family = none)]
714        pub unsafe fn drawGlyphsForGlyphRange_atPoint(
715            &self,
716            glyphs_to_show: NSRange,
717            origin: CGPoint,
718        );
719
720        #[cfg(all(
721            feature = "UIFont",
722            feature = "objc2-core-foundation",
723            feature = "objc2-core-graphics"
724        ))]
725        #[unsafe(method(showCGGlyphs:positions:count:font:textMatrix:attributes:inContext:))]
726        #[unsafe(method_family = none)]
727        pub unsafe fn showCGGlyphs_positions_count_font_textMatrix_attributes_inContext(
728            &self,
729            glyphs: NonNull<CGGlyph>,
730            positions: NonNull<CGPoint>,
731            glyph_count: NSInteger,
732            font: &UIFont,
733            text_matrix: CGAffineTransform,
734            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
735            cg_context: &CGContext,
736        );
737
738        #[cfg(all(feature = "UIColor", feature = "objc2-core-foundation"))]
739        #[unsafe(method(fillBackgroundRectArray:count:forCharacterRange:color:))]
740        #[unsafe(method_family = none)]
741        pub unsafe fn fillBackgroundRectArray_count_forCharacterRange_color(
742            &self,
743            rect_array: NonNull<CGRect>,
744            rect_count: NSUInteger,
745            char_range: NSRange,
746            color: &UIColor,
747        );
748
749        #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
750        #[unsafe(method(drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
751        #[unsafe(method_family = none)]
752        pub unsafe fn drawUnderlineForGlyphRange_underlineType_baselineOffset_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
753            &self,
754            glyph_range: NSRange,
755            underline_val: NSUnderlineStyle,
756            baseline_offset: CGFloat,
757            line_rect: CGRect,
758            line_glyph_range: NSRange,
759            container_origin: CGPoint,
760        );
761
762        #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
763        #[unsafe(method(underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
764        #[unsafe(method_family = none)]
765        pub unsafe fn underlineGlyphRange_underlineType_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
766            &self,
767            glyph_range: NSRange,
768            underline_val: NSUnderlineStyle,
769            line_rect: CGRect,
770            line_glyph_range: NSRange,
771            container_origin: CGPoint,
772        );
773
774        #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
775        #[unsafe(method(drawStrikethroughForGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
776        #[unsafe(method_family = none)]
777        pub unsafe fn drawStrikethroughForGlyphRange_strikethroughType_baselineOffset_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
778            &self,
779            glyph_range: NSRange,
780            strikethrough_val: NSUnderlineStyle,
781            baseline_offset: CGFloat,
782            line_rect: CGRect,
783            line_glyph_range: NSRange,
784            container_origin: CGPoint,
785        );
786
787        #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
788        #[unsafe(method(strikethroughGlyphRange:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
789        #[unsafe(method_family = none)]
790        pub unsafe fn strikethroughGlyphRange_strikethroughType_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
791            &self,
792            glyph_range: NSRange,
793            strikethrough_val: NSUnderlineStyle,
794            line_rect: CGRect,
795            line_glyph_range: NSRange,
796            container_origin: CGPoint,
797        );
798    );
799}
800
801/// Methods declared on superclass `NSObject`.
802impl NSLayoutManager {
803    extern_methods!(
804        #[unsafe(method(new))]
805        #[unsafe(method_family = new)]
806        pub unsafe fn new() -> Retained<Self>;
807    );
808}
809
810extern_protocol!(
811    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutmanagerdelegate?language=objc)
812    pub unsafe trait NSLayoutManagerDelegate: NSObjectProtocol {
813        #[cfg(all(feature = "UIFont", feature = "objc2-core-graphics"))]
814        /// ********************** Glyph generation ***********************
815        #[optional]
816        #[unsafe(method(layoutManager:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:))]
817        #[unsafe(method_family = none)]
818        unsafe fn layoutManager_shouldGenerateGlyphs_properties_characterIndexes_font_forGlyphRange(
819            &self,
820            layout_manager: &NSLayoutManager,
821            glyphs: NonNull<CGGlyph>,
822            props: NonNull<NSGlyphProperty>,
823            char_indexes: NonNull<NSUInteger>,
824            a_font: &UIFont,
825            glyph_range: NSRange,
826        ) -> NSUInteger;
827
828        #[cfg(feature = "objc2-core-foundation")]
829        /// ********************** Line layout ***********************
830        #[optional]
831        #[unsafe(method(layoutManager:lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
832        #[unsafe(method_family = none)]
833        unsafe fn layoutManager_lineSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
834            &self,
835            layout_manager: &NSLayoutManager,
836            glyph_index: NSUInteger,
837            rect: CGRect,
838        ) -> CGFloat;
839
840        #[cfg(feature = "objc2-core-foundation")]
841        #[optional]
842        #[unsafe(method(layoutManager:paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:))]
843        #[unsafe(method_family = none)]
844        unsafe fn layoutManager_paragraphSpacingBeforeGlyphAtIndex_withProposedLineFragmentRect(
845            &self,
846            layout_manager: &NSLayoutManager,
847            glyph_index: NSUInteger,
848            rect: CGRect,
849        ) -> CGFloat;
850
851        #[cfg(feature = "objc2-core-foundation")]
852        #[optional]
853        #[unsafe(method(layoutManager:paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
854        #[unsafe(method_family = none)]
855        unsafe fn layoutManager_paragraphSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
856            &self,
857            layout_manager: &NSLayoutManager,
858            glyph_index: NSUInteger,
859            rect: CGRect,
860        ) -> CGFloat;
861
862        #[optional]
863        #[unsafe(method(layoutManager:shouldUseAction:forControlCharacterAtIndex:))]
864        #[unsafe(method_family = none)]
865        unsafe fn layoutManager_shouldUseAction_forControlCharacterAtIndex(
866            &self,
867            layout_manager: &NSLayoutManager,
868            action: NSControlCharacterAction,
869            char_index: NSUInteger,
870        ) -> NSControlCharacterAction;
871
872        #[optional]
873        #[unsafe(method(layoutManager:shouldBreakLineByWordBeforeCharacterAtIndex:))]
874        #[unsafe(method_family = none)]
875        unsafe fn layoutManager_shouldBreakLineByWordBeforeCharacterAtIndex(
876            &self,
877            layout_manager: &NSLayoutManager,
878            char_index: NSUInteger,
879        ) -> bool;
880
881        #[optional]
882        #[unsafe(method(layoutManager:shouldBreakLineByHyphenatingBeforeCharacterAtIndex:))]
883        #[unsafe(method_family = none)]
884        unsafe fn layoutManager_shouldBreakLineByHyphenatingBeforeCharacterAtIndex(
885            &self,
886            layout_manager: &NSLayoutManager,
887            char_index: NSUInteger,
888        ) -> bool;
889
890        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
891        #[optional]
892        #[unsafe(method(layoutManager:boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
893        #[unsafe(method_family = none)]
894        unsafe fn layoutManager_boundingBoxForControlGlyphAtIndex_forTextContainer_proposedLineFragment_glyphPosition_characterIndex(
895            &self,
896            layout_manager: &NSLayoutManager,
897            glyph_index: NSUInteger,
898            text_container: &NSTextContainer,
899            proposed_rect: CGRect,
900            glyph_position: CGPoint,
901            char_index: NSUInteger,
902        ) -> CGRect;
903
904        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
905        #[optional]
906        #[unsafe(method(layoutManager:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:inTextContainer:forGlyphRange:))]
907        #[unsafe(method_family = none)]
908        unsafe fn layoutManager_shouldSetLineFragmentRect_lineFragmentUsedRect_baselineOffset_inTextContainer_forGlyphRange(
909            &self,
910            layout_manager: &NSLayoutManager,
911            line_fragment_rect: NonNull<CGRect>,
912            line_fragment_used_rect: NonNull<CGRect>,
913            baseline_offset: NonNull<CGFloat>,
914            text_container: &NSTextContainer,
915            glyph_range: NSRange,
916        ) -> bool;
917
918        /// ********************** Layout processing ***********************
919        #[optional]
920        #[unsafe(method(layoutManagerDidInvalidateLayout:))]
921        #[unsafe(method_family = none)]
922        unsafe fn layoutManagerDidInvalidateLayout(&self, sender: &NSLayoutManager);
923
924        #[cfg(feature = "NSTextContainer")]
925        #[optional]
926        #[unsafe(method(layoutManager:didCompleteLayoutForTextContainer:atEnd:))]
927        #[unsafe(method_family = none)]
928        unsafe fn layoutManager_didCompleteLayoutForTextContainer_atEnd(
929            &self,
930            layout_manager: &NSLayoutManager,
931            text_container: Option<&NSTextContainer>,
932            layout_finished_flag: bool,
933        );
934
935        #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
936        #[optional]
937        #[unsafe(method(layoutManager:textContainer:didChangeGeometryFromSize:))]
938        #[unsafe(method_family = none)]
939        unsafe fn layoutManager_textContainer_didChangeGeometryFromSize(
940            &self,
941            layout_manager: &NSLayoutManager,
942            text_container: &NSTextContainer,
943            old_size: CGSize,
944        );
945    }
946);
947
948/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacterzeroadvancementaction?language=objc)
949#[deprecated]
950pub const NSControlCharacterZeroAdvancementAction: NSInteger =
951    NSControlCharacterAction::ZeroAdvancement.0;
952/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacterwhitespaceaction?language=objc)
953#[deprecated]
954pub const NSControlCharacterWhitespaceAction: NSInteger = NSControlCharacterAction::Whitespace.0;
955/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacterhorizontaltabaction?language=objc)
956#[deprecated]
957pub const NSControlCharacterHorizontalTabAction: NSInteger =
958    NSControlCharacterAction::HorizontalTab.0;
959/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacterlinebreakaction?language=objc)
960#[deprecated]
961pub const NSControlCharacterLineBreakAction: NSInteger = NSControlCharacterAction::LineBreak.0;
962/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharacterparagraphbreakaction?language=objc)
963#[deprecated]
964pub const NSControlCharacterParagraphBreakAction: NSInteger =
965    NSControlCharacterAction::ParagraphBreak.0;
966/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nscontrolcharactercontainerbreakaction?language=objc)
967#[deprecated]
968pub const NSControlCharacterContainerBreakAction: NSInteger =
969    NSControlCharacterAction::ContainerBreak.0;
970
971/// NSLayoutManagerDeprecated.
972impl NSLayoutManager {
973    extern_methods!(
974        #[cfg(feature = "objc2-core-graphics")]
975        #[unsafe(method(glyphAtIndex:isValidIndex:))]
976        #[unsafe(method_family = none)]
977        pub unsafe fn glyphAtIndex_isValidIndex(
978            &self,
979            glyph_index: NSUInteger,
980            is_valid_index: *mut Bool,
981        ) -> CGGlyph;
982
983        #[cfg(feature = "objc2-core-graphics")]
984        #[unsafe(method(glyphAtIndex:))]
985        #[unsafe(method_family = none)]
986        pub unsafe fn glyphAtIndex(&self, glyph_index: NSUInteger) -> CGGlyph;
987
988        #[cfg(feature = "objc2-core-foundation")]
989        #[deprecated = "Please use usesDefaultHyphenation or -[NSParagraphStyle hyphenationFactor] instead."]
990        #[unsafe(method(hyphenationFactor))]
991        #[unsafe(method_family = none)]
992        pub unsafe fn hyphenationFactor(&self) -> CGFloat;
993
994        #[cfg(feature = "objc2-core-foundation")]
995        /// Setter for [`hyphenationFactor`][Self::hyphenationFactor].
996        #[deprecated = "Please use usesDefaultHyphenation or -[NSParagraphStyle hyphenationFactor] instead."]
997        #[unsafe(method(setHyphenationFactor:))]
998        #[unsafe(method_family = none)]
999        pub unsafe fn setHyphenationFactor(&self, hyphenation_factor: CGFloat);
1000
1001        #[cfg(all(
1002            feature = "UIFont",
1003            feature = "objc2-core-foundation",
1004            feature = "objc2-core-graphics"
1005        ))]
1006        #[deprecated]
1007        #[unsafe(method(showCGGlyphs:positions:count:font:matrix:attributes:inContext:))]
1008        #[unsafe(method_family = none)]
1009        pub unsafe fn showCGGlyphs_positions_count_font_matrix_attributes_inContext(
1010            &self,
1011            glyphs: NonNull<CGGlyph>,
1012            positions: NonNull<CGPoint>,
1013            glyph_count: NSUInteger,
1014            font: &UIFont,
1015            text_matrix: CGAffineTransform,
1016            attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
1017            graphics_context: &CGContext,
1018        );
1019    );
1020}