pango/auto/
layout_iter.rs1use glib::translate::*;
6use pango_sys;
7use std::mem;
8use Layout;
9use LayoutLine;
10use LayoutRun;
11use Rectangle;
12
13glib_wrapper! {
14 #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
15 pub struct LayoutIter(Boxed<pango_sys::PangoLayoutIter>);
16
17 match fn {
18 copy => |ptr| pango_sys::pango_layout_iter_copy(mut_override(ptr)),
19 free => |ptr| pango_sys::pango_layout_iter_free(ptr),
20 get_type => || pango_sys::pango_layout_iter_get_type(),
21 }
22}
23
24impl LayoutIter {
25 pub fn at_last_line(&mut self) -> bool {
26 unsafe {
27 from_glib(pango_sys::pango_layout_iter_at_last_line(
28 self.to_glib_none_mut().0,
29 ))
30 }
31 }
32
33 pub fn get_baseline(&mut self) -> i32 {
34 unsafe { pango_sys::pango_layout_iter_get_baseline(self.to_glib_none_mut().0) }
35 }
36
37 pub fn get_char_extents(&mut self) -> Rectangle {
38 unsafe {
39 let mut logical_rect = Rectangle::uninitialized();
40 pango_sys::pango_layout_iter_get_char_extents(
41 self.to_glib_none_mut().0,
42 logical_rect.to_glib_none_mut().0,
43 );
44 logical_rect
45 }
46 }
47
48 pub fn get_cluster_extents(&mut self) -> (Rectangle, Rectangle) {
49 unsafe {
50 let mut ink_rect = Rectangle::uninitialized();
51 let mut logical_rect = Rectangle::uninitialized();
52 pango_sys::pango_layout_iter_get_cluster_extents(
53 self.to_glib_none_mut().0,
54 ink_rect.to_glib_none_mut().0,
55 logical_rect.to_glib_none_mut().0,
56 );
57 (ink_rect, logical_rect)
58 }
59 }
60
61 pub fn get_index(&mut self) -> i32 {
62 unsafe { pango_sys::pango_layout_iter_get_index(self.to_glib_none_mut().0) }
63 }
64
65 pub fn get_layout(&mut self) -> Option<Layout> {
66 unsafe {
67 from_glib_none(pango_sys::pango_layout_iter_get_layout(
68 self.to_glib_none_mut().0,
69 ))
70 }
71 }
72
73 pub fn get_layout_extents(&mut self) -> (Rectangle, Rectangle) {
74 unsafe {
75 let mut ink_rect = Rectangle::uninitialized();
76 let mut logical_rect = Rectangle::uninitialized();
77 pango_sys::pango_layout_iter_get_layout_extents(
78 self.to_glib_none_mut().0,
79 ink_rect.to_glib_none_mut().0,
80 logical_rect.to_glib_none_mut().0,
81 );
82 (ink_rect, logical_rect)
83 }
84 }
85
86 pub fn get_line(&mut self) -> Option<LayoutLine> {
87 unsafe {
88 from_glib_full(pango_sys::pango_layout_iter_get_line(
89 self.to_glib_none_mut().0,
90 ))
91 }
92 }
93
94 pub fn get_line_extents(&mut self) -> (Rectangle, Rectangle) {
95 unsafe {
96 let mut ink_rect = Rectangle::uninitialized();
97 let mut logical_rect = Rectangle::uninitialized();
98 pango_sys::pango_layout_iter_get_line_extents(
99 self.to_glib_none_mut().0,
100 ink_rect.to_glib_none_mut().0,
101 logical_rect.to_glib_none_mut().0,
102 );
103 (ink_rect, logical_rect)
104 }
105 }
106
107 pub fn get_line_readonly(&mut self) -> Option<LayoutLine> {
108 unsafe {
109 from_glib_none(pango_sys::pango_layout_iter_get_line_readonly(
110 self.to_glib_none_mut().0,
111 ))
112 }
113 }
114
115 pub fn get_line_yrange(&mut self) -> (i32, i32) {
116 unsafe {
117 let mut y0_ = mem::uninitialized();
118 let mut y1_ = mem::uninitialized();
119 pango_sys::pango_layout_iter_get_line_yrange(
120 self.to_glib_none_mut().0,
121 &mut y0_,
122 &mut y1_,
123 );
124 (y0_, y1_)
125 }
126 }
127
128 pub fn get_run(&mut self) -> Option<LayoutRun> {
129 unsafe {
130 from_glib_none(pango_sys::pango_layout_iter_get_run(
131 self.to_glib_none_mut().0,
132 ))
133 }
134 }
135
136 pub fn get_run_extents(&mut self) -> (Rectangle, Rectangle) {
137 unsafe {
138 let mut ink_rect = Rectangle::uninitialized();
139 let mut logical_rect = Rectangle::uninitialized();
140 pango_sys::pango_layout_iter_get_run_extents(
141 self.to_glib_none_mut().0,
142 ink_rect.to_glib_none_mut().0,
143 logical_rect.to_glib_none_mut().0,
144 );
145 (ink_rect, logical_rect)
146 }
147 }
148
149 pub fn get_run_readonly(&mut self) -> Option<LayoutRun> {
150 unsafe {
151 from_glib_none(pango_sys::pango_layout_iter_get_run_readonly(
152 self.to_glib_none_mut().0,
153 ))
154 }
155 }
156
157 pub fn next_char(&mut self) -> bool {
158 unsafe {
159 from_glib(pango_sys::pango_layout_iter_next_char(
160 self.to_glib_none_mut().0,
161 ))
162 }
163 }
164
165 pub fn next_cluster(&mut self) -> bool {
166 unsafe {
167 from_glib(pango_sys::pango_layout_iter_next_cluster(
168 self.to_glib_none_mut().0,
169 ))
170 }
171 }
172
173 pub fn next_line(&mut self) -> bool {
174 unsafe {
175 from_glib(pango_sys::pango_layout_iter_next_line(
176 self.to_glib_none_mut().0,
177 ))
178 }
179 }
180
181 pub fn next_run(&mut self) -> bool {
182 unsafe {
183 from_glib(pango_sys::pango_layout_iter_next_run(
184 self.to_glib_none_mut().0,
185 ))
186 }
187 }
188}