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