1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use Rectangle;
use ffi;
use glib::translate::*;
use std::mem;
glib_wrapper! {
pub struct LayoutLine(Shared<ffi::PangoLayoutLine>);
match fn {
ref => |ptr| ffi::pango_layout_line_ref(ptr),
unref => |ptr| ffi::pango_layout_line_unref(ptr),
}
}
impl LayoutLine {
pub fn get_extents(&self) -> (Rectangle, Rectangle) {
unsafe {
let mut ink_rect = Rectangle::uninitialized();
let mut logical_rect = Rectangle::uninitialized();
ffi::pango_layout_line_get_extents(self.to_glib_none().0, ink_rect.to_glib_none_mut().0, logical_rect.to_glib_none_mut().0);
(ink_rect, logical_rect)
}
}
pub fn get_pixel_extents(&self) -> (Rectangle, Rectangle) {
unsafe {
let mut ink_rect = Rectangle::uninitialized();
let mut logical_rect = Rectangle::uninitialized();
ffi::pango_layout_line_get_pixel_extents(self.to_glib_none().0, ink_rect.to_glib_none_mut().0, logical_rect.to_glib_none_mut().0);
(ink_rect, logical_rect)
}
}
pub fn index_to_x(&self, index_: i32, trailing: bool) -> i32 {
unsafe {
let mut x_pos = mem::uninitialized();
ffi::pango_layout_line_index_to_x(self.to_glib_none().0, index_, trailing.to_glib(), &mut x_pos);
x_pos
}
}
pub fn x_to_index(&self, x_pos: i32) -> Option<(i32, i32)> {
unsafe {
let mut index_ = mem::uninitialized();
let mut trailing = mem::uninitialized();
let ret = from_glib(ffi::pango_layout_line_x_to_index(self.to_glib_none().0, x_pos, &mut index_, &mut trailing));
if ret { Some((index_, trailing)) } else { None }
}
}
}