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.Str;
28 private import gobject.ObjectG;
29 private import gtkc.pango;
30 public  import gtkc.pangotypes;
31 private import gtkd.Loader;
32 private import pango.PgGlyphItem;
33 
34 
35 /**
36  * A #PangoGlyphItemIter is an iterator over the clusters in a
37  * #PangoGlyphItem.  The <firstterm>forward direction</firstterm> of the
38  * iterator is the logical direction of text.  That is, with increasing
39  * @start_index and @start_char values.  If @glyph_item is right-to-left
40  * (that is, if <literal>@glyph_item->item->analysis.level</literal> is odd),
41  * then @start_glyph decreases as the iterator moves forward.  Moreover,
42  * in right-to-left cases, @start_glyph is greater than @end_glyph.
43  * 
44  * An iterator should be initialized using either of
45  * pango_glyph_item_iter_init_start() and
46  * pango_glyph_item_iter_init_end(), for forward and backward iteration
47  * respectively, and walked over using any desired mixture of
48  * pango_glyph_item_iter_next_cluster() and
49  * pango_glyph_item_iter_prev_cluster().  A common idiom for doing a
50  * forward iteration over the clusters is:
51  * <programlisting>
52  * PangoGlyphItemIter cluster_iter;
53  * gboolean have_cluster;
54  * 
55  * for (have_cluster = pango_glyph_item_iter_init_start (&amp;cluster_iter,
56  * glyph_item, text);
57  * have_cluster;
58  * have_cluster = pango_glyph_item_iter_next_cluster (&amp;cluster_iter))
59  * {
60  * ...
61  * }
62  * </programlisting>
63  * 
64  * Note that @text is the start of the text for layout, which is then
65  * indexed by <literal>@glyph_item->item->offset</literal> to get to the
66  * text of @glyph_item.  The @start_index and @end_index values can directly
67  * index into @text.  The @start_glyph, @end_glyph, @start_char, and @end_char
68  * values however are zero-based for the @glyph_item.  For each cluster, the
69  * item pointed at by the start variables is included in the cluster while
70  * the one pointed at by end variables is not.
71  * 
72  * None of the members of a #PangoGlyphItemIter should be modified manually.
73  *
74  * Since: 1.22
75  */
76 public class PgGlyphItemIter
77 {
78 	/** the main Gtk struct */
79 	protected PangoGlyphItemIter* pangoGlyphItemIter;
80 	protected bool ownedRef;
81 
82 	/** Get the main Gtk struct */
83 	public PangoGlyphItemIter* getPgGlyphItemIterStruct(bool transferOwnership = false)
84 	{
85 		if (transferOwnership)
86 			ownedRef = false;
87 		return pangoGlyphItemIter;
88 	}
89 
90 	/** the main Gtk struct as a void* */
91 	protected void* getStruct()
92 	{
93 		return cast(void*)pangoGlyphItemIter;
94 	}
95 
96 	/**
97 	 * Sets our main struct and passes it to the parent class.
98 	 */
99 	public this (PangoGlyphItemIter* pangoGlyphItemIter, bool ownedRef = false)
100 	{
101 		this.pangoGlyphItemIter = pangoGlyphItemIter;
102 		this.ownedRef = ownedRef;
103 	}
104 
105 	~this ()
106 	{
107 		if (  Linker.isLoaded(LIBRARY_PANGO) && ownedRef )
108 			pango_glyph_item_iter_free(pangoGlyphItemIter);
109 	}
110 
111 
112 	/** */
113 	public static GType getType()
114 	{
115 		return pango_glyph_item_iter_get_type();
116 	}
117 
118 	/**
119 	 * Make a shallow copy of an existing #PangoGlyphItemIter structure.
120 	 *
121 	 * Returns: the newly allocated #PangoGlyphItemIter, which should
122 	 *     be freed with pango_glyph_item_iter_free(), or %NULL
123 	 *     if @orig was %NULL.
124 	 *
125 	 * Since: 1.22
126 	 */
127 	public PgGlyphItemIter copy()
128 	{
129 		auto p = pango_glyph_item_iter_copy(pangoGlyphItemIter);
130 		
131 		if(p is null)
132 		{
133 			return null;
134 		}
135 		
136 		return ObjectG.getDObject!(PgGlyphItemIter)(cast(PangoGlyphItemIter*) p, true);
137 	}
138 
139 	/**
140 	 * Frees a #PangoGlyphItemIter created by pango_glyph_item_iter_copy().
141 	 *
142 	 * Since: 1.22
143 	 */
144 	public void free()
145 	{
146 		pango_glyph_item_iter_free(pangoGlyphItemIter);
147 		ownedRef = false;
148 	}
149 
150 	/**
151 	 * Initializes a #PangoGlyphItemIter structure to point to the
152 	 * last cluster in a glyph item.
153 	 * See #PangoGlyphItemIter for details of cluster orders.
154 	 *
155 	 * Params:
156 	 *     glyphItem = the glyph item to iterate over
157 	 *     text = text corresponding to the glyph item
158 	 *
159 	 * Returns: %FALSE if there are no clusters in the glyph item
160 	 *
161 	 * Since: 1.22
162 	 */
163 	public bool initEnd(PgGlyphItem glyphItem, string text)
164 	{
165 		return pango_glyph_item_iter_init_end(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0;
166 	}
167 
168 	/**
169 	 * Initializes a #PangoGlyphItemIter structure to point to the
170 	 * first cluster in a glyph item.
171 	 * See #PangoGlyphItemIter for details of cluster orders.
172 	 *
173 	 * Params:
174 	 *     glyphItem = the glyph item to iterate over
175 	 *     text = text corresponding to the glyph item
176 	 *
177 	 * Returns: %FALSE if there are no clusters in the glyph item
178 	 *
179 	 * Since: 1.22
180 	 */
181 	public bool initStart(PgGlyphItem glyphItem, string text)
182 	{
183 		return pango_glyph_item_iter_init_start(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0;
184 	}
185 
186 	/**
187 	 * Advances the iterator to the next cluster in the glyph item.
188 	 * See #PangoGlyphItemIter for details of cluster orders.
189 	 *
190 	 * Returns: %TRUE if the iterator was advanced, %FALSE if we were already on the
191 	 *     last cluster.
192 	 *
193 	 * Since: 1.22
194 	 */
195 	public bool nextCluster()
196 	{
197 		return pango_glyph_item_iter_next_cluster(pangoGlyphItemIter) != 0;
198 	}
199 
200 	/**
201 	 * Moves the iterator to the preceding cluster in the glyph item.
202 	 * See #PangoGlyphItemIter for details of cluster orders.
203 	 *
204 	 * Returns: %TRUE if the iterator was moved, %FALSE if we were already on the
205 	 *     first cluster.
206 	 *
207 	 * Since: 1.22
208 	 */
209 	public bool prevCluster()
210 	{
211 		return pango_glyph_item_iter_prev_cluster(pangoGlyphItemIter) != 0;
212 	}
213 }