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 * Conversion parameters: 26 * inFile = 27 * outPack = pango 28 * outFile = PgAttributeIterator 29 * strct = PangoAttrIterator 30 * realStrct= 31 * ctorStrct= 32 * clss = PgAttributeIterator 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_attr_iterator_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - pango.PgAttribute 47 * - pango.PgFontDescription 48 * - pango.PgLanguage 49 * - glib.ListSG 50 * structWrap: 51 * - GSList* -> ListSG 52 * - PangoAttrIterator* -> PgAttributeIterator 53 * - PangoAttribute* -> PgAttribute 54 * - PangoFontDescription* -> PgFontDescription 55 * - PangoLanguage* -> PgLanguage 56 * module aliases: 57 * local aliases: 58 * overrides: 59 */ 60 61 module pango.PgAttributeIterator; 62 63 public import gtkc.pangotypes; 64 65 private import gtkc.pango; 66 private import glib.ConstructionException; 67 private import gobject.ObjectG; 68 69 70 private import pango.PgAttribute; 71 private import pango.PgFontDescription; 72 private import pango.PgLanguage; 73 private import glib.ListSG; 74 75 76 77 78 /** 79 * Description 80 * Attributed text is used in a number of places in Pango. It 81 * is used as the input to the itemization process and also when 82 * creating a PangoLayout. The data types and functions in 83 * this section are used to represent and manipulate sets 84 * of attributes applied to a portion of text. 85 */ 86 public class PgAttributeIterator 87 { 88 89 /** the main Gtk struct */ 90 protected PangoAttrIterator* pangoAttrIterator; 91 92 93 public PangoAttrIterator* getPgAttributeIteratorStruct() 94 { 95 return pangoAttrIterator; 96 } 97 98 99 /** the main Gtk struct as a void* */ 100 protected void* getStruct() 101 { 102 return cast(void*)pangoAttrIterator; 103 } 104 105 /** 106 * Sets our main struct and passes it to the parent class 107 */ 108 public this (PangoAttrIterator* pangoAttrIterator) 109 { 110 this.pangoAttrIterator = pangoAttrIterator; 111 } 112 113 /** 114 */ 115 116 /** 117 * Copy a PangoAttrIterator 118 * Returns: the newly allocated PangoAttrIterator, which should be freed with pango_attr_iterator_destroy(). 119 */ 120 public PgAttributeIterator copy() 121 { 122 // PangoAttrIterator * pango_attr_iterator_copy (PangoAttrIterator *iterator); 123 auto p = pango_attr_iterator_copy(pangoAttrIterator); 124 125 if(p is null) 126 { 127 return null; 128 } 129 130 return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) p); 131 } 132 133 /** 134 * Advance the iterator until the next change of style. 135 * Returns: FALSE if the iterator is at the end of the list, otherwise TRUE 136 */ 137 public int next() 138 { 139 // gboolean pango_attr_iterator_next (PangoAttrIterator *iterator); 140 return pango_attr_iterator_next(pangoAttrIterator); 141 } 142 143 /** 144 * Get the range of the current segment. Note that the 145 * stored return values are signed, not unsigned like 146 * the values in PangoAttribute. To deal with this API 147 * oversight, stored return values that wouldn't fit into 148 * a signed integer are clamped to G_MAXINT. 149 * Params: 150 * start = location to store the start of the range 151 * end = location to store the end of the range 152 */ 153 public void range(out int start, out int end) 154 { 155 // void pango_attr_iterator_range (PangoAttrIterator *iterator, gint *start, gint *end); 156 pango_attr_iterator_range(pangoAttrIterator, &start, &end); 157 } 158 159 /** 160 * Find the current attribute of a particular type at the iterator 161 * location. When multiple attributes of the same type overlap, 162 * the attribute whose range starts closest to the current location 163 * is used. 164 * Params: 165 * type = the type of attribute to find. 166 * Returns: the current attribute of the given type, or NULL if no attribute of that type applies to the current location. 167 */ 168 public PgAttribute get(PangoAttrType type) 169 { 170 // PangoAttribute * pango_attr_iterator_get (PangoAttrIterator *iterator, PangoAttrType type); 171 auto p = pango_attr_iterator_get(pangoAttrIterator, type); 172 173 if(p is null) 174 { 175 return null; 176 } 177 178 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 179 } 180 181 /** 182 * Get the font and other attributes at the current iterator position. 183 * Params: 184 * desc = a PangoFontDescription to fill in with the current values. 185 * The family name in this structure will be set using 186 * pango_font_description_set_family_static() using values from 187 * an attribute in the PangoAttrList associated with the iterator, 188 * language = if non-NULL, location to store language tag for item, or NULL 189 * if none is found. 190 * extraAttrs = if non-NULL, 191 * location in which to store a list of non-font 192 * attributes at the the current position; only the highest priority 193 * value of each attribute will be added to this list. In order 194 * to free this value, you must call pango_attribute_destroy() on 195 * each member. [element type Pango.Attribute][transfer full] 196 */ 197 public void getFont(PgFontDescription desc, out PgLanguage language, out ListSG extraAttrs) 198 { 199 // void pango_attr_iterator_get_font (PangoAttrIterator *iterator, PangoFontDescription *desc, PangoLanguage **language, GSList **extra_attrs); 200 PangoLanguage* outlanguage = null; 201 GSList* outextraAttrs = null; 202 203 pango_attr_iterator_get_font(pangoAttrIterator, (desc is null) ? null : desc.getPgFontDescriptionStruct(), &outlanguage, &outextraAttrs); 204 205 language = ObjectG.getDObject!(PgLanguage)(outlanguage); 206 extraAttrs = ObjectG.getDObject!(ListSG)(outextraAttrs); 207 } 208 209 /** 210 * Gets a list of all attributes at the current position of the 211 * iterator. 212 * Since 1.2 213 * Returns: a list of all attributes for the current range. To free this value, call pango_attribute_destroy() on each value and g_slist_free() on the list. [element-type Pango.Attribute][transfer full Pango.Attribute] 214 */ 215 public ListSG getAttrs() 216 { 217 // GSList * pango_attr_iterator_get_attrs (PangoAttrIterator *iterator); 218 auto p = pango_attr_iterator_get_attrs(pangoAttrIterator); 219 220 if(p is null) 221 { 222 return null; 223 } 224 225 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 226 } 227 228 /** 229 * Destroy a PangoAttrIterator and free all associated memory. 230 */ 231 public void destroy() 232 { 233 // void pango_attr_iterator_destroy (PangoAttrIterator *iterator); 234 pango_attr_iterator_destroy(pangoAttrIterator); 235 } 236 }