I've no idea here...
[gtkD.git] / src / pango / PgGlyphString.d
blob16564f8837ab0f61c75ac6090fe03758ac0f02ea
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = pango-Glyph-Storage.html
26 * outPack = pango
27 * outFile = PgGlyphString
28 * strct = PangoGlyphString
29 * realStrct=
30 * ctorStrct=
31 * clss = PgGlyphString
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - pango_glyph_string_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.ListSG
45 * - pango.PgContext
46 * - pango.PgItem
47 * - pango.PgLayout
48 * - pango.PgFontDescription
49 * - pango.PgFontMetrics
50 * - pango.PgFontFamily
51 * - pango.PgFontFace
52 * - pango.PgFontMap
53 * - pango.PgFontsetSimple
54 * - pango.PgAttribute
55 * - pango.PgAttributeList
56 * - pango.PgLanguage
57 * - pango.PgTabArray
58 * - pango.PgLayout
59 * - pango.PgLayoutIter
60 * - pango.PgScriptIter
61 * - glib.Str
62 * structWrap:
63 * - GSList* -> ListSG
64 * - PangoAttribute* -> PgAttribute
65 * - PangoAttributeList* -> PgAttributeList
66 * - PangoContext* -> PgContext
67 * - PangoFontDescription* -> PgFontDescription
68 * - PangoFontFace* -> PgFontFace
69 * - PangoFontFamily* -> PgFontFamily
70 * - PangoFontMap* -> PgFontMap
71 * - PangoFontMetrics* -> PgFontMetrics
72 * - PangoFontsetSimple* -> PgFontsetSimple
73 * - PangoItem* -> PgItem
74 * - PangoLanguage* -> PgLanguage
75 * - PangoLayout* -> PgLayout
76 * - PangoLayoutIter* -> PgLayoutIter
77 * - PangoScriptIter* -> PgScriptIter
78 * - PangoTabArray* -> PgTabArray
79 * local aliases:
82 module pango.PgGlyphString;
84 private import pango.pangotypes;
86 private import lib.pango;
88 private import glib.ListSG;
89 private import pango.PgContext;
90 private import pango.PgItem;
91 private import pango.PgLayout;
92 private import pango.PgFontDescription;
93 private import pango.PgFontMetrics;
94 private import pango.PgFontFamily;
95 private import pango.PgFontFace;
96 private import pango.PgFontMap;
97 private import pango.PgFontsetSimple;
98 private import pango.PgAttribute;
99 private import pango.PgAttributeList;
100 private import pango.PgLanguage;
101 private import pango.PgTabArray;
102 private import pango.PgLayout;
103 private import pango.PgLayoutIter;
104 private import pango.PgScriptIter;
105 private import glib.Str;
108 * Description
109 * pango_shape() produces a string of glyphs which
110 * can be measured or drawn to the screen. The following
111 * structures are used to store information about
112 * glyphs.
114 public class PgGlyphString
117 /** the main Gtk struct */
118 protected PangoGlyphString* pangoGlyphString;
121 public PangoGlyphString* getPgGlyphStringStruct()
123 return pangoGlyphString;
127 /** the main Gtk struct as a void* */
128 protected void* getStruct()
130 return cast(void*)pangoGlyphString;
134 * Sets our main struct and passes it to the parent class
136 public this (PangoGlyphString* pangoGlyphString)
138 this.pangoGlyphString = pangoGlyphString;
157 * Copies a PangoMatrix.
158 * matrix:
159 * a PangoMatrix, can be NULL
160 * Returns:
161 * the newly allocated PangoMatrix, which should
162 * be freed with pango_matrix_free(), or NULL if
163 * matrix was NULL.
164 * Since 1.6
166 public static PangoMatrix* pangoMatrixCopy(PangoMatrix* matrix)
168 // PangoMatrix* pango_matrix_copy (const PangoMatrix *matrix);
169 return pango_matrix_copy(matrix);
173 * Free a PangoMatrix created with pango_matrix_copy().
174 * Does nothing if matrix is NULL.
175 * matrix:
176 * a PangoMatrix, or NULL
177 * Since 1.6
179 public static void pangoMatrixFree(PangoMatrix* matrix)
181 // void pango_matrix_free (PangoMatrix *matrix);
182 pango_matrix_free(matrix);
186 * Changes the transformation represented by matrix to be the
187 * transformation given by first translating by (tx, ty)
188 * then applying the original transformation.
189 * matrix:
190 * a PangoMatrix
191 * tx:
192 * amount to translate in the X direction
193 * ty:
194 * amount to translate in the Y direction
195 * Since 1.6
197 public static void pangoMatrixTranslate(PangoMatrix* matrix, double tx, double ty)
199 // void pango_matrix_translate (PangoMatrix *matrix, double tx, double ty);
200 pango_matrix_translate(matrix, tx, ty);
204 * Changes the transformation represented by matrix to be the
205 * transformation given by first scaling by sx in the X direction
206 * and sy in the Y direction then applying the original
207 * transformation.
208 * matrix:
209 * a PangoMatrix
210 * scale_x:
211 * amount to scale by in X direction
212 * scale_y:
213 * amount to scale by in Y direction
214 * Since 1.6
216 public static void pangoMatrixScale(PangoMatrix* matrix, double scaleX, double scaleY)
218 // void pango_matrix_scale (PangoMatrix *matrix, double scale_x, double scale_y);
219 pango_matrix_scale(matrix, scaleX, scaleY);
223 * Changes the transformation represented by matrix to be the
224 * transformation given by first rotating by degrees degrees
225 * counter-clokwise then applying the original transformation.
226 * matrix:
227 * a PangoMatrix
228 * degrees:
229 * degrees to rotate counter-clockwise
230 * Since 1.6
232 public static void pangoMatrixRotate(PangoMatrix* matrix, double degrees)
234 // void pango_matrix_rotate (PangoMatrix *matrix, double degrees);
235 pango_matrix_rotate(matrix, degrees);
239 * Changes the transformation represented by matrix to be the
240 * transformation given by first applying transformation
241 * given by new_matrix then applying the original transformation.
242 * matrix:
243 * a PangoMatrix
244 * new_matrix:
245 * a PangoMatrix
246 * Since 1.6
248 public static void pangoMatrixConcat(PangoMatrix* matrix, PangoMatrix* newMatrix)
250 // void pango_matrix_concat (PangoMatrix *matrix, const PangoMatrix *new_matrix);
251 pango_matrix_concat(matrix, newMatrix);
255 * Returns the scale factor of a matrix on the height of the font.
256 * That is, the scale factor in the direction perpendicular to the
257 * vector that the X coordinate is mapped to.
258 * matrix:
259 * a PangoMatrix, may be NULL
260 * Returns:
261 * the scale factor of matrix on the height of the font,
262 * or 1.0 if matrix is NULL.
263 * Since 1.12
265 public static double pangoMatrixGetFontScaleFactor(PangoMatrix* matrix)
267 // double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix);
268 return pango_matrix_get_font_scale_factor(matrix);
272 * Finds the gravity that best matches the rotation component
273 * in a PangoMatrix.
274 * matrix:
275 * a PangoMatrix
276 * Returns:
277 * the gravity of matrix, which will never be
278 * PANGO_GRAVITY_AUTO, or PANGO_GRAVITY_SOUTH if matrix is NULL
279 * Since 1.16
281 public static PangoGravity pangoMatrixToGravity(PangoMatrix* matrix)
283 // PangoGravity pango_matrix_to_gravity (const PangoMatrix *matrix);
284 return pango_matrix_to_gravity(matrix);
299 * Create a new PangoGlyphString.
300 * Returns:
301 * the newly allocated PangoGlyphString, which
302 * should be freed with pango_glyph_string_free().
304 public this ()
306 // PangoGlyphString* pango_glyph_string_new (void);
307 this(cast(PangoGlyphString*)pango_glyph_string_new() );
311 * Copy a glyph string and associated storage.
312 * string:
313 * a PangoGlyphString.
314 * Returns:
315 * the newly allocated PangoGlyphString, which
316 * should be freed with pango_glyph_string_free().
318 public PangoGlyphString* copy()
320 // PangoGlyphString* pango_glyph_string_copy (PangoGlyphString *string);
321 return pango_glyph_string_copy(pangoGlyphString);
325 * Resize a glyph string to the given length.
326 * string:
327 * a PangoGlyphString.
328 * new_len:
329 * the new length of the string.
331 public void setSize(int newLen)
333 // void pango_glyph_string_set_size (PangoGlyphString *string, gint new_len);
334 pango_glyph_string_set_size(pangoGlyphString, newLen);
338 * Free a glyph string and associated storage.
339 * string:
340 * a PangoGlyphString.
342 public void free()
344 // void pango_glyph_string_free (PangoGlyphString *string);
345 pango_glyph_string_free(pangoGlyphString);
349 * Compute the logical and ink extents of a glyph string. See the documentation
350 * for pango_font_get_glyph_extents() for details about the interpretation
351 * of the rectangles.
352 * glyphs:
353 * a PangoGlyphString
354 * font:
355 * a PangoFont
356 * ink_rect:
357 * rectangle used to store the extents of the glyph string as drawn
358 * or NULL to indicate that the result is not needed.
359 * logical_rect:
360 * rectangle used to store the logical extents of the glyph string
361 * or NULL to indicate that the result is not needed.
363 public void extents(PangoFont* font, PangoRectangle* inkRect, PangoRectangle* logicalRect)
365 // void pango_glyph_string_extents (PangoGlyphString *glyphs, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
366 pango_glyph_string_extents(pangoGlyphString, font, inkRect, logicalRect);
370 * Computes the extents of a sub-portion of a glyph string. The extents are
371 * relative to the start of the glyph string range (the origin of their
372 * coordinate system is at the start of the range, not at the start of the entire
373 * glyph string).
374 * glyphs:
375 * a PangoGlyphString
376 * start:
377 * start index
378 * end:
379 * end index (the range is the set of bytes with
380 * indices such that start <= index < end)
381 * font:
382 * a PangoFont
383 * ink_rect:
384 * rectangle used to store the extents of the glyph string range as drawn
385 * or NULL to indicate that the result is not needed.
386 * logical_rect:
387 * rectangle used to store the logical extents of the glyph string range
388 * or NULL to indicate that the result is not needed.
390 public void extentsRange(int start, int end, PangoFont* font, PangoRectangle* inkRect, PangoRectangle* logicalRect)
392 // void pango_glyph_string_extents_range (PangoGlyphString *glyphs, int start, int end, PangoFont *font, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
393 pango_glyph_string_extents_range(pangoGlyphString, start, end, font, inkRect, logicalRect);
397 * Computes the logical width of the glyph string as can also be computed
398 * using pango_glyph_string_extents(). However, since this only computes the
399 * width, it's much faster. This is in fact only a convenience function that
400 * computes the sum of geometry.width for each glyph in the glyphs.
401 * glyphs:
402 * a PangoGlyphString
403 * Returns:
404 * the logical width of the glyph string.
405 * Since 1.14
407 public int getWidth()
409 // int pango_glyph_string_get_width (PangoGlyphString *glyphs);
410 return pango_glyph_string_get_width(pangoGlyphString);
414 * Converts from character position to x position. (X position
415 * is measured from the left edge of the run). Character positions
416 * are computed by dividing up each cluster into equal portions.
417 * glyphs:
418 * the glyphs return from pango_shape()
419 * text:
420 * the text for the run
421 * length:
422 * the number of bytes (not characters) in text.
423 * analysis:
424 * the analysis information return from pango_itemize()
425 * index_:
426 * the byte index within text
427 * trailing:
428 * whether we should compute the result for the beginning
429 * or end of the character.
430 * x_pos:
431 * location to store result
433 public void indexToX(char[] text, int length, PangoAnalysis* analysis, int index, int trailing, int* xPos)
435 // void pango_glyph_string_index_to_x (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int index_, gboolean trailing, int *x_pos);
436 pango_glyph_string_index_to_x(pangoGlyphString, Str.toStringz(text), length, analysis, index, trailing, xPos);
440 * Convert from x offset to character position. Character positions
441 * are computed by dividing up each cluster into equal portions.
442 * In scripts where positioning within a cluster is not allowed
443 * (such as Thai), the returned value may not be a valid cursor
444 * position; the caller must combine the result with the logical
445 * attributes for the text to compute the valid cursor position.
446 * glyphs:
447 * the glyphs return from pango_shape()
448 * text:
449 * the text for the run
450 * length:
451 * the number of bytes (not characters) in text.
452 * analysis:
453 * the analysis information return from pango_itemize()
454 * x_pos:
455 * the x offset (in PangoGlyphUnit)
456 * index_:
457 * location to store calculated byte index within text
458 * trailing:
459 * location to store a integer indicating where
460 * whether the user clicked on the leading or trailing
461 * edge of the character.
463 public void xToIndex(char[] text, int length, PangoAnalysis* analysis, int xPos, int* index, int* trailing)
465 // void pango_glyph_string_x_to_index (PangoGlyphString *glyphs, char *text, int length, PangoAnalysis *analysis, int x_pos, int *index_, int *trailing);
466 pango_glyph_string_x_to_index(pangoGlyphString, Str.toStringz(text), length, analysis, xPos, index, trailing);
470 * Given a PangoGlyphString resulting from pango_shape() and the corresponding
471 * text, determine the screen width corresponding to each character. When
472 * multiple characters compose a single cluster, the width of the entire
473 * cluster is divided equally among the characters.
474 * glyphs:
475 * a PangoGlyphString
476 * text:
477 * the text corresponding to the glyphs
478 * length:
479 * the length of text, in bytes
480 * embedding_level:
481 * the embedding level of the string
482 * logical_widths:
483 * an array whose length is g_utf8_strlen (text, length)
484 * to be filled in with the resulting character widths.
486 public void getLogicalWidths(char[] text, int length, int embeddingLevel, int* logicalWidths)
488 // void pango_glyph_string_get_logical_widths (PangoGlyphString *glyphs, const char *text, int length, int embedding_level, int *logical_widths);
489 pango_glyph_string_get_logical_widths(pangoGlyphString, Str.toStringz(text), length, embeddingLevel, logicalWidths);
493 * Modifies orig to cover only the text after split_index, and
494 * returns a new item that covers the text before split_index that
495 * used to be in orig. You can think of split_index as the length of
496 * the returned item. split_index may not be 0, and it may not be
497 * greater than or equal to the length of orig (that is, there must
498 * be at least one byte assigned to each item, you can't create a
499 * zero-length item).
500 * This function is similar in function to pango_item_split() (and uses
501 * it internally.)
502 * orig:
503 * a PangoItem
504 * text:
505 * text to which positions in orig apply
506 * split_index:
507 * byte index of position to split item, relative to the start of the item
508 * Returns:
509 * the newly allocated item representing text before
510 * split_index, which should be freed
511 * with pango_glyph_item_free().
512 * Since 1.2
514 public static PangoGlyphItem* pangoGlyphItemSplit(PangoGlyphItem* orig, char[] text, int splitIndex)
516 // PangoGlyphItem* pango_glyph_item_split (PangoGlyphItem *orig, const char *text, int split_index);
517 return pango_glyph_item_split(orig, Str.toStringz(text), splitIndex);
521 * Splits a shaped item (PangoGlyphItem) into multiple items based
522 * on an attribute list. The idea is that if you have attributes
523 * that don't affect shaping, such as color or underline, to avoid
524 * affecting shaping, you filter them out (pango_attr_list_filter()),
525 * apply the shaping process and then reapply them to the result using
526 * this function.
527 * All attributes that start or end inside a cluster are applied
528 * to that cluster; for instance, if half of a cluster is underlined
529 * and the other-half strikethough, then the cluster will end
530 * up with both underline and strikethrough attributes. In these
531 * cases, it may happen that item->extra_attrs for some of the
532 * result items can have multiple attributes of the same type.
533 * This function takes ownership of glyph_item; it will be reused
534 * as one of the elements in the list.
535 * glyph_item:
536 * a shaped item
537 * text:
538 * text that list applies to
539 * list:
540 * a PangoAttrList
541 * Returns:
542 * a list of glyph items resulting from splitting
543 * glyph_item. Free the elements using pango_glyph_item_free(),
544 * the list using g_slist_free().
545 * Since 1.2
547 public static ListSG pangoGlyphItemApplyAttrs(PangoGlyphItem* glyphItem, char[] text, PangoAttrList* list)
549 // GSList* pango_glyph_item_apply_attrs (PangoGlyphItem *glyph_item, const char *text, PangoAttrList *list);
550 return new ListSG( pango_glyph_item_apply_attrs(glyphItem, Str.toStringz(text), list) );
554 * Adds spacing between the graphemes of glyph_item to
555 * give the effect of typographic letter spacing.
556 * glyph_item:
557 * a PangoGlyphItem
558 * text:
559 * text that glyph_item corresponds to
560 * (glyph_item->item->offset is an offset from the
561 * start of text)
562 * log_attrs:
563 * logical attributes for the item (the
564 * first logical attribute refers to the position
565 * before the first character in the item)
566 * letter_spacing:
567 * amount of letter spacing to add
568 * in Pango units. May be negative, though too large
569 * negative values will give ugly results.
570 * Since 1.6
572 public static void pangoGlyphItemLetterSpace(PangoGlyphItem* glyphItem, char[] text, PangoLogAttr* logAttrs, int letterSpacing)
574 // void pango_glyph_item_letter_space (PangoGlyphItem *glyph_item, const char *text, PangoLogAttr *log_attrs, int letter_spacing);
575 pango_glyph_item_letter_space(glyphItem, Str.toStringz(text), logAttrs, letterSpacing);
579 * Frees a PangoGlyphItem and memory to which it points.
580 * glyph_item:
581 * a PangoGlyphItem
582 * Since 1.6
584 public static void pangoGlyphItemFree(PangoGlyphItem* glyphItem)
586 // void pango_glyph_item_free (PangoGlyphItem *glyph_item);
587 pango_glyph_item_free(glyphItem);