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