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