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 (&cluster_iter, 55 * glyph_item, text); 56 * have_cluster; 57 * have_cluster = pango_glyph_item_iter_next_cluster (&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 80 /** Get the main Gtk struct */ 81 public PangoGlyphItemIter* getPgGlyphItemIterStruct() 82 { 83 return pangoGlyphItemIter; 84 } 85 86 /** the main Gtk struct as a void* */ 87 protected void* getStruct() 88 { 89 return cast(void*)pangoGlyphItemIter; 90 } 91 92 /** 93 * Sets our main struct and passes it to the parent class. 94 */ 95 public this (PangoGlyphItemIter* pangoGlyphItemIter) 96 { 97 this.pangoGlyphItemIter = pangoGlyphItemIter; 98 } 99 100 101 /** */ 102 public static GType getType() 103 { 104 return pango_glyph_item_iter_get_type(); 105 } 106 107 /** 108 * Make a shallow copy of an existing #PangoGlyphItemIter structure. 109 * 110 * Return: the newly allocated #PangoGlyphItemIter, which should 111 * be freed with pango_glyph_item_iter_free(), or %NULL 112 * if @orig was %NULL. 113 * 114 * Since: 1.22 115 */ 116 public PgGlyphItemIter copy() 117 { 118 auto p = pango_glyph_item_iter_copy(pangoGlyphItemIter); 119 120 if(p is null) 121 { 122 return null; 123 } 124 125 return ObjectG.getDObject!(PgGlyphItemIter)(cast(PangoGlyphItemIter*) p); 126 } 127 128 /** 129 * Frees a #PangoGlyphItemIter created by pango_glyph_item_iter_copy(). 130 * 131 * Since: 1.22 132 */ 133 public void free() 134 { 135 pango_glyph_item_iter_free(pangoGlyphItemIter); 136 } 137 138 /** 139 * Initializes a #PangoGlyphItemIter structure to point to the 140 * last cluster in a glyph item. 141 * See #PangoGlyphItemIter for details of cluster orders. 142 * 143 * Params: 144 * glyphItem = the glyph item to iterate over 145 * text = text corresponding to the glyph item 146 * 147 * Return: %FALSE if there are no clusters in the glyph item 148 * 149 * Since: 1.22 150 */ 151 public bool initEnd(PgGlyphItem glyphItem, string text) 152 { 153 return pango_glyph_item_iter_init_end(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0; 154 } 155 156 /** 157 * Initializes a #PangoGlyphItemIter structure to point to the 158 * first cluster in a glyph item. 159 * See #PangoGlyphItemIter for details of cluster orders. 160 * 161 * Params: 162 * glyphItem = the glyph item to iterate over 163 * text = text corresponding to the glyph item 164 * 165 * Return: %FALSE if there are no clusters in the glyph item 166 * 167 * Since: 1.22 168 */ 169 public bool initStart(PgGlyphItem glyphItem, string text) 170 { 171 return pango_glyph_item_iter_init_start(pangoGlyphItemIter, (glyphItem is null) ? null : glyphItem.getPgGlyphItemStruct(), Str.toStringz(text)) != 0; 172 } 173 174 /** 175 * Advances the iterator to the next cluster in the glyph item. 176 * See #PangoGlyphItemIter for details of cluster orders. 177 * 178 * Return: %TRUE if the iterator was advanced, %FALSE if we were already on the 179 * last cluster. 180 * 181 * Since: 1.22 182 */ 183 public bool nextCluster() 184 { 185 return pango_glyph_item_iter_next_cluster(pangoGlyphItemIter) != 0; 186 } 187 188 /** 189 * Moves the iterator to the preceding cluster in the glyph item. 190 * See #PangoGlyphItemIter for details of cluster orders. 191 * 192 * Return: %TRUE if the iterator was moved, %FALSE if we were already on the 193 * first cluster. 194 * 195 * Since: 1.22 196 */ 197 public bool prevCluster() 198 { 199 return pango_glyph_item_iter_prev_cluster(pangoGlyphItemIter) != 0; 200 } 201 }