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.PgItem; 26 27 private import glib.ConstructionException; 28 private import glib.MemorySlice; 29 private import gobject.ObjectG; 30 private import gtkd.Loader; 31 private import pango.PgAttributeIterator; 32 private import pango.c.functions; 33 public import pango.c.types; 34 35 36 /** 37 * The `PangoItem` structure stores information about a segment of text. 38 * 39 * You typically obtain `PangoItems` by itemizing a piece of text 40 * with [func@itemize]. 41 */ 42 public final class PgItem 43 { 44 /** the main Gtk struct */ 45 protected PangoItem* pangoItem; 46 protected bool ownedRef; 47 48 /** Get the main Gtk struct */ 49 public PangoItem* getPgItemStruct(bool transferOwnership = false) 50 { 51 if (transferOwnership) 52 ownedRef = false; 53 return pangoItem; 54 } 55 56 /** the main Gtk struct as a void* */ 57 protected void* getStruct() 58 { 59 return cast(void*)pangoItem; 60 } 61 62 /** 63 * Sets our main struct and passes it to the parent class. 64 */ 65 public this (PangoItem* pangoItem, bool ownedRef = false) 66 { 67 this.pangoItem = pangoItem; 68 this.ownedRef = ownedRef; 69 } 70 71 ~this () 72 { 73 if ( Linker.isLoaded(LIBRARY_PANGO) && ownedRef ) 74 pango_item_free(pangoItem); 75 } 76 77 78 /** 79 * byte offset of the start of this item in text. 80 */ 81 public @property int offset() 82 { 83 return pangoItem.offset; 84 } 85 86 /** Ditto */ 87 public @property void offset(int value) 88 { 89 pangoItem.offset = value; 90 } 91 92 /** 93 * length of this item in bytes. 94 */ 95 public @property int length() 96 { 97 return pangoItem.length; 98 } 99 100 /** Ditto */ 101 public @property void length(int value) 102 { 103 pangoItem.length = value; 104 } 105 106 /** 107 * number of Unicode characters in the item. 108 */ 109 public @property int numChars() 110 { 111 return pangoItem.numChars; 112 } 113 114 /** Ditto */ 115 public @property void numChars(int value) 116 { 117 pangoItem.numChars = value; 118 } 119 120 /** 121 * analysis results for the item. 122 */ 123 public @property PangoAnalysis analysis() 124 { 125 return pangoItem.analysis; 126 } 127 128 /** Ditto */ 129 public @property void analysis(PangoAnalysis value) 130 { 131 pangoItem.analysis = value; 132 } 133 134 /** */ 135 public static GType getType() 136 { 137 return pango_item_get_type(); 138 } 139 140 /** 141 * Creates a new `PangoItem` structure initialized to default values. 142 * 143 * Returns: the newly allocated `PangoItem`, which should 144 * be freed with [method@Pango.Item.free]. 145 * 146 * Throws: ConstructionException GTK+ fails to create the object. 147 */ 148 public this() 149 { 150 auto __p = pango_item_new(); 151 152 if(__p is null) 153 { 154 throw new ConstructionException("null returned by new"); 155 } 156 157 this(cast(PangoItem*) __p); 158 } 159 160 /** 161 * Add attributes to a `PangoItem`. 162 * 163 * The idea is that you have attributes that don't affect itemization, 164 * such as font features, so you filter them out using 165 * [method@Pango.AttrList.filter], itemize your text, then reapply the 166 * attributes to the resulting items using this function. 167 * 168 * The @iter should be positioned before the range of the item, 169 * and will be advanced past it. This function is meant to be called 170 * in a loop over the items resulting from itemization, while passing 171 * the iter to each call. 172 * 173 * Params: 174 * iter = a `PangoAttrIterator` 175 * 176 * Since: 1.44 177 */ 178 public void applyAttrs(PgAttributeIterator iter) 179 { 180 pango_item_apply_attrs(pangoItem, (iter is null) ? null : iter.getPgAttributeIteratorStruct()); 181 } 182 183 /** 184 * Copy an existing `PangoItem` structure. 185 * 186 * Returns: the newly allocated `PangoItem`, which 187 * should be freed with [method@Pango.Item.free], or %NULL if 188 * @item was %NULL. 189 */ 190 public PgItem copy() 191 { 192 auto __p = pango_item_copy(pangoItem); 193 194 if(__p is null) 195 { 196 return null; 197 } 198 199 return ObjectG.getDObject!(PgItem)(cast(PangoItem*) __p, true); 200 } 201 202 /** 203 * Free a `PangoItem` and all associated memory. 204 */ 205 public void free() 206 { 207 pango_item_free(pangoItem); 208 ownedRef = false; 209 } 210 211 /** 212 * Modifies @orig to cover only the text after @split_index, and 213 * returns a new item that covers the text before @split_index that 214 * used to be in @orig. 215 * 216 * You can think of @split_index as the length of the returned item. 217 * @split_index may not be 0, and it may not be greater than or equal 218 * to the length of @orig (that is, there must be at least one byte 219 * assigned to each item, you can't create a zero-length item). 220 * @split_offset is the length of the first item in chars, and must be 221 * provided because the text used to generate the item isn't available, 222 * so `pango_item_split()` can't count the char length of the split items 223 * itself. 224 * 225 * Params: 226 * splitIndex = byte index of position to split item, relative to the 227 * start of the item 228 * splitOffset = number of chars between start of @orig and @split_index 229 * 230 * Returns: new item representing text before @split_index, which 231 * should be freed with [method@Pango.Item.free]. 232 */ 233 public PgItem split(int splitIndex, int splitOffset) 234 { 235 auto __p = pango_item_split(pangoItem, splitIndex, splitOffset); 236 237 if(__p is null) 238 { 239 return null; 240 } 241 242 return ObjectG.getDObject!(PgItem)(cast(PangoItem*) __p, true); 243 } 244 }