objc2_core_text/generated/
CTParagraphStyle.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctparagraphstyle?language=objc)
14#[repr(C)]
15pub struct CTParagraphStyle {
16    inner: [u8; 0],
17    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21    #[encoding_name = "__CTParagraphStyle"]
22    unsafe impl CTParagraphStyle {}
23);
24
25unsafe impl ConcreteType for CTParagraphStyle {
26    /// Returns the CFType of the paragraph style object
27    #[doc(alias = "CTParagraphStyleGetTypeID")]
28    #[inline]
29    fn type_id() -> CFTypeID {
30        extern "C-unwind" {
31            fn CTParagraphStyleGetTypeID() -> CFTypeID;
32        }
33        unsafe { CTParagraphStyleGetTypeID() }
34    }
35}
36
37/// These constants specify text alignment.
38///
39///
40/// Text is visually left-aligned.
41///
42///
43/// Text is visually right-aligned.
44///
45///
46/// Text is visually center-aligned.
47///
48///
49/// Text is fully justified. The last line in a paragraph is
50/// naturally aligned.
51///
52///
53/// Use the natural alignment of the text's script.
54///
55/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/cttextalignment?language=objc)
56// NS_ENUM
57#[repr(transparent)]
58#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
59pub struct CTTextAlignment(pub u8);
60impl CTTextAlignment {
61    #[doc(alias = "kCTTextAlignmentLeft")]
62    pub const Left: Self = Self(0);
63    #[doc(alias = "kCTTextAlignmentRight")]
64    pub const Right: Self = Self(1);
65    #[doc(alias = "kCTTextAlignmentCenter")]
66    pub const Center: Self = Self(2);
67    #[doc(alias = "kCTTextAlignmentJustified")]
68    pub const Justified: Self = Self(3);
69    #[doc(alias = "kCTTextAlignmentNatural")]
70    pub const Natural: Self = Self(4);
71    #[deprecated = "Deprecated"]
72    pub const kCTLeftTextAlignment: Self = Self(CTTextAlignment::Left.0);
73    #[deprecated = "Deprecated"]
74    pub const kCTRightTextAlignment: Self = Self(CTTextAlignment::Right.0);
75    #[deprecated = "Deprecated"]
76    pub const kCTCenterTextAlignment: Self = Self(CTTextAlignment::Center.0);
77    #[deprecated = "Deprecated"]
78    pub const kCTJustifiedTextAlignment: Self = Self(CTTextAlignment::Justified.0);
79    #[deprecated = "Deprecated"]
80    pub const kCTNaturalTextAlignment: Self = Self(CTTextAlignment::Natural.0);
81}
82
83#[cfg(feature = "objc2")]
84unsafe impl Encode for CTTextAlignment {
85    const ENCODING: Encoding = u8::ENCODING;
86}
87
88#[cfg(feature = "objc2")]
89unsafe impl RefEncode for CTTextAlignment {
90    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
91}
92
93/// These constants specify what happens when a line is too long for
94/// its frame.
95///
96///
97/// Wrapping occurs at word boundaries, unless the word itself doesn't
98/// fit on a single line.
99///
100///
101/// Wrapping occurs before the first character that doesn't fit.
102///
103///
104/// Lines are simply not drawn past the edge of the frame.
105///
106///
107/// Each line is displayed so that the end fits in the frame and the
108/// missing text is indicated by some kind of ellipsis glyph.
109///
110///
111/// Each line is displayed so that the beginning fits in the
112/// container and the missing text is indicated by some kind of
113/// ellipsis glyph.
114///
115///
116/// Each line is displayed so that the beginning and end fit in the
117/// container and the missing text is indicated by some kind of
118/// ellipsis glyph in the middle.
119///
120/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctlinebreakmode?language=objc)
121// NS_ENUM
122#[repr(transparent)]
123#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
124pub struct CTLineBreakMode(pub u8);
125impl CTLineBreakMode {
126    #[doc(alias = "kCTLineBreakByWordWrapping")]
127    pub const ByWordWrapping: Self = Self(0);
128    #[doc(alias = "kCTLineBreakByCharWrapping")]
129    pub const ByCharWrapping: Self = Self(1);
130    #[doc(alias = "kCTLineBreakByClipping")]
131    pub const ByClipping: Self = Self(2);
132    #[doc(alias = "kCTLineBreakByTruncatingHead")]
133    pub const ByTruncatingHead: Self = Self(3);
134    #[doc(alias = "kCTLineBreakByTruncatingTail")]
135    pub const ByTruncatingTail: Self = Self(4);
136    #[doc(alias = "kCTLineBreakByTruncatingMiddle")]
137    pub const ByTruncatingMiddle: Self = Self(5);
138}
139
140#[cfg(feature = "objc2")]
141unsafe impl Encode for CTLineBreakMode {
142    const ENCODING: Encoding = u8::ENCODING;
143}
144
145#[cfg(feature = "objc2")]
146unsafe impl RefEncode for CTLineBreakMode {
147    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
148}
149
150/// These constants specify the writing direction
151///
152///
153/// The writing direction is algorithmically determined
154/// using the Unicode Bidirectional Algorithm rules P2 and P3.
155///
156///
157/// The writing direction is left to right.
158///
159///
160/// The writing direction is right to left.
161///
162/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctwritingdirection?language=objc)
163// NS_ENUM
164#[repr(transparent)]
165#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
166pub struct CTWritingDirection(pub i8);
167impl CTWritingDirection {
168    #[doc(alias = "kCTWritingDirectionNatural")]
169    pub const Natural: Self = Self(-1);
170    #[doc(alias = "kCTWritingDirectionLeftToRight")]
171    pub const LeftToRight: Self = Self(0);
172    #[doc(alias = "kCTWritingDirectionRightToLeft")]
173    pub const RightToLeft: Self = Self(1);
174}
175
176#[cfg(feature = "objc2")]
177unsafe impl Encode for CTWritingDirection {
178    const ENCODING: Encoding = i8::ENCODING;
179}
180
181#[cfg(feature = "objc2")]
182unsafe impl RefEncode for CTWritingDirection {
183    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
184}
185
186/// These constants are used to query and modify the CTParagraphStyle
187/// object.
188///
189///
190/// Each specifier has a type and a default value associated with it.
191/// The type must always be observed when setting or fetching the
192/// value from the CTParagraphStyle object. In addition, some
193/// specifiers affect the behavior of both the framesetter and
194/// the typesetter, and others only affect the behavior of the
195/// framesetter; this is also noted below.
196///
197///
198/// The text alignment. Natural text alignment is realized as
199/// left or right alignment, depending on the line sweep direction
200/// of the first script contained in the paragraph.
201///
202/// Type: CTTextAlignment
203/// Default: kCTTextAlignmentNatural
204/// Application: CTFramesetter
205///
206///
207/// The distance in points from the leading margin of a frame to
208/// the beginning of the paragraph's first line. This value is always
209/// nonnegative.
210///
211/// Type: CGFloat
212/// Default: 0.0
213/// Application: CTFramesetter
214///
215///
216/// The distance in points from the leading margin of a text
217/// container to the beginning of lines other than the first.
218/// This value is always nonnegative.
219///
220/// Type: CGFloat
221/// Default: 0.0
222/// Application: CTFramesetter
223///
224///
225/// The distance in points from the margin of a frame to the end of
226/// lines. If positive, this value is the distance from the leading
227/// margin (for example, the left margin in left-to-right text).
228/// If 0 or negative, it's the distance from the trailing margin.
229///
230/// Type: CGFloat
231/// Default: 0.0
232/// Application: CTFramesetter
233///
234///
235/// The CTTextTab objects, sorted by location, that define the tab
236/// stops for the paragraph style.
237///
238/// Type: CFArray of CTTextTabRef
239/// Default: 12 left-aligned tabs, spaced by 28.0 points
240/// Application: CTFramesetter, CTTypesetter
241///
242///
243/// The document-wide default tab interval. Tabs after the last
244/// specified by kCTParagraphStyleSpecifierTabStops are placed at
245/// integer multiples of this distance (if positive).
246///
247/// Type: CGFloat
248/// Default: 0.0
249/// Application: CTFramesetter, CTTypesetter
250///
251///
252/// The mode that should be used to break lines when laying out
253/// the paragraph's text.
254///
255/// Type: CTLineBreakMode
256/// Default: kCTLineBreakByWordWrapping
257/// Application: CTFramesetter
258///
259///
260/// The line height multiple. The natural line height of the
261/// receiver is multiplied by this factor (if positive) before
262/// being constrained by minimum and maximum line height.
263///
264/// Type: CGFloat
265/// Default: 0.0
266/// Application: CTFramesetter
267///
268///
269/// The maximum height that any line in the frame will occupy,
270/// regardless of the font size or size of any attached graphic.
271/// Glyphs and graphics exceeding this height will overlap
272/// neighboring lines. A maximum height of 0 implies
273/// no line height limit. This value is always nonnegative.
274///
275/// Type: CGFloat
276/// Default: 0.0
277/// Application: CTFramesetter
278///
279///
280/// The minimum height that any line in the frame will occupy,
281/// regardless of the font size or size of any attached graphic.
282/// This value is always nonnegative.
283///
284/// Type: CGFloat
285/// Default: 0.0
286/// Application: CTFramesetter
287///
288///
289/// Deprecated.
290/// Use kCTParagraphStyleSpecifierMaximumLineSpacing, kCTParagraphStyleSpecifierMinimumLineSpacing,
291/// and kCTParagraphStyleSpecifierLineSpacingAdjustment to control
292/// space between lines.
293///
294///
295/// The space added at the end of the paragraph to separate it from
296/// the following paragraph. This value is always nonnegative and is
297/// determined by adding the previous paragraph's
298/// kCTParagraphStyleSpecifierParagraphSpacing setting and the
299/// current paragraph's kCTParagraphStyleSpecifierParagraphSpacingBefore
300/// setting.
301///
302/// Type: CGFloat
303/// Default: 0.0
304/// Application: CTFramesetter
305///
306///
307/// The distance between the paragraph's top and the beginning of
308/// its text content.
309///
310/// Type: CGFloat
311/// Default: 0.0
312/// Application: CTFramesetter
313///
314///
315/// The base writing direction of the lines.
316///
317/// Type: CTWritingDirection
318/// Default: kCTWritingDirectionNatural
319/// Application: CTFramesetter, CTTypesetter
320///
321///
322/// The maximum space in points between lines within the paragraph
323/// (commonly known as leading).
324///
325/// Type: CGFloat
326/// Default: some large number.
327/// Application: CTFramesetter
328///
329///
330/// The minimum space in points between lines within the paragraph
331/// (commonly known as leading).
332///
333/// Type: CGFloat
334/// Default: 0.0
335/// Application: CTFramesetter
336///
337///
338/// The space in points added between lines within the paragraph
339/// (commonly known as leading).
340///
341/// Type: CGFloat
342/// Default: 0.0
343/// Application: CTFramesetter
344///
345///
346/// The options controlling the alignment of the line edges with
347/// the leading and trailing margins.
348///
349/// Type: CTLineBoundsOptions
350/// Default: 0 (no options)
351/// Application: CTTypesetter
352///
353/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctparagraphstylespecifier?language=objc)
354// NS_ENUM
355#[repr(transparent)]
356#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
357pub struct CTParagraphStyleSpecifier(pub u32);
358impl CTParagraphStyleSpecifier {
359    #[doc(alias = "kCTParagraphStyleSpecifierAlignment")]
360    pub const Alignment: Self = Self(0);
361    #[doc(alias = "kCTParagraphStyleSpecifierFirstLineHeadIndent")]
362    pub const FirstLineHeadIndent: Self = Self(1);
363    #[doc(alias = "kCTParagraphStyleSpecifierHeadIndent")]
364    pub const HeadIndent: Self = Self(2);
365    #[doc(alias = "kCTParagraphStyleSpecifierTailIndent")]
366    pub const TailIndent: Self = Self(3);
367    #[doc(alias = "kCTParagraphStyleSpecifierTabStops")]
368    pub const TabStops: Self = Self(4);
369    #[doc(alias = "kCTParagraphStyleSpecifierDefaultTabInterval")]
370    pub const DefaultTabInterval: Self = Self(5);
371    #[doc(alias = "kCTParagraphStyleSpecifierLineBreakMode")]
372    pub const LineBreakMode: Self = Self(6);
373    #[doc(alias = "kCTParagraphStyleSpecifierLineHeightMultiple")]
374    pub const LineHeightMultiple: Self = Self(7);
375    #[doc(alias = "kCTParagraphStyleSpecifierMaximumLineHeight")]
376    pub const MaximumLineHeight: Self = Self(8);
377    #[doc(alias = "kCTParagraphStyleSpecifierMinimumLineHeight")]
378    pub const MinimumLineHeight: Self = Self(9);
379    #[deprecated = "See documentation for replacements"]
380    #[doc(alias = "kCTParagraphStyleSpecifierLineSpacing")]
381    pub const LineSpacing: Self = Self(10);
382    #[doc(alias = "kCTParagraphStyleSpecifierParagraphSpacing")]
383    pub const ParagraphSpacing: Self = Self(11);
384    #[doc(alias = "kCTParagraphStyleSpecifierParagraphSpacingBefore")]
385    pub const ParagraphSpacingBefore: Self = Self(12);
386    #[doc(alias = "kCTParagraphStyleSpecifierBaseWritingDirection")]
387    pub const BaseWritingDirection: Self = Self(13);
388    #[doc(alias = "kCTParagraphStyleSpecifierMaximumLineSpacing")]
389    pub const MaximumLineSpacing: Self = Self(14);
390    #[doc(alias = "kCTParagraphStyleSpecifierMinimumLineSpacing")]
391    pub const MinimumLineSpacing: Self = Self(15);
392    #[doc(alias = "kCTParagraphStyleSpecifierLineSpacingAdjustment")]
393    pub const LineSpacingAdjustment: Self = Self(16);
394    #[doc(alias = "kCTParagraphStyleSpecifierLineBoundsOptions")]
395    pub const LineBoundsOptions: Self = Self(17);
396    #[doc(alias = "kCTParagraphStyleSpecifierCount")]
397    pub const Count: Self = Self(18);
398}
399
400#[cfg(feature = "objc2")]
401unsafe impl Encode for CTParagraphStyleSpecifier {
402    const ENCODING: Encoding = u32::ENCODING;
403}
404
405#[cfg(feature = "objc2")]
406unsafe impl RefEncode for CTParagraphStyleSpecifier {
407    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
408}
409
410/// This structure is used to alter the paragraph style.
411///
412/// Field: spec
413/// The specifier of the setting.
414///
415/// Field: valueSize
416/// The size of the value pointed to by the "value" field. This
417/// must match the size of the value required by the
418/// CTParagraphStyleSpecifier set in the "spec" field.
419///
420/// Field: value
421/// A reference to the value of the setting specified by the
422/// "spec" field. The value must be in the proper range for the
423/// spec value. The value must also be at least valueSize.
424///
425/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctparagraphstylesetting?language=objc)
426#[repr(C)]
427#[derive(Clone, Copy, Debug, PartialEq)]
428pub struct CTParagraphStyleSetting {
429    pub spec: CTParagraphStyleSpecifier,
430    pub valueSize: usize,
431    pub value: NonNull<c_void>,
432}
433
434#[cfg(feature = "objc2")]
435unsafe impl Encode for CTParagraphStyleSetting {
436    const ENCODING: Encoding = Encoding::Struct(
437        "CTParagraphStyleSetting",
438        &[
439            <CTParagraphStyleSpecifier>::ENCODING,
440            <usize>::ENCODING,
441            <NonNull<c_void>>::ENCODING,
442        ],
443    );
444}
445
446#[cfg(feature = "objc2")]
447unsafe impl RefEncode for CTParagraphStyleSetting {
448    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
449}
450
451/// Creates an immutable paragraph style.
452///
453///
454/// Using this function is the easiest and most efficient way to
455/// create a paragraph style. Paragraph styles should be kept
456/// immutable for totally lock-free operation.
457///
458/// If an invalid paragraph style setting specifier is passed into
459/// the "settings" parameter, nothing bad will happen but just don't
460/// expect to be able to query for this value. This is to allow
461/// backwards compatibility with style setting specifiers that may
462/// be introduced in future versions.
463///
464///
465/// Parameter `settings`: The settings that you wish to pre-load the paragraph style
466/// with. If you wish to specify the default set of settings,
467/// then this parameter may be set to NULL.
468///
469///
470/// Parameter `settingCount`: The number of settings that you have specified in the
471/// "settings" parameter. This must be greater than or equal
472/// to zero.
473///
474///
475/// Returns: If the paragraph style creation was successful, this function
476/// will return a valid reference to an immutable CTParagraphStyle
477/// object. Otherwise, this function will return NULL.
478#[inline]
479pub unsafe extern "C-unwind" fn CTParagraphStyleCreate(
480    settings: *const CTParagraphStyleSetting,
481    setting_count: usize,
482) -> CFRetained<CTParagraphStyle> {
483    extern "C-unwind" {
484        fn CTParagraphStyleCreate(
485            settings: *const CTParagraphStyleSetting,
486            setting_count: usize,
487        ) -> Option<NonNull<CTParagraphStyle>>;
488    }
489    let ret = unsafe { CTParagraphStyleCreate(settings, setting_count) };
490    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
491    unsafe { CFRetained::from_raw(ret) }
492}
493
494/// Creates an immutable copy of a paragraph style.
495///
496///
497/// Parameter `paragraphStyle`: The style that you wish to copy.
498///
499///
500/// Returns: If the "paragraphStyle" reference is valid, then this
501/// function will return valid reference to an immutable
502/// CTParagraphStyle object that is a copy of the one passed into
503/// "paragraphStyle".
504#[inline]
505pub unsafe extern "C-unwind" fn CTParagraphStyleCreateCopy(
506    paragraph_style: &CTParagraphStyle,
507) -> CFRetained<CTParagraphStyle> {
508    extern "C-unwind" {
509        fn CTParagraphStyleCreateCopy(
510            paragraph_style: &CTParagraphStyle,
511        ) -> Option<NonNull<CTParagraphStyle>>;
512    }
513    let ret = unsafe { CTParagraphStyleCreateCopy(paragraph_style) };
514    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
515    unsafe { CFRetained::from_raw(ret) }
516}
517
518extern "C-unwind" {
519    /// Obtains the current value for a single setting specifier.
520    ///
521    ///
522    /// This function will return the current value of the specifier
523    /// whether or not the user had actually set it. If the user has
524    /// not set it, this function will return the default value.
525    ///
526    /// If an invalid paragraph style setting specifier is passed into
527    /// the "spec" parameter, nothing bad will happen and the buffer
528    /// value will simply be zeroed out. This is to allow backwards
529    /// compatibility with style setting specifier that may be introduced
530    /// in future versions.
531    ///
532    ///
533    /// Parameter `paragraphStyle`: The paragraph style that you wish to get the value from.
534    ///
535    ///
536    /// Parameter `spec`: The setting specifier that you want to get the value for.
537    ///
538    ///
539    /// Parameter `valueBufferSize`: The size of the buffer pointed to by the "valueBuffer" parameter.
540    /// This value must be at least as large as the size the required by
541    /// the CTParagraphSpecifier value set in the "spec" parameter.
542    ///
543    ///
544    /// Parameter `valueBuffer`: The buffer where the requested setting value will be written
545    /// upon successful completion. The buffer's size needs to be at least
546    /// as large as the value passed into "valueBufferSize".
547    ///
548    ///
549    /// Returns: This function will return "true" if the valueBuffer had been
550    /// successfully filled. Otherwise, this function will return false,
551    /// indicating that one or more of the parameters is not valid.
552    pub fn CTParagraphStyleGetValueForSpecifier(
553        paragraph_style: &CTParagraphStyle,
554        spec: CTParagraphStyleSpecifier,
555        value_buffer_size: usize,
556        value_buffer: NonNull<c_void>,
557    ) -> bool;
558}