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