Skip to main content

ohos_drawing_sys/text_line/
text_line_ffi.rs

1// automatically generated by rust-bindgen 0.71.1
2
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6use crate::text_declaration::{OH_Drawing_Run, OH_Drawing_TextLine, OH_Drawing_Typography};
7use crate::types::*;
8
9/// User-defined callback functions for using offsets and indexes.
10///
11///
12/// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
13/// # Arguments
14///
15/// * `offset` - Character offset is traversed as an argument to the callback function.
16///
17/// * `index` - Character index is traversed as an argument to the callback function.
18///
19/// * `leadingEdge` - Whether the current offset is at the character front, as an argument to the callback function.
20///
21/// # Returns
22///
23/// * The return value of the user-defined callback function.
24/// If false is returned, the traversal continues.
25/// If true is returned, the traversal stops.
26///
27/// Available since API-level: 18
28///
29/// Version: 1.0
30#[cfg(feature = "api-18")]
31#[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
32pub type Drawing_CaretOffsetsCallback = ::core::option::Option<
33    unsafe extern "C" fn(offset: f64, index: i32, leadingEdge: bool) -> bool,
34>;
35extern "C" {
36    /// Get text line information.
37    ///
38    ///
39    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
40    /// # Arguments
41    ///
42    /// * `typography` - Indicates the pointer to a typography object <b>OH_Drawing_Typography</b>.
43    ///
44    /// # Returns
45    ///
46    /// * Indicates the pointer to a text line array object <b>OH_Drawing_Array</b>.
47    ///
48    /// Available since API-level: 18
49    #[cfg(feature = "api-18")]
50    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
51    pub fn OH_Drawing_TypographyGetTextLines(
52        typography: *mut OH_Drawing_Typography,
53    ) -> *mut OH_Drawing_Array;
54    /// Releases the memory occupied by the text line array object <b>OH_Drawing_Array</b>.
55    ///
56    ///
57    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
58    /// # Arguments
59    ///
60    /// * `lines` - Indicates the pointer to the text line array object <b>OH_Drawing_Array</b>.
61    ///
62    /// Available since API-level: 18
63    ///
64    /// Version: 1.0
65    #[cfg(feature = "api-18")]
66    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
67    pub fn OH_Drawing_DestroyTextLines(lines: *mut OH_Drawing_Array);
68    /// Releases the memory occupied by the text line object <b>OH_Drawing_TextLine</b>.
69    ///
70    ///
71    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
72    /// # Arguments
73    ///
74    /// * `line` - Indicates the pointer to the text line object <b>OH_Drawing_TextLine</b>.
75    ///
76    /// Available since API-level: 18
77    ///
78    /// Version: 1.0
79    #[cfg(feature = "api-18")]
80    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
81    pub fn OH_Drawing_DestroyTextLine(line: *mut OH_Drawing_TextLine);
82    /// Get the text line object by index.
83    ///
84    ///
85    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
86    /// # Arguments
87    ///
88    /// * `lines` - Indicates the pointer to the text line array object <b>OH_Drawing_Array</b>.
89    ///
90    /// * `index` - The text line object index.
91    ///
92    /// # Returns
93    ///
94    /// * Indicates the pointer to a text line object <b>OH_Drawing_TextLine</b>.
95    ///
96    /// Available since API-level: 18
97    #[cfg(feature = "api-18")]
98    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
99    pub fn OH_Drawing_GetTextLineByIndex(
100        lines: *mut OH_Drawing_Array,
101        index: usize,
102    ) -> *mut OH_Drawing_TextLine;
103    /// Get the count of glyphs.
104    ///
105    ///
106    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
107    /// # Arguments
108    ///
109    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
110    ///
111    /// # Returns
112    ///
113    /// * Returns the count of glyphs.
114    ///
115    /// Available since API-level: 18
116    ///
117    /// Version: 1.0
118    #[cfg(feature = "api-18")]
119    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
120    pub fn OH_Drawing_TextLineGetGlyphCount(line: *mut OH_Drawing_TextLine) -> f64;
121    /// Get the range of text line.
122    ///
123    ///
124    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
125    /// # Arguments
126    ///
127    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
128    ///
129    /// * `start` - Indicates the pointer to text line start position.
130    ///
131    /// * `end` - Indicates the pointer to text line end position.
132    ///
133    /// Available since API-level: 18
134    ///
135    /// Version: 1.0
136    #[cfg(feature = "api-18")]
137    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
138    pub fn OH_Drawing_TextLineGetTextRange(
139        line: *mut OH_Drawing_TextLine,
140        start: *mut usize,
141        end: *mut usize,
142    );
143    /// Get the glyph runs array of text line.
144    ///
145    ///
146    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
147    /// # Arguments
148    ///
149    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
150    ///
151    /// # Returns
152    ///
153    /// * Indicates the pointer to a glyph runs array object of text line <b>OH_Drawing_Array</b>.
154    ///
155    /// Available since API-level: 18
156    ///
157    /// Version: 1.0
158    #[cfg(feature = "api-18")]
159    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
160    pub fn OH_Drawing_TextLineGetGlyphRuns(line: *mut OH_Drawing_TextLine)
161        -> *mut OH_Drawing_Array;
162    /// Releases the memory occupied by the run array object <b>OH_Drawing_Array</b>.
163    ///
164    ///
165    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
166    /// # Arguments
167    ///
168    /// * `runs` - Indicates the pointer to the run array object <b>OH_Drawing_Array</b>.
169    ///
170    /// Available since API-level: 18
171    ///
172    /// Version: 1.0
173    #[cfg(feature = "api-18")]
174    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
175    pub fn OH_Drawing_DestroyRuns(runs: *mut OH_Drawing_Array);
176    /// Get the run object by index.
177    ///
178    ///
179    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
180    /// # Arguments
181    ///
182    /// * `runs` - Indicates the pointer to the run array object <b>OH_Drawing_Array</b>.
183    ///
184    /// * `index` - The run object index.
185    ///
186    /// # Returns
187    ///
188    /// * Indicates the pointer to a run object <b>OH_Drawing_Run</b>.
189    ///
190    /// Available since API-level: 18
191    #[cfg(feature = "api-18")]
192    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
193    pub fn OH_Drawing_GetRunByIndex(
194        runs: *mut OH_Drawing_Array,
195        index: usize,
196    ) -> *mut OH_Drawing_Run;
197    /// Paint the range of text line.
198    ///
199    ///
200    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
201    /// # Arguments
202    ///
203    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
204    ///
205    /// * `canvas` - Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
206    ///
207    /// * `x` - Represents the X-axis position on the canvas.
208    ///
209    /// * `y` - Represents the Y-axis position on the canvas.
210    ///
211    /// Available since API-level: 18
212    ///
213    /// Version: 1.0
214    #[cfg(feature = "api-18")]
215    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
216    pub fn OH_Drawing_TextLinePaint(
217        line: *mut OH_Drawing_TextLine,
218        canvas: *mut OH_Drawing_Canvas,
219        x: f64,
220        y: f64,
221    );
222    /// Creates a truncated text line object.
223    ///
224    ///
225    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
226    /// # Arguments
227    ///
228    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
229    ///
230    /// * `width` - Indicates the text line width to set.
231    ///
232    /// * `mode` - Indicates the ellipsis model to set, EllipsisMode:MIDDLE is not supported.
233    /// For details, see the enum <b>OH_Drawing_EllipsisModal</b>.
234    ///
235    /// * `ellipsis` - Indicates the ellipsis string to set.
236    ///
237    /// # Returns
238    ///
239    /// * Returns the pointer to the <b>OH_Drawing_TextLine</b> object created.
240    ///
241    /// Available since API-level: 18
242    ///
243    /// Version: 1.0
244    #[cfg(feature = "api-18")]
245    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
246    pub fn OH_Drawing_TextLineCreateTruncatedLine(
247        line: *mut OH_Drawing_TextLine,
248        width: f64,
249        mode: ::core::ffi::c_int,
250        ellipsis: *const ::core::ffi::c_char,
251    ) -> *mut OH_Drawing_TextLine;
252    /// Gets the text line typographic bounds.
253    ///
254    ///
255    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
256    /// # Arguments
257    ///
258    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
259    ///
260    /// * `ascent` - Indicates the distance that the pointer points to remain above the baseline.
261    ///
262    /// * `descent` - Indicates the pointer to the distance that remains below the baseline.
263    ///
264    /// * `leading` - Indicates the pointer to the line Spacing.
265    ///
266    /// # Returns
267    ///
268    /// * Returns The total width of the typesetting border.
269    ///
270    /// Available since API-level: 18
271    ///
272    /// Version: 1.0
273    #[cfg(feature = "api-18")]
274    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
275    pub fn OH_Drawing_TextLineGetTypographicBounds(
276        line: *mut OH_Drawing_TextLine,
277        ascent: *mut f64,
278        descent: *mut f64,
279        leading: *mut f64,
280    ) -> f64;
281    /// Gets the text line image bounds.
282    ///
283    ///
284    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
285    /// # Arguments
286    ///
287    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
288    ///
289    /// # Returns
290    ///
291    /// * Returns the pointer to the <b>OH_Drawing_Rect</b> struct created.
292    ///
293    /// Available since API-level: 18
294    ///
295    /// Version: 1.0
296    #[cfg(feature = "api-18")]
297    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
298    pub fn OH_Drawing_TextLineGetImageBounds(
299        line: *mut OH_Drawing_TextLine,
300    ) -> *mut OH_Drawing_Rect;
301    /// Gets the tail space width.
302    ///
303    ///
304    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
305    /// # Arguments
306    ///
307    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
308    ///
309    /// # Returns
310    ///
311    /// * Returns the tail space width.
312    ///
313    /// Available since API-level: 18
314    ///
315    /// Version: 1.0
316    #[cfg(feature = "api-18")]
317    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
318    pub fn OH_Drawing_TextLineGetTrailingSpaceWidth(line: *mut OH_Drawing_TextLine) -> f64;
319    /// Gets the string index of the given position.
320    ///
321    ///
322    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
323    /// # Arguments
324    ///
325    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
326    ///
327    /// * `point` - Indicates the pointer to an <b>OH_Drawing_Point</b> object.
328    ///
329    /// # Returns
330    ///
331    /// * Returns the string index for a given position.
332    ///
333    /// Available since API-level: 18
334    #[cfg(feature = "api-18")]
335    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
336    pub fn OH_Drawing_TextLineGetStringIndexForPosition(
337        line: *mut OH_Drawing_TextLine,
338        point: *mut OH_Drawing_Point,
339    ) -> i32;
340    /// Gets the offset of the given string index.
341    ///
342    ///
343    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
344    /// # Arguments
345    ///
346    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
347    ///
348    /// * `index` - The given string index.
349    ///
350    /// # Returns
351    ///
352    /// * Returns the offset for a given string index.
353    ///
354    /// Available since API-level: 18
355    #[cfg(feature = "api-18")]
356    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
357    pub fn OH_Drawing_TextLineGetOffsetForStringIndex(
358        line: *mut OH_Drawing_TextLine,
359        index: i32,
360    ) -> f64;
361    /// Enumerate caret offset and index in text lines.
362    ///
363    ///
364    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
365    /// # Arguments
366    ///
367    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
368    ///
369    /// * `callback` - User-defined callback functions, see <b>Drawing_CaretOffsetsCallback</b>.
370    ///
371    /// Available since API-level: 18
372    #[cfg(feature = "api-18")]
373    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
374    pub fn OH_Drawing_TextLineEnumerateCaretOffsets(
375        line: *mut OH_Drawing_TextLine,
376        callback: Drawing_CaretOffsetsCallback,
377    );
378    /// Gets the text offset based on the given alignment factor and alignment width.
379    ///
380    ///
381    /// Required System Capabilities: SystemCapability.Graphic.Graphic2D.NativeDrawing
382    /// # Arguments
383    ///
384    /// * `line` - Indicates the pointer to an <b>OH_Drawing_TextLine</b> object.
385    ///
386    /// * `alignmentFactor` - The coefficients that text needs to be aligned.
387    /// Less than or equal to 0 is left justified, 0.5 is center justified,
388    /// and greater than or equal to 1 is right justified.
389    ///
390    /// * `alignmentWidth` - The width of the text to be aligned.
391    /// Returns 0 if it is less than the actual width of the text.
392    ///
393    /// # Returns
394    ///
395    /// * Returns the offset of the aligned text.
396    ///
397    /// Available since API-level: 18
398    ///
399    /// Version: 1.0
400    #[cfg(feature = "api-18")]
401    #[cfg_attr(docsrs, doc(cfg(feature = "api-18")))]
402    pub fn OH_Drawing_TextLineGetAlignmentOffset(
403        line: *mut OH_Drawing_TextLine,
404        alignmentFactor: f64,
405        alignmentWidth: f64,
406    ) -> f64;
407}