1use 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#[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#[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#[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 pub unsafe trait NSTextLayoutOrientationProvider {
93 #[unsafe(method(layoutOrientation))]
94 #[unsafe(method_family = none)]
95 fn layoutOrientation(&self) -> NSTextLayoutOrientation;
96 }
97);
98
99extern_class!(
100 #[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 #[unsafe(method(init))]
122 #[unsafe(method_family = init)]
123 pub fn init(this: Allocated<Self>) -> Retained<Self>;
124
125 #[unsafe(method(initWithCoder:))]
129 #[unsafe(method_family = init)]
130 pub unsafe fn initWithCoder(
131 this: Allocated<Self>,
132 coder: &NSCoder,
133 ) -> Option<Retained<Self>>;
134
135 #[cfg(feature = "NSTextStorage")]
136 #[unsafe(method(textStorage))]
142 #[unsafe(method_family = none)]
143 pub unsafe fn textStorage(&self) -> Option<Retained<NSTextStorage>>;
144
145 #[cfg(feature = "NSTextStorage")]
146 #[unsafe(method(setTextStorage:))]
152 #[unsafe(method_family = none)]
153 pub unsafe fn setTextStorage(&self, text_storage: Option<&NSTextStorage>);
154
155 #[cfg(feature = "NSTextContainer")]
156 #[unsafe(method(textContainers))]
158 #[unsafe(method_family = none)]
159 pub fn textContainers(&self) -> Retained<NSArray<NSTextContainer>>;
160
161 #[cfg(feature = "NSTextContainer")]
162 #[unsafe(method(addTextContainer:))]
163 #[unsafe(method_family = none)]
164 pub fn addTextContainer(&self, container: &NSTextContainer);
165
166 #[cfg(feature = "NSTextContainer")]
167 #[unsafe(method(insertTextContainer:atIndex:))]
168 #[unsafe(method_family = none)]
169 pub fn insertTextContainer_atIndex(&self, container: &NSTextContainer, index: NSUInteger);
170
171 #[unsafe(method(removeTextContainerAtIndex:))]
172 #[unsafe(method_family = none)]
173 pub fn removeTextContainerAtIndex(&self, index: NSUInteger);
174
175 #[cfg(feature = "NSTextContainer")]
176 #[unsafe(method(textContainerChangedGeometry:))]
177 #[unsafe(method_family = none)]
178 pub fn textContainerChangedGeometry(&self, container: &NSTextContainer);
179
180 #[unsafe(method(delegate))]
182 #[unsafe(method_family = none)]
183 pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn NSLayoutManagerDelegate>>>;
184
185 #[unsafe(method(setDelegate:))]
189 #[unsafe(method_family = none)]
190 pub fn setDelegate(&self, delegate: Option<&ProtocolObject<dyn NSLayoutManagerDelegate>>);
191
192 #[unsafe(method(showsInvisibleCharacters))]
194 #[unsafe(method_family = none)]
195 pub fn showsInvisibleCharacters(&self) -> bool;
196
197 #[unsafe(method(setShowsInvisibleCharacters:))]
199 #[unsafe(method_family = none)]
200 pub fn setShowsInvisibleCharacters(&self, shows_invisible_characters: bool);
201
202 #[unsafe(method(showsControlCharacters))]
203 #[unsafe(method_family = none)]
204 pub fn showsControlCharacters(&self) -> bool;
205
206 #[unsafe(method(setShowsControlCharacters:))]
208 #[unsafe(method_family = none)]
209 pub fn setShowsControlCharacters(&self, shows_control_characters: bool);
210
211 #[unsafe(method(usesFontLeading))]
212 #[unsafe(method_family = none)]
213 pub fn usesFontLeading(&self) -> bool;
214
215 #[unsafe(method(setUsesFontLeading:))]
217 #[unsafe(method_family = none)]
218 pub fn setUsesFontLeading(&self, uses_font_leading: bool);
219
220 #[unsafe(method(allowsNonContiguousLayout))]
221 #[unsafe(method_family = none)]
222 pub fn allowsNonContiguousLayout(&self) -> bool;
223
224 #[unsafe(method(setAllowsNonContiguousLayout:))]
226 #[unsafe(method_family = none)]
227 pub fn setAllowsNonContiguousLayout(&self, allows_non_contiguous_layout: bool);
228
229 #[unsafe(method(hasNonContiguousLayout))]
230 #[unsafe(method_family = none)]
231 pub fn hasNonContiguousLayout(&self) -> bool;
232
233 #[unsafe(method(limitsLayoutForSuspiciousContents))]
234 #[unsafe(method_family = none)]
235 pub fn limitsLayoutForSuspiciousContents(&self) -> bool;
236
237 #[unsafe(method(setLimitsLayoutForSuspiciousContents:))]
239 #[unsafe(method_family = none)]
240 pub fn setLimitsLayoutForSuspiciousContents(
241 &self,
242 limits_layout_for_suspicious_contents: bool,
243 );
244
245 #[unsafe(method(usesDefaultHyphenation))]
246 #[unsafe(method_family = none)]
247 pub fn usesDefaultHyphenation(&self) -> bool;
248
249 #[unsafe(method(setUsesDefaultHyphenation:))]
251 #[unsafe(method_family = none)]
252 pub fn setUsesDefaultHyphenation(&self, uses_default_hyphenation: bool);
253
254 #[unsafe(method(invalidateGlyphsForCharacterRange:changeInLength:actualCharacterRange:))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn invalidateGlyphsForCharacterRange_changeInLength_actualCharacterRange(
262 &self,
263 char_range: NSRange,
264 delta: NSInteger,
265 actual_char_range: NSRangePointer,
266 );
267
268 #[unsafe(method(invalidateLayoutForCharacterRange:actualCharacterRange:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn invalidateLayoutForCharacterRange_actualCharacterRange(
274 &self,
275 char_range: NSRange,
276 actual_char_range: NSRangePointer,
277 );
278
279 #[unsafe(method(invalidateDisplayForCharacterRange:))]
280 #[unsafe(method_family = none)]
281 pub fn invalidateDisplayForCharacterRange(&self, char_range: NSRange);
282
283 #[unsafe(method(invalidateDisplayForGlyphRange:))]
284 #[unsafe(method_family = none)]
285 pub fn invalidateDisplayForGlyphRange(&self, glyph_range: NSRange);
286
287 #[cfg(feature = "NSTextStorage")]
288 #[unsafe(method(processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:))]
289 #[unsafe(method_family = none)]
290 pub fn processEditingForTextStorage_edited_range_changeInLength_invalidatedRange(
291 &self,
292 text_storage: &NSTextStorage,
293 edit_mask: NSTextStorageEditActions,
294 new_char_range: NSRange,
295 delta: NSInteger,
296 invalidated_char_range: NSRange,
297 );
298
299 #[unsafe(method(ensureGlyphsForCharacterRange:))]
301 #[unsafe(method_family = none)]
302 pub fn ensureGlyphsForCharacterRange(&self, char_range: NSRange);
303
304 #[unsafe(method(ensureGlyphsForGlyphRange:))]
305 #[unsafe(method_family = none)]
306 pub fn ensureGlyphsForGlyphRange(&self, glyph_range: NSRange);
307
308 #[unsafe(method(ensureLayoutForCharacterRange:))]
309 #[unsafe(method_family = none)]
310 pub fn ensureLayoutForCharacterRange(&self, char_range: NSRange);
311
312 #[unsafe(method(ensureLayoutForGlyphRange:))]
313 #[unsafe(method_family = none)]
314 pub fn ensureLayoutForGlyphRange(&self, glyph_range: NSRange);
315
316 #[cfg(feature = "NSTextContainer")]
317 #[unsafe(method(ensureLayoutForTextContainer:))]
318 #[unsafe(method_family = none)]
319 pub fn ensureLayoutForTextContainer(&self, container: &NSTextContainer);
320
321 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
322 #[unsafe(method(ensureLayoutForBoundingRect:inTextContainer:))]
323 #[unsafe(method_family = none)]
324 pub fn ensureLayoutForBoundingRect_inTextContainer(
325 &self,
326 bounds: CGRect,
327 container: &NSTextContainer,
328 );
329
330 #[cfg(all(feature = "UIFont", feature = "objc2-core-graphics"))]
331 #[unsafe(method(setGlyphs:properties:characterIndexes:font:forGlyphRange:))]
339 #[unsafe(method_family = none)]
340 pub unsafe fn setGlyphs_properties_characterIndexes_font_forGlyphRange(
341 &self,
342 glyphs: NonNull<CGGlyph>,
343 props: NonNull<NSGlyphProperty>,
344 char_indexes: NonNull<NSUInteger>,
345 a_font: &UIFont,
346 glyph_range: NSRange,
347 );
348
349 #[unsafe(method(numberOfGlyphs))]
351 #[unsafe(method_family = none)]
352 pub fn numberOfGlyphs(&self) -> NSUInteger;
353
354 #[cfg(feature = "objc2-core-graphics")]
355 #[unsafe(method(CGGlyphAtIndex:isValidIndex:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn CGGlyphAtIndex_isValidIndex(
361 &self,
362 glyph_index: NSUInteger,
363 is_valid_index: *mut Bool,
364 ) -> CGGlyph;
365
366 #[cfg(feature = "objc2-core-graphics")]
367 #[unsafe(method(CGGlyphAtIndex:))]
368 #[unsafe(method_family = none)]
369 pub fn CGGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGGlyph;
370
371 #[unsafe(method(isValidGlyphIndex:))]
372 #[unsafe(method_family = none)]
373 pub fn isValidGlyphIndex(&self, glyph_index: NSUInteger) -> bool;
374
375 #[unsafe(method(propertyForGlyphAtIndex:))]
376 #[unsafe(method_family = none)]
377 pub fn propertyForGlyphAtIndex(&self, glyph_index: NSUInteger) -> NSGlyphProperty;
378
379 #[unsafe(method(characterIndexForGlyphAtIndex:))]
380 #[unsafe(method_family = none)]
381 pub fn characterIndexForGlyphAtIndex(&self, glyph_index: NSUInteger) -> NSUInteger;
382
383 #[unsafe(method(glyphIndexForCharacterAtIndex:))]
384 #[unsafe(method_family = none)]
385 pub fn glyphIndexForCharacterAtIndex(&self, char_index: NSUInteger) -> NSUInteger;
386
387 #[cfg(feature = "objc2-core-graphics")]
388 #[unsafe(method(getGlyphsInRange:glyphs:properties:characterIndexes:bidiLevels:))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn getGlyphsInRange_glyphs_properties_characterIndexes_bidiLevels(
397 &self,
398 glyph_range: NSRange,
399 glyph_buffer: *mut CGGlyph,
400 props: *mut NSGlyphProperty,
401 char_index_buffer: *mut NSUInteger,
402 bidi_level_buffer: *mut c_uchar,
403 ) -> NSUInteger;
404
405 #[cfg(feature = "NSTextContainer")]
406 #[unsafe(method(setTextContainer:forGlyphRange:))]
407 #[unsafe(method_family = none)]
408 pub fn setTextContainer_forGlyphRange(
409 &self,
410 container: &NSTextContainer,
411 glyph_range: NSRange,
412 );
413
414 #[cfg(feature = "objc2-core-foundation")]
415 #[unsafe(method(setLineFragmentRect:forGlyphRange:usedRect:))]
416 #[unsafe(method_family = none)]
417 pub fn setLineFragmentRect_forGlyphRange_usedRect(
418 &self,
419 fragment_rect: CGRect,
420 glyph_range: NSRange,
421 used_rect: CGRect,
422 );
423
424 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
425 #[unsafe(method(setExtraLineFragmentRect:usedRect:textContainer:))]
426 #[unsafe(method_family = none)]
427 pub fn setExtraLineFragmentRect_usedRect_textContainer(
428 &self,
429 fragment_rect: CGRect,
430 used_rect: CGRect,
431 container: &NSTextContainer,
432 );
433
434 #[cfg(feature = "objc2-core-foundation")]
435 #[unsafe(method(setLocation:forStartOfGlyphRange:))]
436 #[unsafe(method_family = none)]
437 pub fn setLocation_forStartOfGlyphRange(&self, location: CGPoint, glyph_range: NSRange);
438
439 #[unsafe(method(setNotShownAttribute:forGlyphAtIndex:))]
440 #[unsafe(method_family = none)]
441 pub fn setNotShownAttribute_forGlyphAtIndex(&self, flag: bool, glyph_index: NSUInteger);
442
443 #[unsafe(method(setDrawsOutsideLineFragment:forGlyphAtIndex:))]
444 #[unsafe(method_family = none)]
445 pub fn setDrawsOutsideLineFragment_forGlyphAtIndex(
446 &self,
447 flag: bool,
448 glyph_index: NSUInteger,
449 );
450
451 #[cfg(feature = "objc2-core-foundation")]
452 #[unsafe(method(setAttachmentSize:forGlyphRange:))]
453 #[unsafe(method_family = none)]
454 pub fn setAttachmentSize_forGlyphRange(
455 &self,
456 attachment_size: CGSize,
457 glyph_range: NSRange,
458 );
459
460 #[unsafe(method(getFirstUnlaidCharacterIndex:glyphIndex:))]
467 #[unsafe(method_family = none)]
468 pub unsafe fn getFirstUnlaidCharacterIndex_glyphIndex(
469 &self,
470 char_index: *mut NSUInteger,
471 glyph_index: *mut NSUInteger,
472 );
473
474 #[unsafe(method(firstUnlaidCharacterIndex))]
475 #[unsafe(method_family = none)]
476 pub fn firstUnlaidCharacterIndex(&self) -> NSUInteger;
477
478 #[unsafe(method(firstUnlaidGlyphIndex))]
479 #[unsafe(method_family = none)]
480 pub fn firstUnlaidGlyphIndex(&self) -> NSUInteger;
481
482 #[cfg(feature = "NSTextContainer")]
483 #[unsafe(method(textContainerForGlyphAtIndex:effectiveRange:))]
487 #[unsafe(method_family = none)]
488 pub unsafe fn textContainerForGlyphAtIndex_effectiveRange(
489 &self,
490 glyph_index: NSUInteger,
491 effective_glyph_range: NSRangePointer,
492 ) -> Option<Retained<NSTextContainer>>;
493
494 #[cfg(feature = "NSTextContainer")]
495 #[unsafe(method(textContainerForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
499 #[unsafe(method_family = none)]
500 pub unsafe fn textContainerForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
501 &self,
502 glyph_index: NSUInteger,
503 effective_glyph_range: NSRangePointer,
504 flag: bool,
505 ) -> Option<Retained<NSTextContainer>>;
506
507 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
508 #[unsafe(method(usedRectForTextContainer:))]
509 #[unsafe(method_family = none)]
510 pub fn usedRectForTextContainer(&self, container: &NSTextContainer) -> CGRect;
511
512 #[cfg(feature = "objc2-core-foundation")]
513 #[unsafe(method(lineFragmentRectForGlyphAtIndex:effectiveRange:))]
517 #[unsafe(method_family = none)]
518 pub unsafe fn lineFragmentRectForGlyphAtIndex_effectiveRange(
519 &self,
520 glyph_index: NSUInteger,
521 effective_glyph_range: NSRangePointer,
522 ) -> CGRect;
523
524 #[cfg(feature = "objc2-core-foundation")]
525 #[unsafe(method(lineFragmentRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
529 #[unsafe(method_family = none)]
530 pub unsafe fn lineFragmentRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
531 &self,
532 glyph_index: NSUInteger,
533 effective_glyph_range: NSRangePointer,
534 flag: bool,
535 ) -> CGRect;
536
537 #[cfg(feature = "objc2-core-foundation")]
538 #[unsafe(method(lineFragmentUsedRectForGlyphAtIndex:effectiveRange:))]
542 #[unsafe(method_family = none)]
543 pub unsafe fn lineFragmentUsedRectForGlyphAtIndex_effectiveRange(
544 &self,
545 glyph_index: NSUInteger,
546 effective_glyph_range: NSRangePointer,
547 ) -> CGRect;
548
549 #[cfg(feature = "objc2-core-foundation")]
550 #[unsafe(method(lineFragmentUsedRectForGlyphAtIndex:effectiveRange:withoutAdditionalLayout:))]
554 #[unsafe(method_family = none)]
555 pub unsafe fn lineFragmentUsedRectForGlyphAtIndex_effectiveRange_withoutAdditionalLayout(
556 &self,
557 glyph_index: NSUInteger,
558 effective_glyph_range: NSRangePointer,
559 flag: bool,
560 ) -> CGRect;
561
562 #[cfg(feature = "objc2-core-foundation")]
563 #[unsafe(method(extraLineFragmentRect))]
564 #[unsafe(method_family = none)]
565 pub fn extraLineFragmentRect(&self) -> CGRect;
566
567 #[cfg(feature = "objc2-core-foundation")]
568 #[unsafe(method(extraLineFragmentUsedRect))]
569 #[unsafe(method_family = none)]
570 pub fn extraLineFragmentUsedRect(&self) -> CGRect;
571
572 #[cfg(feature = "NSTextContainer")]
573 #[unsafe(method(extraLineFragmentTextContainer))]
574 #[unsafe(method_family = none)]
575 pub fn extraLineFragmentTextContainer(&self) -> Option<Retained<NSTextContainer>>;
576
577 #[cfg(feature = "objc2-core-foundation")]
578 #[unsafe(method(locationForGlyphAtIndex:))]
579 #[unsafe(method_family = none)]
580 pub fn locationForGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGPoint;
581
582 #[unsafe(method(notShownAttributeForGlyphAtIndex:))]
583 #[unsafe(method_family = none)]
584 pub fn notShownAttributeForGlyphAtIndex(&self, glyph_index: NSUInteger) -> bool;
585
586 #[unsafe(method(drawsOutsideLineFragmentForGlyphAtIndex:))]
587 #[unsafe(method_family = none)]
588 pub fn drawsOutsideLineFragmentForGlyphAtIndex(&self, glyph_index: NSUInteger) -> bool;
589
590 #[cfg(feature = "objc2-core-foundation")]
591 #[unsafe(method(attachmentSizeForGlyphAtIndex:))]
592 #[unsafe(method_family = none)]
593 pub fn attachmentSizeForGlyphAtIndex(&self, glyph_index: NSUInteger) -> CGSize;
594
595 #[unsafe(method(truncatedGlyphRangeInLineFragmentForGlyphAtIndex:))]
596 #[unsafe(method_family = none)]
597 pub fn truncatedGlyphRangeInLineFragmentForGlyphAtIndex(
598 &self,
599 glyph_index: NSUInteger,
600 ) -> NSRange;
601
602 #[unsafe(method(glyphRangeForCharacterRange:actualCharacterRange:))]
608 #[unsafe(method_family = none)]
609 pub unsafe fn glyphRangeForCharacterRange_actualCharacterRange(
610 &self,
611 char_range: NSRange,
612 actual_char_range: NSRangePointer,
613 ) -> NSRange;
614
615 #[unsafe(method(characterRangeForGlyphRange:actualGlyphRange:))]
619 #[unsafe(method_family = none)]
620 pub unsafe fn characterRangeForGlyphRange_actualGlyphRange(
621 &self,
622 glyph_range: NSRange,
623 actual_glyph_range: NSRangePointer,
624 ) -> NSRange;
625
626 #[cfg(feature = "NSTextContainer")]
627 #[unsafe(method(glyphRangeForTextContainer:))]
628 #[unsafe(method_family = none)]
629 pub fn glyphRangeForTextContainer(&self, container: &NSTextContainer) -> NSRange;
630
631 #[unsafe(method(rangeOfNominallySpacedGlyphsContainingIndex:))]
632 #[unsafe(method_family = none)]
633 pub fn rangeOfNominallySpacedGlyphsContainingIndex(
634 &self,
635 glyph_index: NSUInteger,
636 ) -> NSRange;
637
638 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
639 #[unsafe(method(boundingRectForGlyphRange:inTextContainer:))]
640 #[unsafe(method_family = none)]
641 pub fn boundingRectForGlyphRange_inTextContainer(
642 &self,
643 glyph_range: NSRange,
644 container: &NSTextContainer,
645 ) -> CGRect;
646
647 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
648 #[unsafe(method(glyphRangeForBoundingRect:inTextContainer:))]
649 #[unsafe(method_family = none)]
650 pub fn glyphRangeForBoundingRect_inTextContainer(
651 &self,
652 bounds: CGRect,
653 container: &NSTextContainer,
654 ) -> NSRange;
655
656 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
657 #[unsafe(method(glyphRangeForBoundingRectWithoutAdditionalLayout:inTextContainer:))]
658 #[unsafe(method_family = none)]
659 pub fn glyphRangeForBoundingRectWithoutAdditionalLayout_inTextContainer(
660 &self,
661 bounds: CGRect,
662 container: &NSTextContainer,
663 ) -> NSRange;
664
665 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
666 #[unsafe(method(glyphIndexForPoint:inTextContainer:fractionOfDistanceThroughGlyph:))]
670 #[unsafe(method_family = none)]
671 pub unsafe fn glyphIndexForPoint_inTextContainer_fractionOfDistanceThroughGlyph(
672 &self,
673 point: CGPoint,
674 container: &NSTextContainer,
675 partial_fraction: *mut CGFloat,
676 ) -> NSUInteger;
677
678 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
679 #[unsafe(method(glyphIndexForPoint:inTextContainer:))]
680 #[unsafe(method_family = none)]
681 pub fn glyphIndexForPoint_inTextContainer(
682 &self,
683 point: CGPoint,
684 container: &NSTextContainer,
685 ) -> NSUInteger;
686
687 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
688 #[unsafe(method(fractionOfDistanceThroughGlyphForPoint:inTextContainer:))]
689 #[unsafe(method_family = none)]
690 pub fn fractionOfDistanceThroughGlyphForPoint_inTextContainer(
691 &self,
692 point: CGPoint,
693 container: &NSTextContainer,
694 ) -> CGFloat;
695
696 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
697 #[unsafe(method(characterIndexForPoint:inTextContainer:fractionOfDistanceBetweenInsertionPoints:))]
701 #[unsafe(method_family = none)]
702 pub unsafe fn characterIndexForPoint_inTextContainer_fractionOfDistanceBetweenInsertionPoints(
703 &self,
704 point: CGPoint,
705 container: &NSTextContainer,
706 partial_fraction: *mut CGFloat,
707 ) -> NSUInteger;
708
709 #[cfg(feature = "objc2-core-foundation")]
710 #[unsafe(method(getLineFragmentInsertionPointsForCharacterAtIndex:alternatePositions:inDisplayOrder:positions:characterIndexes:))]
715 #[unsafe(method_family = none)]
716 pub unsafe fn getLineFragmentInsertionPointsForCharacterAtIndex_alternatePositions_inDisplayOrder_positions_characterIndexes(
717 &self,
718 char_index: NSUInteger,
719 a_flag: bool,
720 d_flag: bool,
721 positions: *mut CGFloat,
722 char_indexes: *mut NSUInteger,
723 ) -> NSUInteger;
724
725 #[cfg(all(
726 feature = "NSTextContainer",
727 feature = "block2",
728 feature = "objc2-core-foundation"
729 ))]
730 #[unsafe(method(enumerateLineFragmentsForGlyphRange:usingBlock:))]
731 #[unsafe(method_family = none)]
732 pub fn enumerateLineFragmentsForGlyphRange_usingBlock(
733 &self,
734 glyph_range: NSRange,
735 block: &block2::DynBlock<
736 dyn Fn(CGRect, CGRect, NonNull<NSTextContainer>, NSRange, NonNull<Bool>),
737 >,
738 );
739
740 #[cfg(all(
741 feature = "NSTextContainer",
742 feature = "block2",
743 feature = "objc2-core-foundation"
744 ))]
745 #[unsafe(method(enumerateEnclosingRectsForGlyphRange:withinSelectedGlyphRange:inTextContainer:usingBlock:))]
746 #[unsafe(method_family = none)]
747 pub fn enumerateEnclosingRectsForGlyphRange_withinSelectedGlyphRange_inTextContainer_usingBlock(
748 &self,
749 glyph_range: NSRange,
750 selected_range: NSRange,
751 text_container: &NSTextContainer,
752 block: &block2::DynBlock<dyn Fn(CGRect, NonNull<Bool>)>,
753 );
754
755 #[cfg(feature = "objc2-core-foundation")]
756 #[unsafe(method(drawBackgroundForGlyphRange:atPoint:))]
758 #[unsafe(method_family = none)]
759 pub fn drawBackgroundForGlyphRange_atPoint(&self, glyphs_to_show: NSRange, origin: CGPoint);
760
761 #[cfg(feature = "objc2-core-foundation")]
762 #[unsafe(method(drawGlyphsForGlyphRange:atPoint:))]
763 #[unsafe(method_family = none)]
764 pub fn drawGlyphsForGlyphRange_atPoint(&self, glyphs_to_show: NSRange, origin: CGPoint);
765
766 #[cfg(all(
767 feature = "UIFont",
768 feature = "objc2-core-foundation",
769 feature = "objc2-core-graphics"
770 ))]
771 #[unsafe(method(showCGGlyphs:positions:count:font:textMatrix:attributes:inContext:))]
777 #[unsafe(method_family = none)]
778 pub unsafe fn showCGGlyphs_positions_count_font_textMatrix_attributes_inContext(
779 &self,
780 glyphs: NonNull<CGGlyph>,
781 positions: NonNull<CGPoint>,
782 glyph_count: NSInteger,
783 font: &UIFont,
784 text_matrix: CGAffineTransform,
785 attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
786 cg_context: &CGContext,
787 );
788
789 #[cfg(all(feature = "UIColor", feature = "objc2-core-foundation"))]
790 #[unsafe(method(fillBackgroundRectArray:count:forCharacterRange:color:))]
794 #[unsafe(method_family = none)]
795 pub unsafe fn fillBackgroundRectArray_count_forCharacterRange_color(
796 &self,
797 rect_array: NonNull<CGRect>,
798 rect_count: NSUInteger,
799 char_range: NSRange,
800 color: &UIColor,
801 );
802
803 #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
804 #[unsafe(method(drawUnderlineForGlyphRange:underlineType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
805 #[unsafe(method_family = none)]
806 pub fn drawUnderlineForGlyphRange_underlineType_baselineOffset_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
807 &self,
808 glyph_range: NSRange,
809 underline_val: NSUnderlineStyle,
810 baseline_offset: CGFloat,
811 line_rect: CGRect,
812 line_glyph_range: NSRange,
813 container_origin: CGPoint,
814 );
815
816 #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
817 #[unsafe(method(underlineGlyphRange:underlineType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
818 #[unsafe(method_family = none)]
819 pub fn underlineGlyphRange_underlineType_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
820 &self,
821 glyph_range: NSRange,
822 underline_val: NSUnderlineStyle,
823 line_rect: CGRect,
824 line_glyph_range: NSRange,
825 container_origin: CGPoint,
826 );
827
828 #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
829 #[unsafe(method(drawStrikethroughForGlyphRange:strikethroughType:baselineOffset:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
830 #[unsafe(method_family = none)]
831 pub fn drawStrikethroughForGlyphRange_strikethroughType_baselineOffset_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
832 &self,
833 glyph_range: NSRange,
834 strikethrough_val: NSUnderlineStyle,
835 baseline_offset: CGFloat,
836 line_rect: CGRect,
837 line_glyph_range: NSRange,
838 container_origin: CGPoint,
839 );
840
841 #[cfg(all(feature = "NSAttributedString", feature = "objc2-core-foundation"))]
842 #[unsafe(method(strikethroughGlyphRange:strikethroughType:lineFragmentRect:lineFragmentGlyphRange:containerOrigin:))]
843 #[unsafe(method_family = none)]
844 pub fn strikethroughGlyphRange_strikethroughType_lineFragmentRect_lineFragmentGlyphRange_containerOrigin(
845 &self,
846 glyph_range: NSRange,
847 strikethrough_val: NSUnderlineStyle,
848 line_rect: CGRect,
849 line_glyph_range: NSRange,
850 container_origin: CGPoint,
851 );
852 );
853}
854
855impl NSLayoutManager {
857 extern_methods!(
858 #[unsafe(method(new))]
859 #[unsafe(method_family = new)]
860 pub fn new() -> Retained<Self>;
861 );
862}
863
864impl DefaultRetained for NSLayoutManager {
865 #[inline]
866 fn default_retained() -> Retained<Self> {
867 Self::new()
868 }
869}
870
871extern_protocol!(
872 pub unsafe trait NSLayoutManagerDelegate: NSObjectProtocol {
874 #[cfg(all(feature = "UIFont", feature = "objc2-core-graphics"))]
875 #[optional]
883 #[unsafe(method(layoutManager:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:))]
884 #[unsafe(method_family = none)]
885 unsafe fn layoutManager_shouldGenerateGlyphs_properties_characterIndexes_font_forGlyphRange(
886 &self,
887 layout_manager: &NSLayoutManager,
888 glyphs: NonNull<CGGlyph>,
889 props: NonNull<NSGlyphProperty>,
890 char_indexes: NonNull<NSUInteger>,
891 a_font: &UIFont,
892 glyph_range: NSRange,
893 ) -> NSUInteger;
894
895 #[cfg(feature = "objc2-core-foundation")]
896 #[optional]
898 #[unsafe(method(layoutManager:lineSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
899 #[unsafe(method_family = none)]
900 fn layoutManager_lineSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
901 &self,
902 layout_manager: &NSLayoutManager,
903 glyph_index: NSUInteger,
904 rect: CGRect,
905 ) -> CGFloat;
906
907 #[cfg(feature = "objc2-core-foundation")]
908 #[optional]
909 #[unsafe(method(layoutManager:paragraphSpacingBeforeGlyphAtIndex:withProposedLineFragmentRect:))]
910 #[unsafe(method_family = none)]
911 fn layoutManager_paragraphSpacingBeforeGlyphAtIndex_withProposedLineFragmentRect(
912 &self,
913 layout_manager: &NSLayoutManager,
914 glyph_index: NSUInteger,
915 rect: CGRect,
916 ) -> CGFloat;
917
918 #[cfg(feature = "objc2-core-foundation")]
919 #[optional]
920 #[unsafe(method(layoutManager:paragraphSpacingAfterGlyphAtIndex:withProposedLineFragmentRect:))]
921 #[unsafe(method_family = none)]
922 fn layoutManager_paragraphSpacingAfterGlyphAtIndex_withProposedLineFragmentRect(
923 &self,
924 layout_manager: &NSLayoutManager,
925 glyph_index: NSUInteger,
926 rect: CGRect,
927 ) -> CGFloat;
928
929 #[optional]
930 #[unsafe(method(layoutManager:shouldUseAction:forControlCharacterAtIndex:))]
931 #[unsafe(method_family = none)]
932 fn layoutManager_shouldUseAction_forControlCharacterAtIndex(
933 &self,
934 layout_manager: &NSLayoutManager,
935 action: NSControlCharacterAction,
936 char_index: NSUInteger,
937 ) -> NSControlCharacterAction;
938
939 #[optional]
940 #[unsafe(method(layoutManager:shouldBreakLineByWordBeforeCharacterAtIndex:))]
941 #[unsafe(method_family = none)]
942 fn layoutManager_shouldBreakLineByWordBeforeCharacterAtIndex(
943 &self,
944 layout_manager: &NSLayoutManager,
945 char_index: NSUInteger,
946 ) -> bool;
947
948 #[optional]
949 #[unsafe(method(layoutManager:shouldBreakLineByHyphenatingBeforeCharacterAtIndex:))]
950 #[unsafe(method_family = none)]
951 fn layoutManager_shouldBreakLineByHyphenatingBeforeCharacterAtIndex(
952 &self,
953 layout_manager: &NSLayoutManager,
954 char_index: NSUInteger,
955 ) -> bool;
956
957 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
958 #[optional]
959 #[unsafe(method(layoutManager:boundingBoxForControlGlyphAtIndex:forTextContainer:proposedLineFragment:glyphPosition:characterIndex:))]
960 #[unsafe(method_family = none)]
961 fn layoutManager_boundingBoxForControlGlyphAtIndex_forTextContainer_proposedLineFragment_glyphPosition_characterIndex(
962 &self,
963 layout_manager: &NSLayoutManager,
964 glyph_index: NSUInteger,
965 text_container: &NSTextContainer,
966 proposed_rect: CGRect,
967 glyph_position: CGPoint,
968 char_index: NSUInteger,
969 ) -> CGRect;
970
971 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
972 #[optional]
978 #[unsafe(method(layoutManager:shouldSetLineFragmentRect:lineFragmentUsedRect:baselineOffset:inTextContainer:forGlyphRange:))]
979 #[unsafe(method_family = none)]
980 unsafe fn layoutManager_shouldSetLineFragmentRect_lineFragmentUsedRect_baselineOffset_inTextContainer_forGlyphRange(
981 &self,
982 layout_manager: &NSLayoutManager,
983 line_fragment_rect: NonNull<CGRect>,
984 line_fragment_used_rect: NonNull<CGRect>,
985 baseline_offset: NonNull<CGFloat>,
986 text_container: &NSTextContainer,
987 glyph_range: NSRange,
988 ) -> bool;
989
990 #[optional]
992 #[unsafe(method(layoutManagerDidInvalidateLayout:))]
993 #[unsafe(method_family = none)]
994 fn layoutManagerDidInvalidateLayout(&self, sender: &NSLayoutManager);
995
996 #[cfg(feature = "NSTextContainer")]
997 #[optional]
998 #[unsafe(method(layoutManager:didCompleteLayoutForTextContainer:atEnd:))]
999 #[unsafe(method_family = none)]
1000 fn layoutManager_didCompleteLayoutForTextContainer_atEnd(
1001 &self,
1002 layout_manager: &NSLayoutManager,
1003 text_container: Option<&NSTextContainer>,
1004 layout_finished_flag: bool,
1005 );
1006
1007 #[cfg(all(feature = "NSTextContainer", feature = "objc2-core-foundation"))]
1008 #[optional]
1009 #[unsafe(method(layoutManager:textContainer:didChangeGeometryFromSize:))]
1010 #[unsafe(method_family = none)]
1011 fn layoutManager_textContainer_didChangeGeometryFromSize(
1012 &self,
1013 layout_manager: &NSLayoutManager,
1014 text_container: &NSTextContainer,
1015 old_size: CGSize,
1016 );
1017 }
1018);
1019
1020#[deprecated]
1022pub const NSControlCharacterZeroAdvancementAction: NSInteger =
1023 NSControlCharacterAction::ZeroAdvancement.0;
1024#[deprecated]
1026pub const NSControlCharacterWhitespaceAction: NSInteger = NSControlCharacterAction::Whitespace.0;
1027#[deprecated]
1029pub const NSControlCharacterHorizontalTabAction: NSInteger =
1030 NSControlCharacterAction::HorizontalTab.0;
1031#[deprecated]
1033pub const NSControlCharacterLineBreakAction: NSInteger = NSControlCharacterAction::LineBreak.0;
1034#[deprecated]
1036pub const NSControlCharacterParagraphBreakAction: NSInteger =
1037 NSControlCharacterAction::ParagraphBreak.0;
1038#[deprecated]
1040pub const NSControlCharacterContainerBreakAction: NSInteger =
1041 NSControlCharacterAction::ContainerBreak.0;
1042
1043impl NSLayoutManager {
1045 extern_methods!(
1046 #[cfg(feature = "objc2-core-graphics")]
1047 #[unsafe(method(glyphAtIndex:isValidIndex:))]
1051 #[unsafe(method_family = none)]
1052 pub unsafe fn glyphAtIndex_isValidIndex(
1053 &self,
1054 glyph_index: NSUInteger,
1055 is_valid_index: *mut Bool,
1056 ) -> CGGlyph;
1057
1058 #[cfg(feature = "objc2-core-graphics")]
1059 #[unsafe(method(glyphAtIndex:))]
1060 #[unsafe(method_family = none)]
1061 pub fn glyphAtIndex(&self, glyph_index: NSUInteger) -> CGGlyph;
1062
1063 #[cfg(feature = "objc2-core-foundation")]
1064 #[deprecated = "Please use usesDefaultHyphenation or -[NSParagraphStyle hyphenationFactor] instead."]
1065 #[unsafe(method(hyphenationFactor))]
1066 #[unsafe(method_family = none)]
1067 pub fn hyphenationFactor(&self) -> CGFloat;
1068
1069 #[cfg(feature = "objc2-core-foundation")]
1070 #[deprecated = "Please use usesDefaultHyphenation or -[NSParagraphStyle hyphenationFactor] instead."]
1072 #[unsafe(method(setHyphenationFactor:))]
1073 #[unsafe(method_family = none)]
1074 pub fn setHyphenationFactor(&self, hyphenation_factor: CGFloat);
1075
1076 #[cfg(all(
1077 feature = "UIFont",
1078 feature = "objc2-core-foundation",
1079 feature = "objc2-core-graphics"
1080 ))]
1081 #[deprecated]
1087 #[unsafe(method(showCGGlyphs:positions:count:font:matrix:attributes:inContext:))]
1088 #[unsafe(method_family = none)]
1089 pub unsafe fn showCGGlyphs_positions_count_font_matrix_attributes_inContext(
1090 &self,
1091 glyphs: NonNull<CGGlyph>,
1092 positions: NonNull<CGPoint>,
1093 glyph_count: NSUInteger,
1094 font: &UIFont,
1095 text_matrix: CGAffineTransform,
1096 attributes: &NSDictionary<NSAttributedStringKey, AnyObject>,
1097 graphics_context: &CGContext,
1098 );
1099 );
1100}