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.PgGlyphItemIter;
26 
27 private import glib.MemorySlice;
28 private import glib.Str;
29 private import glib.c.functions;
30 private import gobject.ObjectG;
31 private import gtkd.Loader;
32 private import pango.PgGlyphItem;
33 private import pango.c.functions;
34 public  import pango.c.types;
35 
36 
37 /**
38  * A `PangoGlyphItemIter` is an iterator over the clusters in a
39  * `PangoGlyphItem`.
40  * 
41  * The *forward direction* of the iterator is the logical direction of text.
42  * That is, with increasing @start_index and @start_char values. If @glyph_item
43  * is right-to-left (that is, if `glyph_item->item->analysis.level` is odd),
44  * then @start_glyph decreases as the iterator moves forward.  Moreover,
45  * in right-to-left cases, @start_glyph is greater than @end_glyph.
46  * 
47  * An iterator should be initialized using either
48  * pango_glyph_item_iter_init_start() or
49  * pango_glyph_item_iter_init_end(), for forward and backward iteration
50  * respectively, and walked over using any desired mixture of
51  * pango_glyph_item_iter_next_cluster() and
52  * pango_glyph_item_iter_prev_cluster().
53  * 
54  * A common idiom for doing a forward iteration over the clusters is:
55  * 
56  * ```
57  * PangoGlyphItemIter cluster_iter;
58  * gboolean have_cluster;
59  * 
60  * for (have_cluster = pango_glyph_item_iter_init_start (&cluster_iter,
61  * glyph_item, text);
62  * have_cluster;
63  * have_cluster = pango_glyph_item_iter_next_cluster (&cluster_iter))
64  * {
65  * ...
66  * }
67  * ```
68  * 
69  * Note that @text is the start of the text for layout, which is then
70  * indexed by `glyph_item->item->offset` to get to the text of @glyph_item.
71  * The @start_index and @end_index values can directly index into @text. The
72  * @start_glyph, @end_glyph, @start_char, and @end_char values however are
73  * zero-based for the @glyph_item.  For each cluster, the item pointed at by
74  * the start variables is included in the cluster while the one pointed at by
75  * end variables is not.
76  * 
77  * None of the members of a `PangoGlyphItemIter` should be modified manually.
78  *
79  * Since: 1.22
80  */
81 public final class PgGlyphItemIter
82 {
83 	/** the main Gtk struct */
84 	protected PangoGlyphItemIter* pangoGlyphItemIter;
85 	protected bool ownedRef;
86 
87 	/** Get the main Gtk struct */
88 	public PangoGlyphItemIter* getPgGlyphItemIterStruct(bool transferOwnership = false)
89 	{
90 		if (transferOwnership)
91 			ownedRef = false;
92 		return pangoGlyphItemIter;
93 	}
94 
95 	/** the main Gtk struct as a void* */
96 	protected void* getStruct()
97 	{
98 		return cast(void*)pangoGlyphItemIter;
99 	}
100 
101 	/**
102 	 * Sets our main struct and passes it to the parent class.
103 	 */
104 	public this (PangoGlyphItemIter* pangoGlyphItemIter, bool ownedRef = false)
105 	{
106 		this.pangoGlyphItemIter = pangoGlyphItemIter;
107 		this.ownedRef = ownedRef;
108 	}
109 
110 	~this ()
111 	{
112 		if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
113 			pango_glyph_item_iter_free(pangoGlyphItemIter);
114 	}
115 
116 
117 	/** */
118 	public @property PgGlyphItem glyphItem()
119 	{
120 		return ObjectG.getDObject!(PgGlyphItem)(pangoGlyphItemIter.glyphItem, false);
121 	}
122 
123 	/** Ditto */
124 	public @property void glyphItem(PgGlyphItem value)
125 	{
126 		pangoGlyphItemIter.glyphItem = value.getPgGlyphItemStruct();
127 	}
128 
129 	/** */
130 	public @property string text()
131 	{
132 		return Str.toString(pangoGlyphItemIter.text);
133 	}
134 
135 	/** Ditto */
136 	public @property void text(string value)
137 	{
138 		pangoGlyphItemIter.text = Str.toStringz(value);
139 	}
140 
141 	/** */
142 	public @property int startGlyph()
143 	{
144 		return pangoGlyphItemIter.startGlyph;
145 	}
146 
147 	/** Ditto */
148 	public @property void startGlyph(int value)
149 	{
150 		pangoGlyphItemIter.startGlyph = value;
151 	}
152 
153 	/** */
154 	public @property int startIndex()
155 	{
156 		return pangoGlyphItemIter.startIndex;
157 	}
158 
159 	/** Ditto */
160 	public @property void startIndex(int value)
161 	{
162 		pangoGlyphItemIter.startIndex = value;
163 	}
164 
165 	/** */
166 	public @property int startChar()
167 	{
168 		return pangoGlyphItemIter.startChar;
169 	}
170 
171 	/** Ditto */
172 	public @property void startChar(int value)
173 	{
174 		pangoGlyphItemIter.startChar = value;
175 	}
176 
177 	/** */
178 	public @property int endGlyph()
179 	{
180 		return pangoGlyphItemIter.endGlyph;
181 	}
182 
183 	/** Ditto */
184 	public @property void endGlyph(int value)
185 	{
186 		pangoGlyphItemIter.endGlyph = value;
187 	}
188 
189 	/** */
190 	public @property int endIndex()
191 	{
192 		return pangoGlyphItemIter.endIndex;
193 	}
194 
195 	/** Ditto */
196 	public @property void endIndex(int value)
197 	{
198 		pangoGlyphItemIter.endIndex = value;
199 	}
200 
201 	/** */
202 	public @property int endChar()
203 	{
204 		return pangoGlyphItemIter.endChar;
205 	}
206 
207 	/** Ditto */
208 	public @property void endChar(int value)
209 	{
210 		pangoGlyphItemIter.endChar = value;
211 	}
212 
213 	/** */
214 	public static GType getType()
215 	{
216 		return pango_glyph_item_iter_get_type();
217 	}
218 
219 	/**
220 	 * Make a shallow copy of an existing `PangoGlyphItemIter` structure.
221 	 *
222 	 * Returns: the newly allocated `PangoGlyphItemIter`,
223 	 *     which should be freed with pango_glyph_item_iter_free(), or %NULL
224 	 *     if @orig was %NULL.
225 	 *
226 	 * Since: 1.22
227 	 */
228 	public PgGlyphItemIter copy()
229 	{
230 		auto __p = pango_glyph_item_iter_copy(pangoGlyphItemIter);
231 
232 		if(__p is null)
233 		{
234 			return null;
235 		}
236 
237 		return ObjectG.getDObject!(PgGlyphItemIter)(cast(PangoGlyphItemIter*) __p, true);
238 	}
239 
240 	/**
241 	 * Frees a `PangoGlyphItem`Iter.
242 	 *
243 	 * Since: 1.22
244 	 */
245 	public void free()
246 	{
247 		pango_glyph_item_iter_free(pangoGlyphItemIter);
248 		ownedRef = false;
249 	}
250 
251 	/**
252 	 * Initializes a `PangoGlyphItemIter` structure to point to the
253 	 * last cluster in a glyph item.
254 	 *
255 	 * See `PangoGlyphItemIter` for details of cluster orders.
256 	 *
257 	 * Params:
258 	 *     glyphItem = the glyph item to iterate over
259 	 *     text = text corresponding to the glyph item
260 	 *
261 	 * Returns: %FALSE if there are no clusters in the glyph item
262 	 *
263 	 * Since: 1.22
264 	 */
265 	public bool initEnd(PgGlyphItem glyphItem, string text)
266 	{
267 		return pango_glyph_item_iter_init_end(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0;
268 	}
269 
270 	/**
271 	 * Initializes a `PangoGlyphItemIter` structure to point to the
272 	 * first cluster in a glyph item.
273 	 *
274 	 * See `PangoGlyphItemIter` for details of cluster orders.
275 	 *
276 	 * Params:
277 	 *     glyphItem = the glyph item to iterate over
278 	 *     text = text corresponding to the glyph item
279 	 *
280 	 * Returns: %FALSE if there are no clusters in the glyph item
281 	 *
282 	 * Since: 1.22
283 	 */
284 	public bool initStart(PgGlyphItem glyphItem, string text)
285 	{
286 		return pango_glyph_item_iter_init_start(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0;
287 	}
288 
289 	/**
290 	 * Advances the iterator to the next cluster in the glyph item.
291 	 *
292 	 * See `PangoGlyphItemIter` for details of cluster orders.
293 	 *
294 	 * Returns: %TRUE if the iterator was advanced,
295 	 *     %FALSE if we were already on the  last cluster.
296 	 *
297 	 * Since: 1.22
298 	 */
299 	public bool nextCluster()
300 	{
301 		return pango_glyph_item_iter_next_cluster(pangoGlyphItemIter) != 0;
302 	}
303 
304 	/**
305 	 * Moves the iterator to the preceding cluster in the glyph item.
306 	 * See `PangoGlyphItemIter` for details of cluster orders.
307 	 *
308 	 * Returns: %TRUE if the iterator was moved,
309 	 *     %FALSE if we were already on the first cluster.
310 	 *
311 	 * Since: 1.22
312 	 */
313 	public bool prevCluster()
314 	{
315 		return pango_glyph_item_iter_prev_cluster(pangoGlyphItemIter) != 0;
316 	}
317 }