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.PgAttributeList; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gtkc.pango; 30 public import gtkc.pangotypes; 31 private import pango.PgAttribute; 32 private import pango.PgAttributeIterator; 33 34 35 /** 36 * The #PangoAttrList structure represents a list of attributes 37 * that apply to a section of text. The attributes are, in general, 38 * allowed to overlap in an arbitrary fashion, however, if the 39 * attributes are manipulated only through pango_attr_list_change(), 40 * the overlap between properties will meet stricter criteria. 41 * 42 * Since the #PangoAttrList structure is stored as a linear list, 43 * it is not suitable for storing attributes for large amounts 44 * of text. In general, you should not use a single #PangoAttrList 45 * for more than one paragraph of text. 46 */ 47 public class PgAttributeList 48 { 49 /** the main Gtk struct */ 50 protected PangoAttrList* pangoAttrList; 51 52 /** Get the main Gtk struct */ 53 public PangoAttrList* getPgAttributeListStruct() 54 { 55 return pangoAttrList; 56 } 57 58 /** the main Gtk struct as a void* */ 59 protected void* getStruct() 60 { 61 return cast(void*)pangoAttrList; 62 } 63 64 /** 65 * Sets our main struct and passes it to the parent class. 66 */ 67 public this (PangoAttrList* pangoAttrList) 68 { 69 this.pangoAttrList = pangoAttrList; 70 } 71 72 73 /** */ 74 public static GType getType() 75 { 76 return pango_attr_list_get_type(); 77 } 78 79 /** 80 * Create a new empty attribute list with a reference count of one. 81 * 82 * Return: the newly allocated #PangoAttrList, 83 * which should be freed with pango_attr_list_unref(). 84 * 85 * Throws: ConstructionException GTK+ fails to create the object. 86 */ 87 public this() 88 { 89 auto p = pango_attr_list_new(); 90 91 if(p is null) 92 { 93 throw new ConstructionException("null returned by new"); 94 } 95 96 this(cast(PangoAttrList*) p); 97 } 98 99 /** 100 * Insert the given attribute into the #PangoAttrList. It will 101 * replace any attributes of the same type on that segment 102 * and be merged with any adjoining attributes that are identical. 103 * 104 * This function is slower than pango_attr_list_insert() for 105 * creating a attribute list in order (potentially much slower 106 * for large lists). However, pango_attr_list_insert() is not 107 * suitable for continually changing a set of attributes 108 * since it never removes or combines existing attributes. 109 * 110 * Params: 111 * attr = the attribute to insert. Ownership of this 112 * value is assumed by the list. 113 */ 114 public void change(PgAttribute attr) 115 { 116 pango_attr_list_change(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct()); 117 } 118 119 /** 120 * Copy @list and return an identical new list. 121 * 122 * Return: the newly allocated #PangoAttrList, with a 123 * reference count of one, which should 124 * be freed with pango_attr_list_unref(). 125 * Returns %NULL if @list was %NULL. 126 */ 127 public PgAttributeList copy() 128 { 129 auto p = pango_attr_list_copy(pangoAttrList); 130 131 if(p is null) 132 { 133 return null; 134 } 135 136 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p); 137 } 138 139 /** 140 * Given a #PangoAttrList and callback function, removes any elements 141 * of @list for which @func returns %TRUE and inserts them into 142 * a new list. 143 * 144 * Params: 145 * func = callback function; returns %TRUE 146 * if an attribute should be filtered out. 147 * data = Data to be passed to @func 148 * 149 * Return: the new #PangoAttrList or 150 * %NULL if no attributes of the given types were found. 151 * 152 * Since: 1.2 153 */ 154 public PgAttributeList filter(PangoAttrFilterFunc func, void* data) 155 { 156 auto p = pango_attr_list_filter(pangoAttrList, func, data); 157 158 if(p is null) 159 { 160 return null; 161 } 162 163 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p); 164 } 165 166 /** 167 * Create a iterator initialized to the beginning of the list. 168 * @list must not be modified until this iterator is freed. 169 * 170 * Return: the newly allocated #PangoAttrIterator, which should 171 * be freed with pango_attr_iterator_destroy(). 172 */ 173 public PgAttributeIterator getIterator() 174 { 175 auto p = pango_attr_list_get_iterator(pangoAttrList); 176 177 if(p is null) 178 { 179 return null; 180 } 181 182 return ObjectG.getDObject!(PgAttributeIterator)(cast(PangoAttrIterator*) p); 183 } 184 185 /** 186 * Insert the given attribute into the #PangoAttrList. It will 187 * be inserted after all other attributes with a matching 188 * @start_index. 189 * 190 * Params: 191 * attr = the attribute to insert. Ownership of this 192 * value is assumed by the list. 193 */ 194 public void insert(PgAttribute attr) 195 { 196 pango_attr_list_insert(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct()); 197 } 198 199 /** 200 * Insert the given attribute into the #PangoAttrList. It will 201 * be inserted before all other attributes with a matching 202 * @start_index. 203 * 204 * Params: 205 * attr = the attribute to insert. Ownership of this 206 * value is assumed by the list. 207 */ 208 public void insertBefore(PgAttribute attr) 209 { 210 pango_attr_list_insert_before(pangoAttrList, (attr is null) ? null : attr.getPgAttributeStruct()); 211 } 212 213 /** 214 * Increase the reference count of the given attribute list by one. 215 * 216 * Return: The attribute list passed in 217 * 218 * Since: 1.10 219 */ 220 public PgAttributeList doref() 221 { 222 auto p = pango_attr_list_ref(pangoAttrList); 223 224 if(p is null) 225 { 226 return null; 227 } 228 229 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p); 230 } 231 232 /** 233 * This function opens up a hole in @list, fills it in with attributes from 234 * the left, and then merges @other on top of the hole. 235 * 236 * This operation is equivalent to stretching every attribute 237 * that applies at position @pos in @list by an amount @len, 238 * and then calling pango_attr_list_change() with a copy 239 * of each attribute in @other in sequence (offset in position by @pos). 240 * 241 * This operation proves useful for, for instance, inserting 242 * a pre-edit string in the middle of an edit buffer. 243 * 244 * Params: 245 * other = another #PangoAttrList 246 * pos = the position in @list at which to insert @other 247 * len = the length of the spliced segment. (Note that this 248 * must be specified since the attributes in @other 249 * may only be present at some subsection of this range) 250 */ 251 public void splice(PgAttributeList other, int pos, int len) 252 { 253 pango_attr_list_splice(pangoAttrList, (other is null) ? null : other.getPgAttributeListStruct(), pos, len); 254 } 255 256 /** 257 * Decrease the reference count of the given attribute list by one. 258 * If the result is zero, free the attribute list and the attributes 259 * it contains. 260 */ 261 public void unref() 262 { 263 pango_attr_list_unref(pangoAttrList); 264 } 265 }