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