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  * Conversion parameters:
26  * inFile  = 
27  * outPack = pango
28  * outFile = PgLayoutIter
29  * strct   = PangoLayoutIter
30  * realStrct=
31  * ctorStrct=
32  * clss    = PgLayoutIter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- pango_layout_iter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- pango.PgLayout
47  * 	- pango.PgLayoutLine
48  * structWrap:
49  * 	- PangoLayout* -> PgLayout
50  * 	- PangoLayoutIter* -> PgLayoutIter
51  * 	- PangoLayoutLine* -> PgLayoutLine
52  * module aliases:
53  * local aliases:
54  * overrides:
55  */
56 
57 module pango.PgLayoutIter;
58 
59 public  import gtkc.pangotypes;
60 
61 private import gtkc.pango;
62 private import glib.ConstructionException;
63 private import gobject.ObjectG;
64 
65 private import pango.PgLayout;
66 private import pango.PgLayoutLine;
67 
68 
69 
70 /**
71  * While complete access to the layout capabilities of Pango is provided
72  * using the detailed interfaces for itemization and shaping, using
73  * that functionality directly involves writing a fairly large amount
74  * of code. The objects and functions in this section provide a
75  * high-level driver for formatting entire paragraphs of text
76  * at once.
77  */
78 public class PgLayoutIter
79 {
80 	
81 	/** the main Gtk struct */
82 	protected PangoLayoutIter* pangoLayoutIter;
83 	
84 	
85 	/** Get the main Gtk struct */
86 	public PangoLayoutIter* getPgLayoutIterStruct()
87 	{
88 		return pangoLayoutIter;
89 	}
90 	
91 	
92 	/** the main Gtk struct as a void* */
93 	protected void* getStruct()
94 	{
95 		return cast(void*)pangoLayoutIter;
96 	}
97 	
98 	/**
99 	 * Sets our main struct and passes it to the parent class
100 	 */
101 	public this (PangoLayoutIter* pangoLayoutIter)
102 	{
103 		this.pangoLayoutIter = pangoLayoutIter;
104 	}
105 	
106 	/**
107 	 */
108 	
109 	/**
110 	 * Copies a PangoLayoutIter.
111 	 * Since 1.20
112 	 * Returns: the newly allocated PangoLayoutIter, which should be freed with pango_layout_iter_free(), or NULL if iter was NULL.
113 	 */
114 	public PgLayoutIter copy()
115 	{
116 		// PangoLayoutIter * pango_layout_iter_copy (PangoLayoutIter *iter);
117 		auto p = pango_layout_iter_copy(pangoLayoutIter);
118 		
119 		if(p is null)
120 		{
121 			return null;
122 		}
123 		
124 		return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) p);
125 	}
126 	
127 	/**
128 	 * Frees an iterator that's no longer in use.
129 	 */
130 	public void free()
131 	{
132 		// void pango_layout_iter_free (PangoLayoutIter *iter);
133 		pango_layout_iter_free(pangoLayoutIter);
134 	}
135 	
136 	/**
137 	 * Moves iter forward to the next run in visual order. If iter was
138 	 * already at the end of the layout, returns FALSE.
139 	 * Returns: whether motion was possible.
140 	 */
141 	public int nextRun()
142 	{
143 		// gboolean pango_layout_iter_next_run (PangoLayoutIter *iter);
144 		return pango_layout_iter_next_run(pangoLayoutIter);
145 	}
146 	
147 	/**
148 	 * Moves iter forward to the next character in visual order. If iter was already at
149 	 * the end of the layout, returns FALSE.
150 	 * Returns: whether motion was possible.
151 	 */
152 	public int nextChar()
153 	{
154 		// gboolean pango_layout_iter_next_char (PangoLayoutIter *iter);
155 		return pango_layout_iter_next_char(pangoLayoutIter);
156 	}
157 	
158 	/**
159 	 * Moves iter forward to the next cluster in visual order. If iter
160 	 * was already at the end of the layout, returns FALSE.
161 	 * Returns: whether motion was possible.
162 	 */
163 	public int nextCluster()
164 	{
165 		// gboolean pango_layout_iter_next_cluster (PangoLayoutIter *iter);
166 		return pango_layout_iter_next_cluster(pangoLayoutIter);
167 	}
168 	
169 	/**
170 	 * Moves iter forward to the start of the next line. If iter is
171 	 * already on the last line, returns FALSE.
172 	 * Returns: whether motion was possible.
173 	 */
174 	public int nextLine()
175 	{
176 		// gboolean pango_layout_iter_next_line (PangoLayoutIter *iter);
177 		return pango_layout_iter_next_line(pangoLayoutIter);
178 	}
179 	
180 	/**
181 	 * Determines whether iter is on the last line of the layout.
182 	 * Returns: TRUE if iter is on the last line.
183 	 */
184 	public int atLastLine()
185 	{
186 		// gboolean pango_layout_iter_at_last_line (PangoLayoutIter *iter);
187 		return pango_layout_iter_at_last_line(pangoLayoutIter);
188 	}
189 	
190 	/**
191 	 * Gets the current byte index. Note that iterating forward by char
192 	 * moves in visual order, not logical order, so indexes may not be
193 	 * sequential. Also, the index may be equal to the length of the text
194 	 * in the layout, if on the NULL run (see pango_layout_iter_get_run()).
195 	 * Returns: current byte index.
196 	 */
197 	public int getIndex()
198 	{
199 		// int pango_layout_iter_get_index (PangoLayoutIter *iter);
200 		return pango_layout_iter_get_index(pangoLayoutIter);
201 	}
202 	
203 	/**
204 	 * Gets the Y position of the current line's baseline, in layout
205 	 * coordinates (origin at top left of the entire layout).
206 	 * Returns: baseline of current line.
207 	 */
208 	public int getBaseline()
209 	{
210 		// int pango_layout_iter_get_baseline (PangoLayoutIter *iter);
211 		return pango_layout_iter_get_baseline(pangoLayoutIter);
212 	}
213 	
214 	/**
215 	 * Gets the current run. When iterating by run, at the end of each
216 	 * line, there's a position with a NULL run, so this function can return
217 	 * NULL. The NULL run at the end of each line ensures that all lines have
218 	 * at least one run, even lines consisting of only a newline.
219 	 * Use the faster pango_layout_iter_get_run_readonly() if you do not plan
220 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
221 	 * Returns: the current run. [transfer none]
222 	 */
223 	public PangoLayoutRun* getRun()
224 	{
225 		// PangoLayoutRun * pango_layout_iter_get_run (PangoLayoutIter *iter);
226 		return pango_layout_iter_get_run(pangoLayoutIter);
227 	}
228 	
229 	/**
230 	 * Gets the current run. When iterating by run, at the end of each
231 	 * line, there's a position with a NULL run, so this function can return
232 	 * NULL. The NULL run at the end of each line ensures that all lines have
233 	 * at least one run, even lines consisting of only a newline.
234 	 * This is a faster alternative to pango_layout_iter_get_run(),
235 	 * but the user is not expected
236 	 * to modify the contents of the run (glyphs, glyph widths, etc.).
237 	 * Since 1.16
238 	 * Returns: the current run, that should not be modified. [transfer none]
239 	 */
240 	public PangoLayoutRun* getRunReadonly()
241 	{
242 		// PangoLayoutRun * pango_layout_iter_get_run_readonly (PangoLayoutIter *iter);
243 		return pango_layout_iter_get_run_readonly(pangoLayoutIter);
244 	}
245 	
246 	/**
247 	 * Gets the current line.
248 	 * Use the faster pango_layout_iter_get_line_readonly() if you do not plan
249 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
250 	 * Returns: the current line.
251 	 */
252 	public PgLayoutLine getLine()
253 	{
254 		// PangoLayoutLine * pango_layout_iter_get_line (PangoLayoutIter *iter);
255 		auto p = pango_layout_iter_get_line(pangoLayoutIter);
256 		
257 		if(p is null)
258 		{
259 			return null;
260 		}
261 		
262 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
263 	}
264 	
265 	/**
266 	 * Gets the current line for read-only access.
267 	 * This is a faster alternative to pango_layout_iter_get_line(),
268 	 * but the user is not expected
269 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
270 	 * Since 1.16
271 	 * Returns: the current line, that should not be modified. [transfer none]
272 	 */
273 	public PgLayoutLine getLineReadonly()
274 	{
275 		// PangoLayoutLine * pango_layout_iter_get_line_readonly (PangoLayoutIter *iter);
276 		auto p = pango_layout_iter_get_line_readonly(pangoLayoutIter);
277 		
278 		if(p is null)
279 		{
280 			return null;
281 		}
282 		
283 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
284 	}
285 	
286 	/**
287 	 * Gets the layout associated with a PangoLayoutIter.
288 	 * Since 1.20
289 	 * Returns: the layout associated with iter. [transfer none]
290 	 */
291 	public PgLayout getLayout()
292 	{
293 		// PangoLayout * pango_layout_iter_get_layout (PangoLayoutIter *iter);
294 		auto p = pango_layout_iter_get_layout(pangoLayoutIter);
295 		
296 		if(p is null)
297 		{
298 			return null;
299 		}
300 		
301 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p);
302 	}
303 	
304 	/**
305 	 * Gets the extents of the current character, in layout coordinates
306 	 * (origin is the top left of the entire layout). Only logical extents
307 	 * can sensibly be obtained for characters; ink extents make sense only
308 	 * down to the level of clusters.
309 	 * Params:
310 	 * logicalRect = rectangle to fill with
311 	 * logical extents. [out caller-allocates]
312 	 */
313 	public void getCharExtents(PangoRectangle* logicalRect)
314 	{
315 		// void pango_layout_iter_get_char_extents (PangoLayoutIter *iter,  PangoRectangle *logical_rect);
316 		pango_layout_iter_get_char_extents(pangoLayoutIter, logicalRect);
317 	}
318 	
319 	/**
320 	 * Gets the extents of the current cluster, in layout coordinates
321 	 * (origin is the top left of the entire layout).
322 	 * Params:
323 	 * inkRect = rectangle to fill with ink extents, or NULL. [out][allow-none]
324 	 * logicalRect = rectangle to fill with logical extents, or NULL. [out][allow-none]
325 	 */
326 	public void getClusterExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
327 	{
328 		// void pango_layout_iter_get_cluster_extents  (PangoLayoutIter *iter,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
329 		pango_layout_iter_get_cluster_extents(pangoLayoutIter, inkRect, logicalRect);
330 	}
331 	
332 	/**
333 	 * Gets the extents of the current run in layout coordinates
334 	 * (origin is the top left of the entire layout).
335 	 * Params:
336 	 * inkRect = rectangle to fill with ink extents, or NULL. [out][allow-none]
337 	 * logicalRect = rectangle to fill with logical extents, or NULL. [out][allow-none]
338 	 */
339 	public void getRunExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
340 	{
341 		// void pango_layout_iter_get_run_extents (PangoLayoutIter *iter,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
342 		pango_layout_iter_get_run_extents(pangoLayoutIter, inkRect, logicalRect);
343 	}
344 	
345 	/**
346 	 * Divides the vertical space in the PangoLayout being iterated over
347 	 * between the lines in the layout, and returns the space belonging to
348 	 * the current line. A line's range includes the line's logical
349 	 * extents, plus half of the spacing above and below the line, if
350 	 * pango_layout_set_spacing() has been called to set layout spacing.
351 	 * The Y positions are in layout coordinates (origin at top left of the
352 	 * entire layout).
353 	 * Params:
354 	 * y0_ = start of line, or NULL. [out][allow-none]
355 	 * y1_ = end of line, or NULL. [out][allow-none]
356 	 */
357 	public void getLineYrange(out int y0_, out int y1_)
358 	{
359 		// void pango_layout_iter_get_line_yrange (PangoLayoutIter *iter,  int *y0_,  int *y1_);
360 		pango_layout_iter_get_line_yrange(pangoLayoutIter, &y0_, &y1_);
361 	}
362 	
363 	/**
364 	 * Obtains the extents of the current line. ink_rect or logical_rect
365 	 * can be NULL if you aren't interested in them. Extents are in layout
366 	 * coordinates (origin is the top-left corner of the entire
367 	 * PangoLayout). Thus the extents returned by this function will be
368 	 * the same width/height but not at the same x/y as the extents
369 	 * returned from pango_layout_line_get_extents().
370 	 * Params:
371 	 * inkRect = rectangle to fill with ink extents, or NULL. [out][allow-none]
372 	 * logicalRect = rectangle to fill with logical extents, or NULL. [out][allow-none]
373 	 */
374 	public void getLineExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
375 	{
376 		// void pango_layout_iter_get_line_extents (PangoLayoutIter *iter,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
377 		pango_layout_iter_get_line_extents(pangoLayoutIter, inkRect, logicalRect);
378 	}
379 	
380 	/**
381 	 * Obtains the extents of the PangoLayout being iterated
382 	 * over. ink_rect or logical_rect can be NULL if you
383 	 * aren't interested in them.
384 	 * Params:
385 	 * inkRect = rectangle to fill with ink extents,
386 	 * or NULL. [out][allow-none]
387 	 * logicalRect = rectangle to fill with logical
388 	 * extents, or NULL. [out][allow-none]
389 	 */
390 	public void getLayoutExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
391 	{
392 		// void pango_layout_iter_get_layout_extents  (PangoLayoutIter *iter,  PangoRectangle *ink_rect,  PangoRectangle *logical_rect);
393 		pango_layout_iter_get_layout_extents(pangoLayoutIter, inkRect, logicalRect);
394 	}
395 }