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