1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module pango.PgLayoutIter;
26 
27 private import gobject.ObjectG;
28 private import gtkc.pango;
29 public  import gtkc.pangotypes;
30 private import pango.PgLayout;
31 private import pango.PgLayoutLine;
32 
33 
34 /**
35  * A #PangoLayoutIter structure can be used to
36  * iterate over the visual extents of a #PangoLayout.
37  * 
38  * The #PangoLayoutIter structure is opaque, and
39  * has no user-visible fields.
40  */
41 public class PgLayoutIter
42 {
43 	/** the main Gtk struct */
44 	protected PangoLayoutIter* pangoLayoutIter;
45 
46 	/** Get the main Gtk struct */
47 	public PangoLayoutIter* getPgLayoutIterStruct()
48 	{
49 		return pangoLayoutIter;
50 	}
51 
52 	/** the main Gtk struct as a void* */
53 	protected void* getStruct()
54 	{
55 		return cast(void*)pangoLayoutIter;
56 	}
57 
58 	/**
59 	 * Sets our main struct and passes it to the parent class.
60 	 */
61 	public this (PangoLayoutIter* pangoLayoutIter)
62 	{
63 		this.pangoLayoutIter = pangoLayoutIter;
64 	}
65 
66 	/**
67 	 */
68 
69 	public static GType getType()
70 	{
71 		return pango_layout_iter_get_type();
72 	}
73 
74 	/**
75 	 * Determines whether @iter is on the last line of the layout.
76 	 *
77 	 * Return: %TRUE if @iter is on the last line.
78 	 */
79 	public bool atLastLine()
80 	{
81 		return pango_layout_iter_at_last_line(pangoLayoutIter) != 0;
82 	}
83 
84 	/**
85 	 * Copies a #PangoLayoutIter.
86 	 *
87 	 * Return: the newly allocated #PangoLayoutIter, which should
88 	 *     be freed with pango_layout_iter_free(), or %NULL if
89 	 *     @iter was %NULL.
90 	 *
91 	 * Since: 1.20
92 	 */
93 	public PgLayoutIter copy()
94 	{
95 		auto p = pango_layout_iter_copy(pangoLayoutIter);
96 		
97 		if(p is null)
98 		{
99 			return null;
100 		}
101 		
102 		return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) p);
103 	}
104 
105 	/**
106 	 * Frees an iterator that's no longer in use.
107 	 */
108 	public void free()
109 	{
110 		pango_layout_iter_free(pangoLayoutIter);
111 	}
112 
113 	/**
114 	 * Gets the Y position of the current line's baseline, in layout
115 	 * coordinates (origin at top left of the entire layout).
116 	 *
117 	 * Return: baseline of current line.
118 	 */
119 	public int getBaseline()
120 	{
121 		return pango_layout_iter_get_baseline(pangoLayoutIter);
122 	}
123 
124 	/**
125 	 * Gets the extents of the current character, in layout coordinates
126 	 * (origin is the top left of the entire layout). Only logical extents
127 	 * can sensibly be obtained for characters; ink extents make sense only
128 	 * down to the level of clusters.
129 	 *
130 	 * Params:
131 	 *     logicalRect = rectangle to fill with
132 	 *         logical extents
133 	 */
134 	public void getCharExtents(out PangoRectangle logicalRect)
135 	{
136 		pango_layout_iter_get_char_extents(pangoLayoutIter, &logicalRect);
137 	}
138 
139 	/**
140 	 * Gets the extents of the current cluster, in layout coordinates
141 	 * (origin is the top left of the entire layout).
142 	 *
143 	 * Params:
144 	 *     inkRect = rectangle to fill with ink extents, or %NULL
145 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
146 	 */
147 	public void getClusterExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
148 	{
149 		pango_layout_iter_get_cluster_extents(pangoLayoutIter, &inkRect, &logicalRect);
150 	}
151 
152 	/**
153 	 * Gets the current byte index. Note that iterating forward by char
154 	 * moves in visual order, not logical order, so indexes may not be
155 	 * sequential. Also, the index may be equal to the length of the text
156 	 * in the layout, if on the %NULL run (see pango_layout_iter_get_run()).
157 	 *
158 	 * Return: current byte index.
159 	 */
160 	public int getIndex()
161 	{
162 		return pango_layout_iter_get_index(pangoLayoutIter);
163 	}
164 
165 	/**
166 	 * Gets the layout associated with a #PangoLayoutIter.
167 	 *
168 	 * Return: the layout associated with @iter.
169 	 *
170 	 * Since: 1.20
171 	 */
172 	public PgLayout getLayout()
173 	{
174 		auto p = pango_layout_iter_get_layout(pangoLayoutIter);
175 		
176 		if(p is null)
177 		{
178 			return null;
179 		}
180 		
181 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
182 	}
183 
184 	/**
185 	 * Obtains the extents of the #PangoLayout being iterated
186 	 * over. @ink_rect or @logical_rect can be %NULL if you
187 	 * aren't interested in them.
188 	 *
189 	 * Params:
190 	 *     inkRect = rectangle to fill with ink extents,
191 	 *         or %NULL
192 	 *     logicalRect = rectangle to fill with logical
193 	 *         extents, or %NULL
194 	 */
195 	public void getLayoutExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
196 	{
197 		pango_layout_iter_get_layout_extents(pangoLayoutIter, &inkRect, &logicalRect);
198 	}
199 
200 	/**
201 	 * Gets the current line.
202 	 *
203 	 * Use the faster pango_layout_iter_get_line_readonly() if you do not plan
204 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
205 	 *
206 	 * Return: the current line.
207 	 */
208 	public PgLayoutLine getLine()
209 	{
210 		auto p = pango_layout_iter_get_line(pangoLayoutIter);
211 		
212 		if(p is null)
213 		{
214 			return null;
215 		}
216 		
217 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
218 	}
219 
220 	/**
221 	 * Obtains the extents of the current line. @ink_rect or @logical_rect
222 	 * can be %NULL if you aren't interested in them. Extents are in layout
223 	 * coordinates (origin is the top-left corner of the entire
224 	 * #PangoLayout).  Thus the extents returned by this function will be
225 	 * the same width/height but not at the same x/y as the extents
226 	 * returned from pango_layout_line_get_extents().
227 	 *
228 	 * Params:
229 	 *     inkRect = rectangle to fill with ink extents, or %NULL
230 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
231 	 */
232 	public void getLineExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
233 	{
234 		pango_layout_iter_get_line_extents(pangoLayoutIter, &inkRect, &logicalRect);
235 	}
236 
237 	/**
238 	 * Gets the current line for read-only access.
239 	 *
240 	 * This is a faster alternative to pango_layout_iter_get_line(),
241 	 * but the user is not expected
242 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
243 	 *
244 	 * Return: the current line, that should not be
245 	 *     modified.
246 	 *
247 	 * Since: 1.16
248 	 */
249 	public PgLayoutLine getLineReadonly()
250 	{
251 		auto p = pango_layout_iter_get_line_readonly(pangoLayoutIter);
252 		
253 		if(p is null)
254 		{
255 			return null;
256 		}
257 		
258 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
259 	}
260 
261 	/**
262 	 * Divides the vertical space in the #PangoLayout being iterated over
263 	 * between the lines in the layout, and returns the space belonging to
264 	 * the current line.  A line's range includes the line's logical
265 	 * extents, plus half of the spacing above and below the line, if
266 	 * pango_layout_set_spacing() has been called to set layout spacing.
267 	 * The Y positions are in layout coordinates (origin at top left of the
268 	 * entire layout).
269 	 *
270 	 * Params:
271 	 *     y0 = start of line, or %NULL
272 	 *     y1 = end of line, or %NULL
273 	 */
274 	public void getLineYrange(out int y0, out int y1)
275 	{
276 		pango_layout_iter_get_line_yrange(pangoLayoutIter, &y0, &y1);
277 	}
278 
279 	/**
280 	 * Gets the current run. When iterating by run, at the end of each
281 	 * line, there's a position with a %NULL run, so this function can return
282 	 * %NULL. The %NULL run at the end of each line ensures that all lines have
283 	 * at least one run, even lines consisting of only a newline.
284 	 *
285 	 * Use the faster pango_layout_iter_get_run_readonly() if you do not plan
286 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
287 	 *
288 	 * Return: the current run.
289 	 */
290 	public PangoLayoutRun* getRun()
291 	{
292 		return pango_layout_iter_get_run(pangoLayoutIter);
293 	}
294 
295 	/**
296 	 * Gets the extents of the current run in layout coordinates
297 	 * (origin is the top left of the entire layout).
298 	 *
299 	 * Params:
300 	 *     inkRect = rectangle to fill with ink extents, or %NULL
301 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
302 	 */
303 	public void getRunExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
304 	{
305 		pango_layout_iter_get_run_extents(pangoLayoutIter, &inkRect, &logicalRect);
306 	}
307 
308 	/**
309 	 * Gets the current run. When iterating by run, at the end of each
310 	 * line, there's a position with a %NULL run, so this function can return
311 	 * %NULL. The %NULL run at the end of each line ensures that all lines have
312 	 * at least one run, even lines consisting of only a newline.
313 	 *
314 	 * This is a faster alternative to pango_layout_iter_get_run(),
315 	 * but the user is not expected
316 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
317 	 *
318 	 * Return: the current run, that should not be modified.
319 	 *
320 	 * Since: 1.16
321 	 */
322 	public PangoLayoutRun* getRunReadonly()
323 	{
324 		return pango_layout_iter_get_run_readonly(pangoLayoutIter);
325 	}
326 
327 	/**
328 	 * Moves @iter forward to the next character in visual order. If @iter was already at
329 	 * the end of the layout, returns %FALSE.
330 	 *
331 	 * Return: whether motion was possible.
332 	 */
333 	public bool nextChar()
334 	{
335 		return pango_layout_iter_next_char(pangoLayoutIter) != 0;
336 	}
337 
338 	/**
339 	 * Moves @iter forward to the next cluster in visual order. If @iter
340 	 * was already at the end of the layout, returns %FALSE.
341 	 *
342 	 * Return: whether motion was possible.
343 	 */
344 	public bool nextCluster()
345 	{
346 		return pango_layout_iter_next_cluster(pangoLayoutIter) != 0;
347 	}
348 
349 	/**
350 	 * Moves @iter forward to the start of the next line. If @iter is
351 	 * already on the last line, returns %FALSE.
352 	 *
353 	 * Return: whether motion was possible.
354 	 */
355 	public bool nextLine()
356 	{
357 		return pango_layout_iter_next_line(pangoLayoutIter) != 0;
358 	}
359 
360 	/**
361 	 * Moves @iter forward to the next run in visual order. If @iter was
362 	 * already at the end of the layout, returns %FALSE.
363 	 *
364 	 * Return: whether motion was possible.
365 	 */
366 	public bool nextRun()
367 	{
368 		return pango_layout_iter_next_run(pangoLayoutIter) != 0;
369 	}
370 }