pango/auto/
tab_array.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 pango_sys;
7use std::mem;
8use TabAlign;
9
10glib_wrapper! {
11    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
12    pub struct TabArray(Boxed<pango_sys::PangoTabArray>);
13
14    match fn {
15        copy => |ptr| pango_sys::pango_tab_array_copy(mut_override(ptr)),
16        free => |ptr| pango_sys::pango_tab_array_free(ptr),
17        get_type => || pango_sys::pango_tab_array_get_type(),
18    }
19}
20
21impl TabArray {
22    pub fn new(initial_size: i32, positions_in_pixels: bool) -> TabArray {
23        unsafe {
24            from_glib_full(pango_sys::pango_tab_array_new(
25                initial_size,
26                positions_in_pixels.to_glib(),
27            ))
28        }
29    }
30
31    //pub fn new_with_positions(size: i32, positions_in_pixels: bool, first_alignment: TabAlign, first_position: i32, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> TabArray {
32    //    unsafe { TODO: call pango_sys:pango_tab_array_new_with_positions() }
33    //}
34
35    pub fn get_positions_in_pixels(&mut self) -> bool {
36        unsafe {
37            from_glib(pango_sys::pango_tab_array_get_positions_in_pixels(
38                self.to_glib_none_mut().0,
39            ))
40        }
41    }
42
43    pub fn get_size(&mut self) -> i32 {
44        unsafe { pango_sys::pango_tab_array_get_size(self.to_glib_none_mut().0) }
45    }
46
47    pub fn get_tab(&mut self, tab_index: i32) -> (TabAlign, i32) {
48        unsafe {
49            let mut alignment = mem::uninitialized();
50            let mut location = mem::uninitialized();
51            pango_sys::pango_tab_array_get_tab(
52                self.to_glib_none_mut().0,
53                tab_index,
54                &mut alignment,
55                &mut location,
56            );
57            (from_glib(alignment), location)
58        }
59    }
60
61    //pub fn get_tabs(&mut self, locations: Vec<i32>) -> TabAlign {
62    //    unsafe { TODO: call pango_sys:pango_tab_array_get_tabs() }
63    //}
64
65    pub fn resize(&mut self, new_size: i32) {
66        unsafe {
67            pango_sys::pango_tab_array_resize(self.to_glib_none_mut().0, new_size);
68        }
69    }
70
71    pub fn set_tab(&mut self, tab_index: i32, alignment: TabAlign, location: i32) {
72        unsafe {
73            pango_sys::pango_tab_array_set_tab(
74                self.to_glib_none_mut().0,
75                tab_index,
76                alignment.to_glib(),
77                location,
78            );
79        }
80    }
81}