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.PgAttributeIterator; 26 27 private import glib.ListSG; 28 private import gobject.ObjectG; 29 public import gtkc.pangotypes; 30 private import pango.PgAttribute; 31 private import pango.PgFontDescription; 32 private import pango.PgLanguage; 33 private import pango.c.functions; 34 public import pango.c.types; 35 36 37 /** 38 * The #PangoAttrIterator structure is used to represent an 39 * iterator through a #PangoAttrList. A new iterator is created 40 * with pango_attr_list_get_iterator(). Once the iterator 41 * is created, it can be advanced through the style changes 42 * in the text using pango_attr_iterator_next(). At each 43 * style change, the range of the current style segment and the 44 * attributes currently in effect can be queried. 45 */ 46 public class PgAttributeIterator 47 { 48 /** the main Gtk struct */ 49 protected PangoAttrIterator* pangoAttrIterator; 50 protected bool ownedRef; 51 52 /** Get the main Gtk struct */ 53 public PangoAttrIterator* getPgAttributeIteratorStruct(bool transferOwnership = false) 54 { 55 if (transferOwnership) 56 ownedRef = false; 57 return pangoAttrIterator; 58 } 59 60 /** the main Gtk struct as a void* */ 61 protected void* getStruct() 62 { 63 return cast(void*)pangoAttrIterator; 64 } 65 66 /** 67 * Sets our main struct and passes it to the parent class. 68 */ 69 public this (PangoAttrIterator* pangoAttrIterator, bool ownedRef = false) 70 { 71 this.pangoAttrIterator = pangoAttrIterator; 72 this.ownedRef = ownedRef; 73 } 74 75 76 /** 77 * Copy a #PangoAttrIterator 78 * 79 * Returns: the newly allocated 80 * #PangoAttrIterator, which should be freed with 81 * pango_attr_iterator_destroy(). 82 */ 83 public PgAttributeIterator copy() 84 { 85 auto p = pango_attr_iterator_copy(pangoAttrIterator); 86 87 if(p is null) 88 { 89 return null; 90 } 91 92 return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) p, true); 93 } 94 95 /** 96 * Destroy a #PangoAttrIterator and free all associated memory. 97 */ 98 public void destroy() 99 { 100 pango_attr_iterator_destroy(pangoAttrIterator); 101 } 102 103 /** 104 * Find the current attribute of a particular type at the iterator 105 * location. When multiple attributes of the same type overlap, 106 * the attribute whose range starts closest to the current location 107 * is used. 108 * 109 * Params: 110 * type = the type of attribute to find. 111 * 112 * Returns: the current attribute of the given type, 113 * or %NULL if no attribute of that type applies to the 114 * current location. 115 */ 116 public PgAttribute get(PangoAttrType type) 117 { 118 auto p = pango_attr_iterator_get(pangoAttrIterator, type); 119 120 if(p is null) 121 { 122 return null; 123 } 124 125 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 126 } 127 128 /** 129 * Gets a list of all attributes at the current position of the 130 * iterator. 131 * 132 * Returns: a list of 133 * all attributes for the current range. 134 * To free this value, call pango_attribute_destroy() on 135 * each value and g_slist_free() on the list. 136 * 137 * Since: 1.2 138 */ 139 public ListSG getAttrs() 140 { 141 auto p = pango_attr_iterator_get_attrs(pangoAttrIterator); 142 143 if(p is null) 144 { 145 return null; 146 } 147 148 return new ListSG(cast(GSList*) p, true); 149 } 150 151 /** 152 * Get the font and other attributes at the current iterator position. 153 * 154 * Params: 155 * desc = a #PangoFontDescription to fill in with the current values. 156 * The family name in this structure will be set using 157 * pango_font_description_set_family_static() using values from 158 * an attribute in the #PangoAttrList associated with the iterator, 159 * so if you plan to keep it around, you must call: 160 * <literal>pango_font_description_set_family (desc, pango_font_description_get_family (desc))</literal>. 161 * language = if non-%NULL, location to store language tag for item, or %NULL 162 * if none is found. 163 * extraAttrs = if non-%NULL, 164 * location in which to store a list of non-font 165 * attributes at the the current position; only the highest priority 166 * value of each attribute will be added to this list. In order 167 * to free this value, you must call pango_attribute_destroy() on 168 * each member. 169 */ 170 public void getFont(PgFontDescription desc, out PgLanguage language, out ListSG extraAttrs) 171 { 172 PangoLanguage* outlanguage = null; 173 GSList* outextraAttrs = null; 174 175 pango_attr_iterator_get_font(pangoAttrIterator, (desc is null) ? null : desc.getPgFontDescriptionStruct(), &outlanguage, &outextraAttrs); 176 177 language = ObjectG.getDObject!(PgLanguage)(outlanguage); 178 extraAttrs = new ListSG(outextraAttrs); 179 } 180 181 /** 182 * Advance the iterator until the next change of style. 183 * 184 * Returns: %FALSE if the iterator is at the end of the list, otherwise %TRUE 185 */ 186 public bool next() 187 { 188 return pango_attr_iterator_next(pangoAttrIterator) != 0; 189 } 190 191 /** 192 * Get the range of the current segment. Note that the 193 * stored return values are signed, not unsigned like 194 * the values in #PangoAttribute. To deal with this API 195 * oversight, stored return values that wouldn't fit into 196 * a signed integer are clamped to %G_MAXINT. 197 * 198 * Params: 199 * start = location to store the start of the range 200 * end = location to store the end of the range 201 */ 202 public void range(out int start, out int end) 203 { 204 pango_attr_iterator_range(pangoAttrIterator, &start, &end); 205 } 206 }