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