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 	public static GType getType()
69 	{
70 		return pango_layout_iter_get_type();
71 	}
72 
73 	/**
74 	 * Determines whether @iter is on the last line of the layout.
75 	 *
76 	 * Return: %TRUE if @iter is on the last line.
77 	 */
78 	public bool atLastLine()
79 	{
80 		return pango_layout_iter_at_last_line(pangoLayoutIter) != 0;
81 	}
82 
83 	/**
84 	 * Copies a #PangoLayoutIter.
85 	 *
86 	 * Return: the newly allocated #PangoLayoutIter,
87 	 *     which should be freed with pango_layout_iter_free(),
88 	 *     or %NULL if @iter was %NULL.
89 	 *
90 	 * Since: 1.20
91 	 */
92 	public PgLayoutIter copy()
93 	{
94 		auto p = pango_layout_iter_copy(pangoLayoutIter);
95 		
96 		if(p is null)
97 		{
98 			return null;
99 		}
100 		
101 		return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) p);
102 	}
103 
104 	/**
105 	 * Frees an iterator that's no longer in use.
106 	 */
107 	public void free()
108 	{
109 		pango_layout_iter_free(pangoLayoutIter);
110 	}
111 
112 	/**
113 	 * Gets the Y position of the current line's baseline, in layout
114 	 * coordinates (origin at top left of the entire layout).
115 	 *
116 	 * Return: baseline of current line.
117 	 */
118 	public int getBaseline()
119 	{
120 		return pango_layout_iter_get_baseline(pangoLayoutIter);
121 	}
122 
123 	/**
124 	 * Gets the extents of the current character, in layout coordinates
125 	 * (origin is the top left of the entire layout). Only logical extents
126 	 * can sensibly be obtained for characters; ink extents make sense only
127 	 * down to the level of clusters.
128 	 *
129 	 * Params:
130 	 *     logicalRect = rectangle to fill with
131 	 *         logical extents
132 	 */
133 	public void getCharExtents(out PangoRectangle logicalRect)
134 	{
135 		pango_layout_iter_get_char_extents(pangoLayoutIter, &logicalRect);
136 	}
137 
138 	/**
139 	 * Gets the extents of the current cluster, in layout coordinates
140 	 * (origin is the top left of the entire layout).
141 	 *
142 	 * Params:
143 	 *     inkRect = rectangle to fill with ink extents, or %NULL
144 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
145 	 */
146 	public void getClusterExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
147 	{
148 		pango_layout_iter_get_cluster_extents(pangoLayoutIter, &inkRect, &logicalRect);
149 	}
150 
151 	/**
152 	 * Gets the current byte index. Note that iterating forward by char
153 	 * moves in visual order, not logical order, so indexes may not be
154 	 * sequential. Also, the index may be equal to the length of the text
155 	 * in the layout, if on the %NULL run (see pango_layout_iter_get_run()).
156 	 *
157 	 * Return: current byte index.
158 	 */
159 	public int getIndex()
160 	{
161 		return pango_layout_iter_get_index(pangoLayoutIter);
162 	}
163 
164 	/**
165 	 * Gets the layout associated with a #PangoLayoutIter.
166 	 *
167 	 * Return: the layout associated with @iter.
168 	 *
169 	 * Since: 1.20
170 	 */
171 	public PgLayout getLayout()
172 	{
173 		auto p = pango_layout_iter_get_layout(pangoLayoutIter);
174 		
175 		if(p is null)
176 		{
177 			return null;
178 		}
179 		
180 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
181 	}
182 
183 	/**
184 	 * Obtains the extents of the #PangoLayout being iterated
185 	 * over. @ink_rect or @logical_rect can be %NULL if you
186 	 * aren't interested in them.
187 	 *
188 	 * Params:
189 	 *     inkRect = rectangle to fill with ink extents,
190 	 *         or %NULL
191 	 *     logicalRect = rectangle to fill with logical
192 	 *         extents, or %NULL
193 	 */
194 	public void getLayoutExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
195 	{
196 		pango_layout_iter_get_layout_extents(pangoLayoutIter, &inkRect, &logicalRect);
197 	}
198 
199 	/**
200 	 * Gets the current line.
201 	 *
202 	 * Use the faster pango_layout_iter_get_line_readonly() if you do not plan
203 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
204 	 *
205 	 * Return: the current line.
206 	 */
207 	public PgLayoutLine getLine()
208 	{
209 		auto p = pango_layout_iter_get_line(pangoLayoutIter);
210 		
211 		if(p is null)
212 		{
213 			return null;
214 		}
215 		
216 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
217 	}
218 
219 	/**
220 	 * Obtains the extents of the current line. @ink_rect or @logical_rect
221 	 * can be %NULL if you aren't interested in them. Extents are in layout
222 	 * coordinates (origin is the top-left corner of the entire
223 	 * #PangoLayout).  Thus the extents returned by this function will be
224 	 * the same width/height but not at the same x/y as the extents
225 	 * returned from pango_layout_line_get_extents().
226 	 *
227 	 * Params:
228 	 *     inkRect = rectangle to fill with ink extents, or %NULL
229 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
230 	 */
231 	public void getLineExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
232 	{
233 		pango_layout_iter_get_line_extents(pangoLayoutIter, &inkRect, &logicalRect);
234 	}
235 
236 	/**
237 	 * Gets the current line for read-only access.
238 	 *
239 	 * This is a faster alternative to pango_layout_iter_get_line(),
240 	 * but the user is not expected
241 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
242 	 *
243 	 * Return: the current line, that should not be
244 	 *     modified.
245 	 *
246 	 * Since: 1.16
247 	 */
248 	public PgLayoutLine getLineReadonly()
249 	{
250 		auto p = pango_layout_iter_get_line_readonly(pangoLayoutIter);
251 		
252 		if(p is null)
253 		{
254 			return null;
255 		}
256 		
257 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
258 	}
259 
260 	/**
261 	 * Divides the vertical space in the #PangoLayout being iterated over
262 	 * between the lines in the layout, and returns the space belonging to
263 	 * the current line.  A line's range includes the line's logical
264 	 * extents, plus half of the spacing above and below the line, if
265 	 * pango_layout_set_spacing() has been called to set layout spacing.
266 	 * The Y positions are in layout coordinates (origin at top left of the
267 	 * entire layout).
268 	 *
269 	 * Params:
270 	 *     y0 = start of line, or %NULL
271 	 *     y1 = end of line, or %NULL
272 	 */
273 	public void getLineYrange(out int y0, out int y1)
274 	{
275 		pango_layout_iter_get_line_yrange(pangoLayoutIter, &y0, &y1);
276 	}
277 
278 	/**
279 	 * Gets the current run. When iterating by run, at the end of each
280 	 * line, there's a position with a %NULL run, so this function can return
281 	 * %NULL. The %NULL run at the end of each line ensures that all lines have
282 	 * at least one run, even lines consisting of only a newline.
283 	 *
284 	 * Use the faster pango_layout_iter_get_run_readonly() if you do not plan
285 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
286 	 *
287 	 * Return: the current run.
288 	 */
289 	public PangoLayoutRun* getRun()
290 	{
291 		return pango_layout_iter_get_run(pangoLayoutIter);
292 	}
293 
294 	/**
295 	 * Gets the extents of the current run in layout coordinates
296 	 * (origin is the top left of the entire layout).
297 	 *
298 	 * Params:
299 	 *     inkRect = rectangle to fill with ink extents, or %NULL
300 	 *     logicalRect = rectangle to fill with logical extents, or %NULL
301 	 */
302 	public void getRunExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
303 	{
304 		pango_layout_iter_get_run_extents(pangoLayoutIter, &inkRect, &logicalRect);
305 	}
306 
307 	/**
308 	 * Gets the current run. When iterating by run, at the end of each
309 	 * line, there's a position with a %NULL run, so this function can return
310 	 * %NULL. The %NULL run at the end of each line ensures that all lines have
311 	 * at least one run, even lines consisting of only a newline.
312 	 *
313 	 * This is a faster alternative to pango_layout_iter_get_run(),
314 	 * but the user is not expected
315 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
316 	 *
317 	 * Return: the current run, that
318 	 *     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 }