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