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