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 = PgGlyphString 29 * strct = PangoGlyphString 30 * realStrct= 31 * ctorStrct= 32 * clss = PgGlyphString 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_glyph_string_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * - pango.PgFont 48 * structWrap: 49 * - PangoFont* -> PgFont 50 * - PangoGlyphString* -> PgGlyphString 51 * module aliases: 52 * local aliases: 53 * overrides: 54 */ 55 56 module pango.PgGlyphString; 57 58 public import gtkc.pangotypes; 59 60 private import gtkc.pango; 61 private import glib.ConstructionException; 62 private import gobject.ObjectG; 63 64 private import glib.Str; 65 private import pango.PgFont; 66 67 68 69 /** 70 * pango_shape() produces a string of glyphs which 71 * can be measured or drawn to the screen. The following 72 * structures are used to store information about 73 * glyphs. 74 */ 75 public class PgGlyphString 76 { 77 78 /** the main Gtk struct */ 79 protected PangoGlyphString* pangoGlyphString; 80 81 82 /** Get the main Gtk struct */ 83 public PangoGlyphString* getPgGlyphStringStruct() 84 { 85 return pangoGlyphString; 86 } 87 88 89 /** the main Gtk struct as a void* */ 90 protected void* getStruct() 91 { 92 return cast(void*)pangoGlyphString; 93 } 94 95 /** 96 * Sets our main struct and passes it to the parent class 97 */ 98 public this (PangoGlyphString* pangoGlyphString) 99 { 100 this.pangoGlyphString = pangoGlyphString; 101 } 102 103 /** 104 */ 105 106 /** 107 * Create a new PangoGlyphString. 108 * Throws: ConstructionException GTK+ fails to create the object. 109 */ 110 public this () 111 { 112 // PangoGlyphString * pango_glyph_string_new (void); 113 auto p = pango_glyph_string_new(); 114 if(p is null) 115 { 116 throw new ConstructionException("null returned by pango_glyph_string_new()"); 117 } 118 this(cast(PangoGlyphString*) p); 119 } 120 121 /** 122 * Copy a glyph string and associated storage. 123 * Returns: the newly allocated PangoGlyphString, which should be freed with pango_glyph_string_free(), or NULL if string was NULL. 124 */ 125 public PgGlyphString copy() 126 { 127 // PangoGlyphString * pango_glyph_string_copy (PangoGlyphString *string); 128 auto p = pango_glyph_string_copy(pangoGlyphString); 129 130 if(p is null) 131 { 132 return null; 133 } 134 135 return ObjectG.getDObject!(PgGlyphString)(cast(PangoGlyphString*) p); 136 } 137 138 /** 139 * Resize a glyph string to the given length. 140 * Params: 141 * newLen = the new length of the string. 142 */ 143 public void setSize(int newLen) 144 { 145 // void pango_glyph_string_set_size (PangoGlyphString *string, gint new_len); 146 pango_glyph_string_set_size(pangoGlyphString, newLen); 147 } 148 149 /** 150 * Free a glyph string and associated storage. 151 */ 152 public void free() 153 { 154 // void pango_glyph_string_free (PangoGlyphString *string); 155 pango_glyph_string_free(pangoGlyphString); 156 } 157 158 /** 159 * Compute the logical and ink extents of a glyph string. See the documentation 160 * for pango_font_get_glyph_extents() for details about the interpretation 161 * of the rectangles. 162 * Params: 163 * font = a PangoFont 164 * inkRect = rectangle used to store the extents of the glyph string 165 * as drawn or NULL to indicate that the result is not needed. [out][allow-none] 166 * logicalRect = rectangle used to store the logical extents of the 167 * glyph string or NULL to indicate that the result is not needed. [out][allow-none] 168 */ 169 public void extents(PgFont font, PangoRectangle* inkRect, PangoRectangle* logicalRect) 170 { 171 // void pango_glyph_string_extents (PangoGlyphString *glyphs, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect); 172 pango_glyph_string_extents(pangoGlyphString, (font is null) ? null : font.getPgFontStruct(), inkRect, logicalRect); 173 } 174 175 /** 176 * Computes the extents of a sub-portion of a glyph string. The extents are 177 * relative to the start of the glyph string range (the origin of their 178 * coordinate system is at the start of the range, not at the start of the entire 179 * glyph string). 180 * Params: 181 * start = start index 182 * end = end index (the range is the set of bytes with 183 * indices such that start <= index < end) 184 * font = a PangoFont 185 * inkRect = rectangle used to store the 186 * extents of the glyph string range as drawn or NULL to 187 * indicate that the result is not needed. [out caller-allocates] 188 * logicalRect = rectangle used to store the 189 * logical extents of the glyph string range or NULL to 190 * indicate that the result is not needed. [out caller-allocates] 191 */ 192 public void extentsRange(int start, int end, PgFont font, PangoRectangle* inkRect, PangoRectangle* logicalRect) 193 { 194 // void pango_glyph_string_extents_range (PangoGlyphString *glyphs, int start, int end, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect); 195 pango_glyph_string_extents_range(pangoGlyphString, start, end, (font is null) ? null : font.getPgFontStruct(), inkRect, logicalRect); 196 } 197 198 /** 199 * Computes the logical width of the glyph string as can also be computed 200 * using pango_glyph_string_extents(). However, since this only computes the 201 * width, it's much faster. This is in fact only a convenience function that 202 * computes the sum of geometry.width for each glyph in the glyphs. 203 * Since 1.14 204 * Returns: the logical width of the glyph string. 205 */ 206 public int getWidth() 207 { 208 // int pango_glyph_string_get_width (PangoGlyphString *glyphs); 209 return pango_glyph_string_get_width(pangoGlyphString); 210 } 211 212 /** 213 * Converts from character position to x position. (X position 214 * is measured from the left edge of the run). Character positions 215 * are computed by dividing up each cluster into equal portions. 216 * Params: 217 * text = the text for the run 218 * length = the number of bytes (not characters) in text. 219 * analysis = the analysis information return from pango_itemize() 220 * index = the byte index within text 221 * trailing = whether we should compute the result for the beginning (FALSE) 222 * or end (TRUE) of the character. 223 * xPos = location to store result. [out] 224 */ 225 public void indexToX(string text, int length, PangoAnalysis* analysis, int index, int trailing, out int xPos) 226 { 227 // void pango_glyph_string_index_to_x (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int index_, gboolean trailing, int *x_pos); 228 pango_glyph_string_index_to_x(pangoGlyphString, Str.toStringz(text), length, analysis, index, trailing, &xPos); 229 } 230 231 /** 232 * Convert from x offset to character position. Character positions 233 * are computed by dividing up each cluster into equal portions. 234 * In scripts where positioning within a cluster is not allowed 235 * (such as Thai), the returned value may not be a valid cursor 236 * position; the caller must combine the result with the logical 237 * attributes for the text to compute the valid cursor position. 238 * Params: 239 * text = the text for the run 240 * length = the number of bytes (not characters) in text. 241 * analysis = the analysis information return from pango_itemize() 242 * xPos = the x offset (in Pango units) 243 * index = location to store calculated byte index within text. [out] 244 * trailing = location to store a boolean indicating 245 * whether the user clicked on the leading or trailing 246 * edge of the character. [out] 247 */ 248 public void xToIndex(string text, int length, PangoAnalysis* analysis, int xPos, out int index, out int trailing) 249 { 250 // void pango_glyph_string_x_to_index (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int x_pos, int *index_, int *trailing); 251 pango_glyph_string_x_to_index(pangoGlyphString, Str.toStringz(text), length, analysis, xPos, &index, &trailing); 252 } 253 254 /** 255 * Given a PangoGlyphString resulting from pango_shape() and the corresponding 256 * text, determine the screen width corresponding to each character. When 257 * multiple characters compose a single cluster, the width of the entire 258 * cluster is divided equally among the characters. 259 * See also pango_glyph_item_get_logical_widths(). 260 * Params: 261 * text = the text corresponding to the glyphs 262 * length = the length of text, in bytes 263 * embeddingLevel = the embedding level of the string 264 * logicalWidths = an array whose length is the number of 265 * characters in text (equal to g_utf8_strlen (text, 266 * length) unless text has NUL bytes) to be filled in 267 * with the resulting character widths. [array] 268 */ 269 public void getLogicalWidths(string text, int length, int embeddingLevel, int* logicalWidths) 270 { 271 // void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs, const char *text, int length, int embedding_level, int *logical_widths); 272 pango_glyph_string_get_logical_widths(pangoGlyphString, Str.toStringz(text), length, embeddingLevel, logicalWidths); 273 } 274 }