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 = PgGlyphItem 29 * strct = PangoGlyphItem 30 * realStrct= 31 * ctorStrct= 32 * clss = PgGlyphItem 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_glyph_item_ 41 * omit structs: 42 * omit prefixes: 43 * - pango_glyph_item_iter_ 44 * omit code: 45 * - pango_glyph_item_get_logical_widths 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - pango.PgAttributeList 50 * - glib.ListSG 51 * structWrap: 52 * - GSList* -> ListSG 53 * - PangoAttrList* -> PgAttributeList 54 * - PangoGlyphItem* -> PgGlyphItem 55 * module aliases: 56 * local aliases: 57 * overrides: 58 */ 59 60 module pango.PgGlyphItem; 61 62 public import gtkc.pangotypes; 63 64 private import gtkc.pango; 65 private import glib.ConstructionException; 66 private import gobject.ObjectG; 67 68 69 private import glib.Str; 70 private import pango.PgAttributeList; 71 private import glib.ListSG; 72 73 74 75 76 /** 77 * pango_shape() produces a string of glyphs which 78 * can be measured or drawn to the screen. The following 79 * structures are used to store information about 80 * glyphs. 81 */ 82 public class PgGlyphItem 83 { 84 85 /** the main Gtk struct */ 86 protected PangoGlyphItem* pangoGlyphItem; 87 88 89 public PangoGlyphItem* getPgGlyphItemStruct() 90 { 91 return pangoGlyphItem; 92 } 93 94 95 /** the main Gtk struct as a void* */ 96 protected void* getStruct() 97 { 98 return cast(void*)pangoGlyphItem; 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class 103 */ 104 public this (PangoGlyphItem* pangoGlyphItem) 105 { 106 this.pangoGlyphItem = pangoGlyphItem; 107 } 108 109 /** 110 * Given a PangoGlyphItem and the corresponding 111 * text, determine the screen width corresponding to each character. When 112 * multiple characters compose a single cluster, the width of the entire 113 * cluster is divided equally among the characters. 114 * See also pango_glyph_string_get_logical_widths(). 115 * Since 1.26 116 * Params: 117 * text = text that glyph_item corresponds to 118 * (glyph_item->item->offset is an offset from the 119 * start of text) 120 * logicalWidths = an array whose length is the number of characters in 121 * glyph_item (equal to glyph_item->item->num_chars) 122 * to be filled in with the resulting character widths. 123 */ 124 public void getLogicalWidths(string text, out int[] logicalWidths) 125 { 126 logicalWidths = new int[pangoGlyphItem.item.numChars]; 127 128 // void pango_glyph_item_get_logical_widths (PangoGlyphItem *glyph_item, const char *text, int *logical_widths); 129 pango_glyph_item_get_logical_widths(pangoGlyphItem, Str.toStringz(text), logicalWidths.ptr); 130 } 131 132 /** 133 */ 134 135 /** 136 * Make a deep copy of an existing PangoGlyphItem structure. 137 * Since 1.20 138 * Returns: the newly allocated PangoGlyphItem, which should be freed with pango_glyph_item_free(), or NULL if orig was NULL. 139 */ 140 public PgGlyphItem copy() 141 { 142 // PangoGlyphItem * pango_glyph_item_copy (PangoGlyphItem *orig); 143 auto p = pango_glyph_item_copy(pangoGlyphItem); 144 145 if(p is null) 146 { 147 return null; 148 } 149 150 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p); 151 } 152 153 /** 154 * Frees a PangoGlyphItem and resources to which it points. 155 * Since 1.6 156 */ 157 public void free() 158 { 159 // void pango_glyph_item_free (PangoGlyphItem *glyph_item); 160 pango_glyph_item_free(pangoGlyphItem); 161 } 162 163 /** 164 * Modifies orig to cover only the text after split_index, and 165 * returns a new item that covers the text before split_index that 166 * used to be in orig. You can think of split_index as the length of 167 * the returned item. split_index may not be 0, and it may not be 168 * greater than or equal to the length of orig (that is, there must 169 * be at least one byte assigned to each item, you can't create a 170 * zero-length item). 171 * This function is similar in function to pango_item_split() (and uses 172 * it internally.) 173 * Since 1.2 174 * Params: 175 * text = text to which positions in orig apply 176 * splitIndex = byte index of position to split item, relative to the start of the item 177 * Returns: the newly allocated item representing text before split_index, which should be freed with pango_glyph_item_free(). 178 */ 179 public PgGlyphItem split(string text, int splitIndex) 180 { 181 // PangoGlyphItem * pango_glyph_item_split (PangoGlyphItem *orig, const char *text, int split_index); 182 auto p = pango_glyph_item_split(pangoGlyphItem, Str.toStringz(text), splitIndex); 183 184 if(p is null) 185 { 186 return null; 187 } 188 189 return ObjectG.getDObject!(PgGlyphItem)(cast(PangoGlyphItem*) p); 190 } 191 192 /** 193 * Splits a shaped item (PangoGlyphItem) into multiple items based 194 * on an attribute list. The idea is that if you have attributes 195 * that don't affect shaping, such as color or underline, to avoid 196 * affecting shaping, you filter them out (pango_attr_list_filter()), 197 * apply the shaping process and then reapply them to the result using 198 * this function. 199 * All attributes that start or end inside a cluster are applied 200 * to that cluster; for instance, if half of a cluster is underlined 201 * and the other-half strikethrough, then the cluster will end 202 * up with both underline and strikethrough attributes. In these 203 * cases, it may happen that item->extra_attrs for some of the 204 * result items can have multiple attributes of the same type. 205 * This function takes ownership of glyph_item; it will be reused 206 * as one of the elements in the list. 207 * Since 1.2 208 * Params: 209 * text = text that list applies to 210 * list = a PangoAttrList 211 * Returns: a list of glyph items resulting from splitting glyph_item. Free the elements using pango_glyph_item_free(), the list using g_slist_free(). [transfer full][element-type Pango.GlyphItem] 212 */ 213 public ListSG applyAttrs(string text, PgAttributeList list) 214 { 215 // GSList * pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item, const char *text, PangoAttrList *list); 216 auto p = pango_glyph_item_apply_attrs(pangoGlyphItem, Str.toStringz(text), (list is null) ? null : list.getPgAttributeListStruct()); 217 218 if(p is null) 219 { 220 return null; 221 } 222 223 return ObjectG.getDObject!(ListSG)(cast(GSList*) p); 224 } 225 226 /** 227 * Adds spacing between the graphemes of glyph_item to 228 * give the effect of typographic letter spacing. 229 * Since 1.6 230 * Params: 231 * text = text that glyph_item corresponds to 232 * (glyph_item->item->offset is an offset from the 233 * start of text) 234 * logAttrs = logical attributes for the item 235 * (the first logical attribute refers to the position 236 * before the first character in the item). [array] 237 * letterSpacing = amount of letter spacing to add 238 * in Pango units. May be negative, though too large 239 * negative values will give ugly results. 240 */ 241 public void letterSpace(string text, ref PangoLogAttr logAttrs, int letterSpacing) 242 { 243 // void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item, const char *text, PangoLogAttr *log_attrs, int letter_spacing); 244 pango_glyph_item_letter_space(pangoGlyphItem, Str.toStringz(text), &logAttrs, letterSpacing); 245 } 246 }