objc2_core_text/generated/
CTFrame.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#[cfg(feature = "objc2-core-graphics")]
11use objc2_core_graphics::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/coretext/ctframe?language=objc)
16#[repr(C)]
17pub struct CTFrame {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl CTFrame {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"__CTFrame"> for CTFrame {}
28);
29
30unsafe impl ConcreteType for CTFrame {
31    /// Returns the CFType of the frame object
32    #[doc(alias = "CTFrameGetTypeID")]
33    #[inline]
34    fn type_id() -> CFTypeID {
35        extern "C-unwind" {
36            fn CTFrameGetTypeID() -> CFTypeID;
37        }
38        unsafe { CTFrameGetTypeID() }
39    }
40}
41
42/// These constants specify frame progression types.
43///
44///
45/// The lines of text within a frame may be stacked for either
46/// horizontal or vertical text. Values are enumerated for each
47/// stacking type supported by CTFrame. Frames created with a
48/// progression type specifying vertical text will rotate lines
49/// 90 degrees counterclockwise when drawing.
50///
51///
52/// Lines are stacked top to bottom for horizontal text.
53///
54///
55/// Lines are stacked right to left for vertical text.
56///
57///
58/// Lines are stacked left to right for vertical text.
59///
60/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctframeprogression?language=objc)
61// NS_ENUM
62#[repr(transparent)]
63#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
64pub struct CTFrameProgression(pub u32);
65impl CTFrameProgression {
66    #[doc(alias = "kCTFrameProgressionTopToBottom")]
67    pub const TopToBottom: Self = Self(0);
68    #[doc(alias = "kCTFrameProgressionRightToLeft")]
69    pub const RightToLeft: Self = Self(1);
70    #[doc(alias = "kCTFrameProgressionLeftToRight")]
71    pub const LeftToRight: Self = Self(2);
72}
73
74#[cfg(feature = "objc2")]
75unsafe impl Encode for CTFrameProgression {
76    const ENCODING: Encoding = u32::ENCODING;
77}
78
79#[cfg(feature = "objc2")]
80unsafe impl RefEncode for CTFrameProgression {
81    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
82}
83
84extern "C" {
85    /// Specifies progression for a frame.
86    ///
87    ///
88    /// Value must be a CFNumberRef containing a CTFrameProgression.
89    /// Default is kCTFrameProgressionTopToBottom. This value determines
90    /// the line stacking behavior for a frame and does not affect the
91    /// appearance of the glyphs within that frame.
92    ///
93    ///
94    /// See also: CTFramesetterCreateFrame
95    ///
96    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctframeprogressionattributename?language=objc)
97    pub static kCTFrameProgressionAttributeName: &'static CFString;
98}
99
100/// These constants specify fill rule used by the frame.
101///
102///
103/// When a path intersects with itself, the client should specify which rule to use for deciding the
104/// area of the path.
105///
106///
107/// Text is filled in the area that would be painted if the path were given to CGContextEOFillPath.
108///
109///
110/// Text is fill in the area that would be painted if the path were given to CGContextFillPath.
111///
112/// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/ctframepathfillrule?language=objc)
113// NS_ENUM
114#[repr(transparent)]
115#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
116pub struct CTFramePathFillRule(pub u32);
117impl CTFramePathFillRule {
118    #[doc(alias = "kCTFramePathFillEvenOdd")]
119    pub const EvenOdd: Self = Self(0);
120    #[doc(alias = "kCTFramePathFillWindingNumber")]
121    pub const WindingNumber: Self = Self(1);
122}
123
124#[cfg(feature = "objc2")]
125unsafe impl Encode for CTFramePathFillRule {
126    const ENCODING: Encoding = u32::ENCODING;
127}
128
129#[cfg(feature = "objc2")]
130unsafe impl RefEncode for CTFramePathFillRule {
131    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
132}
133
134extern "C" {
135    /// Specifies fill rule for a frame if this attribute is used at top level of frameAttributes dictionary, or specify
136    /// fill rule for a clipping path if used in a dictionary contained in an array specified by kCTFrameClippingPathsAttributeName.
137    ///
138    ///
139    /// Value must be a CFNumberRef containing kCTFramePathFillEvenOdd or kCTFramePathFillWindingNumber.
140    /// Default is kCTFramePathFillEvenOdd.
141    ///
142    ///
143    /// See also: CTFramesetterCreateFrame
144    ///
145    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctframepathfillruleattributename?language=objc)
146    pub static kCTFramePathFillRuleAttributeName: &'static CFString;
147}
148
149extern "C" {
150    /// Specifies frame width if this attribute is used at top level of frameAttributes dictionary, or specify
151    /// clipping path width if used in a dictionary contained in an array specified by kCTFrameClippingPathsAttributeName.
152    ///
153    ///
154    /// Value must be a CFNumberRef specifying frame width.
155    /// Default is zero.
156    ///
157    ///
158    /// See also: CTFramesetterCreateFrame
159    ///
160    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctframepathwidthattributename?language=objc)
161    pub static kCTFramePathWidthAttributeName: &'static CFString;
162}
163
164extern "C" {
165    /// Specifies array of paths to clip frame.
166    ///
167    ///
168    /// Value must be a CFArrayRef containing CFDictionaryRefs or CGPathRef.  (CGPathRef is allowed on 10.8 or later.)
169    /// Each dictionary should have a kCTFramePathClippingPathAttributeName key-value pair, and can have a kCTFramePathFillRuleAttributeName key-value pair
170    /// and kCTFramePathFillRuleAttributeName key-value pair as optional parameters.  In case of CGPathRef, default fill rule (kCTFramePathFillEvenOdd) and width (0.0) are used.
171    ///
172    ///
173    /// See also: CTFramesetterCreateFrame
174    ///
175    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctframeclippingpathsattributename?language=objc)
176    pub static kCTFrameClippingPathsAttributeName: &'static CFString;
177}
178
179extern "C" {
180    /// Specifies clipping path.  This attribute is valid in a dictionary contained in an array specified by kCTFrameClippingPathsAttributeName.
181    /// On 10.8 or later, This attribute is also valid in frameAttributes dictionary passed to CTFramesetterCreateFrame.
182    ///
183    ///
184    /// Value must be a CGPathRef specifying a clipping path.
185    ///
186    ///
187    /// See also: kCTFrameClippingPathsAttributeName
188    ///
189    /// See also [Apple's documentation](https://developer.apple.com/documentation/coretext/kctframepathclippingpathattributename?language=objc)
190    pub static kCTFramePathClippingPathAttributeName: &'static CFString;
191}
192
193impl CTFrame {
194    /// Returns the range of characters that were originally requested
195    /// to fill the frame.
196    ///
197    ///
198    /// Parameter `frame`: The frame that you want to get the character range from.
199    ///
200    ///
201    /// Returns: This function will return a CFRange containing the backing
202    /// store range of characters that were originally requested
203    /// to fill the frame. If the function call is not successful,
204    /// then an empty range will be returned.
205    #[doc(alias = "CTFrameGetStringRange")]
206    #[inline]
207    pub unsafe fn string_range(self: &CTFrame) -> CFRange {
208        extern "C-unwind" {
209            fn CTFrameGetStringRange(frame: &CTFrame) -> CFRange;
210        }
211        unsafe { CTFrameGetStringRange(self) }
212    }
213
214    /// Returns the range of characters that actually fit in the
215    /// frame.
216    ///
217    ///
218    /// This can be used to chain frames, as it returns the range of
219    /// characters that can be seen in the frame. The next frame would
220    /// start where this frame ends.
221    ///
222    ///
223    /// Parameter `frame`: The frame that you want to get the visible character range
224    /// from.
225    ///
226    ///
227    /// Returns: This function will return a CFRange containing the backing
228    /// store range of characters that fit into the frame. If the
229    /// function call is not successful, or if no characters fit
230    /// in the frame, then an empty range will be returned.
231    #[doc(alias = "CTFrameGetVisibleStringRange")]
232    #[inline]
233    pub unsafe fn visible_string_range(self: &CTFrame) -> CFRange {
234        extern "C-unwind" {
235            fn CTFrameGetVisibleStringRange(frame: &CTFrame) -> CFRange;
236        }
237        unsafe { CTFrameGetVisibleStringRange(self) }
238    }
239
240    /// Returns the path used to create the frame.
241    ///
242    ///
243    /// Parameter `frame`: The frame that you want to obtain the path from.
244    #[doc(alias = "CTFrameGetPath")]
245    #[cfg(feature = "objc2-core-graphics")]
246    #[inline]
247    pub unsafe fn path(self: &CTFrame) -> CFRetained<CGPath> {
248        extern "C-unwind" {
249            fn CTFrameGetPath(frame: &CTFrame) -> Option<NonNull<CGPath>>;
250        }
251        let ret = unsafe { CTFrameGetPath(self) };
252        let ret =
253            ret.expect("function was marked as returning non-null, but actually returned NULL");
254        unsafe { CFRetained::retain(ret) }
255    }
256
257    /// Returns the frame attributes used to create the frame.
258    ///
259    ///
260    /// It is possible to create a frame with an attributes dictionary
261    /// in order to control various aspects of the framing process.
262    /// These attributes are different from the ones that are used to
263    /// create an attributed string.
264    ///
265    ///
266    /// Parameter `frame`: The frame that you want to obtain the frame attributes from.
267    ///
268    ///
269    /// Returns: This function will return a CFDictionary containing the
270    /// frame attributes that were used to create the frame. If the
271    /// frame was created without any frame attributes, this function
272    /// will return NULL.
273    #[doc(alias = "CTFrameGetFrameAttributes")]
274    #[inline]
275    pub unsafe fn frame_attributes(self: &CTFrame) -> Option<CFRetained<CFDictionary>> {
276        extern "C-unwind" {
277            fn CTFrameGetFrameAttributes(frame: &CTFrame) -> Option<NonNull<CFDictionary>>;
278        }
279        let ret = unsafe { CTFrameGetFrameAttributes(self) };
280        ret.map(|ret| unsafe { CFRetained::retain(ret) })
281    }
282
283    /// Returns an array of lines that make up the frame.
284    ///
285    ///
286    /// This function will return an array of CTLine objects that are
287    /// stored in the frame. These line objects can be accessed and
288    /// manipulated in any way that normal line objects can be. It is
289    /// possible that an empty frame exists. That is, a frame in which
290    /// no lines exist. In this case, the returned array will have 0
291    /// entries.
292    ///
293    ///
294    /// Parameter `frame`: The frame that you want to obtain the line array from.
295    ///
296    ///
297    /// Returns: This function will return a CFArray object containing the
298    /// CTLine objects that make up the frame.
299    #[doc(alias = "CTFrameGetLines")]
300    #[inline]
301    pub unsafe fn lines(self: &CTFrame) -> CFRetained<CFArray> {
302        extern "C-unwind" {
303            fn CTFrameGetLines(frame: &CTFrame) -> Option<NonNull<CFArray>>;
304        }
305        let ret = unsafe { CTFrameGetLines(self) };
306        let ret =
307            ret.expect("function was marked as returning non-null, but actually returned NULL");
308        unsafe { CFRetained::retain(ret) }
309    }
310
311    /// Copies a range of line origins for a frame.
312    ///
313    ///
314    /// This function will copy a range of CGPoint structures. Each
315    /// CGPoint is the origin of the corresponding line in the array of
316    /// lines returned by CTFrameGetLines, relative to the origin of the
317    /// frame's path. The maximum number of line origins returned by
318    /// this function is the count of the array of lines.
319    ///
320    ///
321    /// Parameter `frame`: The frame that you want to obtain the line origin array from.
322    ///
323    ///
324    /// Parameter `range`: The range of line origins you wish to copy. If the length of the
325    /// range is set to 0, then the copy operation will continue from
326    /// the range's start index to the last line origin.
327    ///
328    ///
329    /// Parameter `origins`: The buffer to which the origins will be copied. The buffer must
330    /// have at least as many elements as specified by range's length.
331    /// When using the origins to calculate measurements for a frame's
332    /// contents, remember that line origins do not always correspond to
333    /// line metrics; paragraph style settings can affect line origins,
334    /// for one. The overall typographic bounds of a frame may generally
335    /// be calculated as the difference between the top of the frame and
336    /// the descent of the last line. This will obviously exclude any
337    /// spacing following the last line, but such spacing has no effect
338    /// on framesetting in the first place.
339    #[doc(alias = "CTFrameGetLineOrigins")]
340    #[inline]
341    pub unsafe fn line_origins(self: &CTFrame, range: CFRange, origins: NonNull<CGPoint>) {
342        extern "C-unwind" {
343            fn CTFrameGetLineOrigins(frame: &CTFrame, range: CFRange, origins: NonNull<CGPoint>);
344        }
345        unsafe { CTFrameGetLineOrigins(self, range, origins) }
346    }
347
348    /// Draws an entire frame to a context.
349    ///
350    ///
351    /// This function will draw an entire frame to the context. Note
352    /// that this call may leave the context in any state and does not
353    /// flush it after the draw operation.
354    ///
355    ///
356    /// Parameter `frame`: The frame that you want to draw.
357    ///
358    ///
359    /// Parameter `context`: The context to draw the frame to.
360    ///
361    ///
362    /// If both the frame and the context are valid, the frame will be
363    /// drawn in the context.
364    #[doc(alias = "CTFrameDraw")]
365    #[cfg(feature = "objc2-core-graphics")]
366    #[inline]
367    pub unsafe fn draw(self: &CTFrame, context: &CGContext) {
368        extern "C-unwind" {
369            fn CTFrameDraw(frame: &CTFrame, context: &CGContext);
370        }
371        unsafe { CTFrameDraw(self, context) }
372    }
373}
374
375extern "C-unwind" {
376    #[deprecated = "renamed to `CTFrame::string_range`"]
377    pub fn CTFrameGetStringRange(frame: &CTFrame) -> CFRange;
378}
379
380extern "C-unwind" {
381    #[deprecated = "renamed to `CTFrame::visible_string_range`"]
382    pub fn CTFrameGetVisibleStringRange(frame: &CTFrame) -> CFRange;
383}
384
385#[cfg(feature = "objc2-core-graphics")]
386#[deprecated = "renamed to `CTFrame::path`"]
387#[inline]
388pub unsafe extern "C-unwind" fn CTFrameGetPath(frame: &CTFrame) -> CFRetained<CGPath> {
389    extern "C-unwind" {
390        fn CTFrameGetPath(frame: &CTFrame) -> Option<NonNull<CGPath>>;
391    }
392    let ret = unsafe { CTFrameGetPath(frame) };
393    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
394    unsafe { CFRetained::retain(ret) }
395}
396
397#[deprecated = "renamed to `CTFrame::frame_attributes`"]
398#[inline]
399pub unsafe extern "C-unwind" fn CTFrameGetFrameAttributes(
400    frame: &CTFrame,
401) -> Option<CFRetained<CFDictionary>> {
402    extern "C-unwind" {
403        fn CTFrameGetFrameAttributes(frame: &CTFrame) -> Option<NonNull<CFDictionary>>;
404    }
405    let ret = unsafe { CTFrameGetFrameAttributes(frame) };
406    ret.map(|ret| unsafe { CFRetained::retain(ret) })
407}
408
409#[deprecated = "renamed to `CTFrame::lines`"]
410#[inline]
411pub unsafe extern "C-unwind" fn CTFrameGetLines(frame: &CTFrame) -> CFRetained<CFArray> {
412    extern "C-unwind" {
413        fn CTFrameGetLines(frame: &CTFrame) -> Option<NonNull<CFArray>>;
414    }
415    let ret = unsafe { CTFrameGetLines(frame) };
416    let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
417    unsafe { CFRetained::retain(ret) }
418}
419
420extern "C-unwind" {
421    #[deprecated = "renamed to `CTFrame::line_origins`"]
422    pub fn CTFrameGetLineOrigins(frame: &CTFrame, range: CFRange, origins: NonNull<CGPoint>);
423}
424
425extern "C-unwind" {
426    #[cfg(feature = "objc2-core-graphics")]
427    #[deprecated = "renamed to `CTFrame::draw`"]
428    pub fn CTFrameDraw(frame: &CTFrame, context: &CGContext);
429}