pango/auto/
layout.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib::translate::*;
6use glib::GString;
7use pango_sys;
8use std::fmt;
9use std::mem;
10use Alignment;
11use AttrList;
12use Context;
13use EllipsizeMode;
14use FontDescription;
15use LayoutIter;
16use LayoutLine;
17use Rectangle;
18use TabArray;
19use WrapMode;
20
21glib_wrapper! {
22    pub struct Layout(Object<pango_sys::PangoLayout, pango_sys::PangoLayoutClass, LayoutClass>);
23
24    match fn {
25        get_type => || pango_sys::pango_layout_get_type(),
26    }
27}
28
29impl Layout {
30    pub fn new(context: &Context) -> Layout {
31        unsafe { from_glib_full(pango_sys::pango_layout_new(context.to_glib_none().0)) }
32    }
33
34    pub fn context_changed(&self) {
35        unsafe {
36            pango_sys::pango_layout_context_changed(self.to_glib_none().0);
37        }
38    }
39
40    pub fn copy(&self) -> Option<Layout> {
41        unsafe { from_glib_full(pango_sys::pango_layout_copy(self.to_glib_none().0)) }
42    }
43
44    pub fn get_alignment(&self) -> Alignment {
45        unsafe { from_glib(pango_sys::pango_layout_get_alignment(self.to_glib_none().0)) }
46    }
47
48    pub fn get_attributes(&self) -> Option<AttrList> {
49        unsafe {
50            from_glib_none(pango_sys::pango_layout_get_attributes(
51                self.to_glib_none().0,
52            ))
53        }
54    }
55
56    pub fn get_auto_dir(&self) -> bool {
57        unsafe { from_glib(pango_sys::pango_layout_get_auto_dir(self.to_glib_none().0)) }
58    }
59
60    pub fn get_baseline(&self) -> i32 {
61        unsafe { pango_sys::pango_layout_get_baseline(self.to_glib_none().0) }
62    }
63
64    pub fn get_character_count(&self) -> i32 {
65        unsafe { pango_sys::pango_layout_get_character_count(self.to_glib_none().0) }
66    }
67
68    pub fn get_context(&self) -> Option<Context> {
69        unsafe { from_glib_none(pango_sys::pango_layout_get_context(self.to_glib_none().0)) }
70    }
71
72    pub fn get_cursor_pos(&self, index_: i32) -> (Rectangle, Rectangle) {
73        unsafe {
74            let mut strong_pos = Rectangle::uninitialized();
75            let mut weak_pos = Rectangle::uninitialized();
76            pango_sys::pango_layout_get_cursor_pos(
77                self.to_glib_none().0,
78                index_,
79                strong_pos.to_glib_none_mut().0,
80                weak_pos.to_glib_none_mut().0,
81            );
82            (strong_pos, weak_pos)
83        }
84    }
85
86    pub fn get_ellipsize(&self) -> EllipsizeMode {
87        unsafe { from_glib(pango_sys::pango_layout_get_ellipsize(self.to_glib_none().0)) }
88    }
89
90    pub fn get_extents(&self) -> (Rectangle, Rectangle) {
91        unsafe {
92            let mut ink_rect = Rectangle::uninitialized();
93            let mut logical_rect = Rectangle::uninitialized();
94            pango_sys::pango_layout_get_extents(
95                self.to_glib_none().0,
96                ink_rect.to_glib_none_mut().0,
97                logical_rect.to_glib_none_mut().0,
98            );
99            (ink_rect, logical_rect)
100        }
101    }
102
103    pub fn get_font_description(&self) -> Option<FontDescription> {
104        unsafe {
105            from_glib_none(pango_sys::pango_layout_get_font_description(
106                self.to_glib_none().0,
107            ))
108        }
109    }
110
111    pub fn get_height(&self) -> i32 {
112        unsafe { pango_sys::pango_layout_get_height(self.to_glib_none().0) }
113    }
114
115    pub fn get_indent(&self) -> i32 {
116        unsafe { pango_sys::pango_layout_get_indent(self.to_glib_none().0) }
117    }
118
119    pub fn get_iter(&self) -> Option<LayoutIter> {
120        unsafe { from_glib_full(pango_sys::pango_layout_get_iter(self.to_glib_none().0)) }
121    }
122
123    pub fn get_justify(&self) -> bool {
124        unsafe { from_glib(pango_sys::pango_layout_get_justify(self.to_glib_none().0)) }
125    }
126
127    pub fn get_line(&self, line: i32) -> Option<LayoutLine> {
128        unsafe {
129            from_glib_none(pango_sys::pango_layout_get_line(
130                self.to_glib_none().0,
131                line,
132            ))
133        }
134    }
135
136    pub fn get_line_count(&self) -> i32 {
137        unsafe { pango_sys::pango_layout_get_line_count(self.to_glib_none().0) }
138    }
139
140    pub fn get_line_readonly(&self, line: i32) -> Option<LayoutLine> {
141        unsafe {
142            from_glib_none(pango_sys::pango_layout_get_line_readonly(
143                self.to_glib_none().0,
144                line,
145            ))
146        }
147    }
148
149    pub fn get_lines(&self) -> Vec<LayoutLine> {
150        unsafe {
151            FromGlibPtrContainer::from_glib_none(pango_sys::pango_layout_get_lines(
152                self.to_glib_none().0,
153            ))
154        }
155    }
156
157    pub fn get_lines_readonly(&self) -> Vec<LayoutLine> {
158        unsafe {
159            FromGlibPtrContainer::from_glib_none(pango_sys::pango_layout_get_lines_readonly(
160                self.to_glib_none().0,
161            ))
162        }
163    }
164
165    //pub fn get_log_attrs(&self, attrs: /*Ignored*/Vec<LogAttr>) -> i32 {
166    //    unsafe { TODO: call pango_sys:pango_layout_get_log_attrs() }
167    //}
168
169    //pub fn get_log_attrs_readonly(&self) -> /*Ignored*/Vec<LogAttr> {
170    //    unsafe { TODO: call pango_sys:pango_layout_get_log_attrs_readonly() }
171    //}
172
173    pub fn get_pixel_extents(&self) -> (Rectangle, Rectangle) {
174        unsafe {
175            let mut ink_rect = Rectangle::uninitialized();
176            let mut logical_rect = Rectangle::uninitialized();
177            pango_sys::pango_layout_get_pixel_extents(
178                self.to_glib_none().0,
179                ink_rect.to_glib_none_mut().0,
180                logical_rect.to_glib_none_mut().0,
181            );
182            (ink_rect, logical_rect)
183        }
184    }
185
186    pub fn get_pixel_size(&self) -> (i32, i32) {
187        unsafe {
188            let mut width = mem::uninitialized();
189            let mut height = mem::uninitialized();
190            pango_sys::pango_layout_get_pixel_size(self.to_glib_none().0, &mut width, &mut height);
191            (width, height)
192        }
193    }
194
195    pub fn get_serial(&self) -> u32 {
196        unsafe { pango_sys::pango_layout_get_serial(self.to_glib_none().0) }
197    }
198
199    pub fn get_single_paragraph_mode(&self) -> bool {
200        unsafe {
201            from_glib(pango_sys::pango_layout_get_single_paragraph_mode(
202                self.to_glib_none().0,
203            ))
204        }
205    }
206
207    pub fn get_size(&self) -> (i32, i32) {
208        unsafe {
209            let mut width = mem::uninitialized();
210            let mut height = mem::uninitialized();
211            pango_sys::pango_layout_get_size(self.to_glib_none().0, &mut width, &mut height);
212            (width, height)
213        }
214    }
215
216    pub fn get_spacing(&self) -> i32 {
217        unsafe { pango_sys::pango_layout_get_spacing(self.to_glib_none().0) }
218    }
219
220    pub fn get_tabs(&self) -> Option<TabArray> {
221        unsafe { from_glib_full(pango_sys::pango_layout_get_tabs(self.to_glib_none().0)) }
222    }
223
224    pub fn get_text(&self) -> Option<GString> {
225        unsafe { from_glib_none(pango_sys::pango_layout_get_text(self.to_glib_none().0)) }
226    }
227
228    pub fn get_unknown_glyphs_count(&self) -> i32 {
229        unsafe { pango_sys::pango_layout_get_unknown_glyphs_count(self.to_glib_none().0) }
230    }
231
232    pub fn get_width(&self) -> i32 {
233        unsafe { pango_sys::pango_layout_get_width(self.to_glib_none().0) }
234    }
235
236    pub fn get_wrap(&self) -> WrapMode {
237        unsafe { from_glib(pango_sys::pango_layout_get_wrap(self.to_glib_none().0)) }
238    }
239
240    pub fn index_to_line_x(&self, index_: i32, trailing: bool) -> (i32, i32) {
241        unsafe {
242            let mut line = mem::uninitialized();
243            let mut x_pos = mem::uninitialized();
244            pango_sys::pango_layout_index_to_line_x(
245                self.to_glib_none().0,
246                index_,
247                trailing.to_glib(),
248                &mut line,
249                &mut x_pos,
250            );
251            (line, x_pos)
252        }
253    }
254
255    pub fn index_to_pos(&self, index_: i32) -> Rectangle {
256        unsafe {
257            let mut pos = Rectangle::uninitialized();
258            pango_sys::pango_layout_index_to_pos(
259                self.to_glib_none().0,
260                index_,
261                pos.to_glib_none_mut().0,
262            );
263            pos
264        }
265    }
266
267    pub fn is_ellipsized(&self) -> bool {
268        unsafe { from_glib(pango_sys::pango_layout_is_ellipsized(self.to_glib_none().0)) }
269    }
270
271    pub fn is_wrapped(&self) -> bool {
272        unsafe { from_glib(pango_sys::pango_layout_is_wrapped(self.to_glib_none().0)) }
273    }
274
275    pub fn move_cursor_visually(
276        &self,
277        strong: bool,
278        old_index: i32,
279        old_trailing: i32,
280        direction: i32,
281    ) -> (i32, i32) {
282        unsafe {
283            let mut new_index = mem::uninitialized();
284            let mut new_trailing = mem::uninitialized();
285            pango_sys::pango_layout_move_cursor_visually(
286                self.to_glib_none().0,
287                strong.to_glib(),
288                old_index,
289                old_trailing,
290                direction,
291                &mut new_index,
292                &mut new_trailing,
293            );
294            (new_index, new_trailing)
295        }
296    }
297
298    pub fn set_alignment(&self, alignment: Alignment) {
299        unsafe {
300            pango_sys::pango_layout_set_alignment(self.to_glib_none().0, alignment.to_glib());
301        }
302    }
303
304    pub fn set_attributes(&self, attrs: Option<&AttrList>) {
305        unsafe {
306            pango_sys::pango_layout_set_attributes(self.to_glib_none().0, attrs.to_glib_none().0);
307        }
308    }
309
310    pub fn set_auto_dir(&self, auto_dir: bool) {
311        unsafe {
312            pango_sys::pango_layout_set_auto_dir(self.to_glib_none().0, auto_dir.to_glib());
313        }
314    }
315
316    pub fn set_ellipsize(&self, ellipsize: EllipsizeMode) {
317        unsafe {
318            pango_sys::pango_layout_set_ellipsize(self.to_glib_none().0, ellipsize.to_glib());
319        }
320    }
321
322    pub fn set_font_description(&self, desc: Option<&FontDescription>) {
323        unsafe {
324            pango_sys::pango_layout_set_font_description(
325                self.to_glib_none().0,
326                desc.to_glib_none().0,
327            );
328        }
329    }
330
331    pub fn set_height(&self, height: i32) {
332        unsafe {
333            pango_sys::pango_layout_set_height(self.to_glib_none().0, height);
334        }
335    }
336
337    pub fn set_indent(&self, indent: i32) {
338        unsafe {
339            pango_sys::pango_layout_set_indent(self.to_glib_none().0, indent);
340        }
341    }
342
343    pub fn set_justify(&self, justify: bool) {
344        unsafe {
345            pango_sys::pango_layout_set_justify(self.to_glib_none().0, justify.to_glib());
346        }
347    }
348
349    pub fn set_markup(&self, markup: &str) {
350        let length = markup.len() as i32;
351        unsafe {
352            pango_sys::pango_layout_set_markup(
353                self.to_glib_none().0,
354                markup.to_glib_none().0,
355                length,
356            );
357        }
358    }
359
360    pub fn set_markup_with_accel(&self, markup: &str, accel_marker: char) -> char {
361        let length = markup.len() as i32;
362        unsafe {
363            let mut accel_char = mem::uninitialized();
364            pango_sys::pango_layout_set_markup_with_accel(
365                self.to_glib_none().0,
366                markup.to_glib_none().0,
367                length,
368                accel_marker.to_glib(),
369                &mut accel_char,
370            );
371            from_glib(accel_char)
372        }
373    }
374
375    pub fn set_single_paragraph_mode(&self, setting: bool) {
376        unsafe {
377            pango_sys::pango_layout_set_single_paragraph_mode(
378                self.to_glib_none().0,
379                setting.to_glib(),
380            );
381        }
382    }
383
384    pub fn set_spacing(&self, spacing: i32) {
385        unsafe {
386            pango_sys::pango_layout_set_spacing(self.to_glib_none().0, spacing);
387        }
388    }
389
390    pub fn set_tabs(&self, tabs: Option<&TabArray>) {
391        unsafe {
392            pango_sys::pango_layout_set_tabs(
393                self.to_glib_none().0,
394                mut_override(tabs.to_glib_none().0),
395            );
396        }
397    }
398
399    pub fn set_text(&self, text: &str) {
400        let length = text.len() as i32;
401        unsafe {
402            pango_sys::pango_layout_set_text(self.to_glib_none().0, text.to_glib_none().0, length);
403        }
404    }
405
406    pub fn set_width(&self, width: i32) {
407        unsafe {
408            pango_sys::pango_layout_set_width(self.to_glib_none().0, width);
409        }
410    }
411
412    pub fn set_wrap(&self, wrap: WrapMode) {
413        unsafe {
414            pango_sys::pango_layout_set_wrap(self.to_glib_none().0, wrap.to_glib());
415        }
416    }
417
418    pub fn xy_to_index(&self, x: i32, y: i32) -> (bool, i32, i32) {
419        unsafe {
420            let mut index_ = mem::uninitialized();
421            let mut trailing = mem::uninitialized();
422            let ret = from_glib(pango_sys::pango_layout_xy_to_index(
423                self.to_glib_none().0,
424                x,
425                y,
426                &mut index_,
427                &mut trailing,
428            ));
429            (ret, index_, trailing)
430        }
431    }
432}
433
434impl fmt::Display for Layout {
435    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
436        write!(f, "Layout")
437    }
438}