I've no idea here...
[gtkD.git] / src / pango / PgLayout.d
blob6eccffd78d0fc603e80d415098d2629a45ecf224
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-Layout-Objects.html
26 * outPack = pango
27 * outFile = PgLayout
28 * strct = PangoLayout
29 * realStrct=
30 * ctorStrct=
31 * clss = PgLayout
32 * interf =
33 * class Code: Yes
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - pango_layout_
40 * omit structs:
41 * omit prefixes:
42 * - pango_layout_iter_
43 * omit code:
44 * imports:
45 * - glib.ListSG
46 * - pango.PgContext
47 * - pango.PgContext
48 * - pango.PgItem
49 * - pango.PgLayout
50 * - pango.PgFontDescription
51 * - pango.PgFontMetrics
52 * - pango.PgFontFamily
53 * - pango.PgFontFace
54 * - pango.PgFontMap
55 * - pango.PgFontsetSimple
56 * - pango.PgAttribute
57 * - pango.PgAttributeList
58 * - pango.PgLanguage
59 * - pango.PgTabArray
60 * - pango.PgLayoutIter
61 * - pango.PgScriptIter
62 * - glib.Str
63 * structWrap:
64 * - GSList* -> ListSG
65 * - PangoAttribute* -> PgAttribute
66 * - PangoAttributeList* -> PgAttributeList
67 * - PangoContext* -> PgContext
68 * - PangoFontDescription* -> PgFontDescription
69 * - PangoFontFace* -> PgFontFace
70 * - PangoFontFamily* -> PgFontFamily
71 * - PangoFontMap* -> PgFontMap
72 * - PangoFontMetrics* -> PgFontMetrics
73 * - PangoFontsetSimple* -> PgFontsetSimple
74 * - PangoItem* -> PgItem
75 * - PangoLanguage* -> PgLanguage
76 * - PangoLayout* -> PgLayout
77 * - PangoLayoutIter* -> PgLayoutIter
78 * - PangoScriptIter* -> PgScriptIter
79 * - PangoTabArray* -> PgTabArray
80 * local aliases:
83 module pango.PgLayout;
85 private import pango.pangotypes;
87 private import lib.pango;
89 private import glib.ListSG;
90 private import pango.PgContext;
91 private import pango.PgContext;
92 private import pango.PgItem;
93 private import pango.PgLayout;
94 private import pango.PgFontDescription;
95 private import pango.PgFontMetrics;
96 private import pango.PgFontFamily;
97 private import pango.PgFontFace;
98 private import pango.PgFontMap;
99 private import pango.PgFontsetSimple;
100 private import pango.PgAttribute;
101 private import pango.PgAttributeList;
102 private import pango.PgLanguage;
103 private import pango.PgTabArray;
104 private import pango.PgLayoutIter;
105 private import pango.PgScriptIter;
106 private import glib.Str;
109 * Description
110 * While complete access to the layout capabilities of Pango is provided
111 * using the detailed interfaces for itemization and shaping, using
112 * that functionality directly involves writing a fairly large amount
113 * of code. The objects and functions in this section provide a
114 * high-level driver for formatting entire paragraphs of text
115 * at once.
117 public class PgLayout
120 /** the main Gtk struct */
121 protected PangoLayout* pangoLayout;
124 public PangoLayout* getPgLayoutStruct()
126 return pangoLayout;
130 /** the main Gtk struct as a void* */
131 protected void* getStruct()
133 return cast(void*)pangoLayout;
137 * Sets our main struct and passes it to the parent class
139 public this (PangoLayout* pangoLayout)
141 this.pangoLayout = pangoLayout;
145 * Sets the text of the layout.
146 * layout:
147 * a PangoLayout
148 * text:
149 * a UTF-8 string
151 public void setText(char[] text)
153 // void pango_layout_set_text (PangoLayout *layout, const char *text, int length);
154 pango_layout_set_text(pangoLayout, Str.toStringz(text), text.length);
164 * Create a new PangoLayout object with attributes initialized to
165 * default values for a particular PangoContext.
166 * context:
167 * a PangoContext
168 * Returns:
169 * the newly allocated PangoLayout, with a reference
170 * count of one, which should be freed with
171 * g_object_unref().
173 public this (PgContext context)
175 // PangoLayout* pango_layout_new (PangoContext *context);
176 this(cast(PangoLayout*)pango_layout_new((context is null) ? null : context.getPgContextStruct()) );
180 * Does a deep copy-by-value of the src layout. The attribute list,
181 * tab array, and text from the original layout are all copied by
182 * value.
183 * src:
184 * a PangoLayout
185 * Returns:
186 * the newly allocated PangoLayout, with a reference
187 * count of one, which should be freed with
188 * g_object_unref().
190 public PgLayout copy()
192 // PangoLayout* pango_layout_copy (PangoLayout *src);
193 return new PgLayout( pango_layout_copy(pangoLayout) );
197 * Retrieves the PangoContext used for this layout.
198 * layout:
199 * a PangoLayout
200 * Returns:
201 * the PangoContext for the layout. This does not
202 * have an additional refcount added, so if you want to keep
203 * a copy of this around, you must reference it yourself.
205 public PgContext getContext()
207 // PangoContext* pango_layout_get_context (PangoLayout *layout);
208 return new PgContext( pango_layout_get_context(pangoLayout) );
212 * Forces recomputation of any state in the PangoLayout that
213 * might depend on the layout's context. This function should
214 * be called if you make changes to the context subsequent
215 * to creating the layout.
216 * layout:
217 * a PangoLayout
219 public void contextChanged()
221 // void pango_layout_context_changed (PangoLayout *layout);
222 pango_layout_context_changed(pangoLayout);
226 * Sets the text of the layout.
227 * layout:
228 * a PangoLayout
229 * text:
230 * a valid UTF-8 string
231 * length:
232 * maximum length of text, in bytes. -1 indicates that
233 * the string is nul-terminated and the length should be
234 * calculated. The text will also be truncated on
235 * encountaring a nul-termination even when length is
236 * positive.
238 public void setText(char[] text, int length)
240 // void pango_layout_set_text (PangoLayout *layout, const char *text, int length);
241 pango_layout_set_text(pangoLayout, Str.toStringz(text), length);
245 * Gets the text in the layout. The returned text should not
246 * be freed or modified.
247 * layout:
248 * a PangoLayout
249 * Returns:
250 * the text in the layout.
252 public char[] getText()
254 // const char* pango_layout_get_text (PangoLayout *layout);
255 return Str.toString(pango_layout_get_text(pangoLayout) );
259 * Same as pango_layout_set_markup_with_accel(), but
260 * the markup text isn't scanned for accelerators.
261 * layout:
262 * a PangoLayout
263 * markup:
264 * marked-up text
265 * length:
266 * length of marked-up text in bytes, or -1 if markup is
267 * nul-terminated
269 public void setMarkup(char[] markup, int length)
271 // void pango_layout_set_markup (PangoLayout *layout, const char *markup, int length);
272 pango_layout_set_markup(pangoLayout, Str.toStringz(markup), length);
276 * Sets the layout text and attribute list from marked-up text (see
277 * markup format). Replaces
278 * the current text and attribute list.
279 * If accel_marker is nonzero, the given character will mark the
280 * character following it as an accelerator. For example, the accel
281 * marker might be an ampersand or underscore. All characters marked
282 * as an accelerator will receive a PANGO_UNDERLINE_LOW attribute,
283 * and the first character so marked will be returned in accel_char.
284 * Two accel_marker characters following each other produce a single
285 * literal accel_marker character.
286 * layout:
287 * a PangoLayout
288 * markup:
289 * marked-up text
290 * (see markup format)
291 * length:
292 * length of marked-up text in bytes, or -1 if markup is
293 * nul-terminated
294 * accel_marker:
295 * marker for accelerators in the text
296 * accel_char:
297 * return location for first located accelerator, or NULL
299 public void setMarkupWithAccel(char[] markup, int length, gunichar accelMarker, gunichar* accelChar)
301 // void pango_layout_set_markup_with_accel (PangoLayout *layout, const char *markup, int length, gunichar accel_marker, gunichar *accel_char);
302 pango_layout_set_markup_with_accel(pangoLayout, Str.toStringz(markup), length, accelMarker, accelChar);
306 * Sets the text attributes for a layout object.
307 * layout:
308 * a PangoLayout
309 * attrs:
310 * a PangoAttrList
312 public void setAttributes(PangoAttrList* attrs)
314 // void pango_layout_set_attributes (PangoLayout *layout, PangoAttrList *attrs);
315 pango_layout_set_attributes(pangoLayout, attrs);
319 * Gets the attribute list for the layout, if any.
320 * layout:
321 * a PangoLayout
322 * Returns:
323 * a PangoAttrList.
325 public PangoAttrList* getAttributes()
327 // PangoAttrList* pango_layout_get_attributes (PangoLayout *layout);
328 return pango_layout_get_attributes(pangoLayout);
332 * Sets the default font description for the layout. If no font
333 * description is set on the layout, the font description from
334 * the layout's context is used.
335 * layout:
336 * a PangoLayout
337 * desc:
338 * the new PangoFontDescription, or NULL to unset the
339 * current font description
341 public void setFontDescription(PgFontDescription desc)
343 // void pango_layout_set_font_description (PangoLayout *layout, const PangoFontDescription *desc);
344 pango_layout_set_font_description(pangoLayout, (desc is null) ? null : desc.getPgFontDescriptionStruct());
348 * Gets the font description for the layout, if any.
349 * layout:
350 * a PangoLayout
351 * Returns:
352 * a pointer to the layout's font description,
353 * or NULL if the font description from the layout's
354 * context is inherited. This value is owned by the layout
355 * and must not be modified or freed.
356 * Since 1.8
358 public PgFontDescription getFontDescription()
360 // const PangoFontDescription* pango_layout_get_font_description (PangoLayout *layout);
361 return new PgFontDescription( pango_layout_get_font_description(pangoLayout) );
365 * Sets the width to which the lines of the PangoLayout should wrap.
366 * layout:
367 * a PangoLayout.
368 * width:
369 * the desired width in Pango units, or -1 to indicate that no
370 * wrapping should be performed.
372 public void setWidth(int width)
374 // void pango_layout_set_width (PangoLayout *layout, int width);
375 pango_layout_set_width(pangoLayout, width);
379 * Gets the width to which the lines of the PangoLayout should wrap.
380 * layout:
381 * a PangoLayout
382 * Returns:
383 * the width, or -1 if no width set.
385 public int getWidth()
387 // int pango_layout_get_width (PangoLayout *layout);
388 return pango_layout_get_width(pangoLayout);
392 * Sets the wrap mode; the wrap mode only has effect if a width
393 * is set on the layout with pango_layout_set_width(). To turn off wrapping,
394 * set the width to -1.
395 * layout:
396 * a PangoLayout
397 * wrap:
398 * the wrap mode
400 public void setWrap(PangoWrapMode wrap)
402 // void pango_layout_set_wrap (PangoLayout *layout, PangoWrapMode wrap);
403 pango_layout_set_wrap(pangoLayout, wrap);
407 * Gets the wrap mode for the layout.
408 * layout:
409 * a PangoLayout
410 * Returns:
411 * active wrap mode.
413 public PangoWrapMode getWrap()
415 // PangoWrapMode pango_layout_get_wrap (PangoLayout *layout);
416 return pango_layout_get_wrap(pangoLayout);
422 * Sets the type of ellipsization being performed for layout.
423 * Depending on the ellipsization mode ellipsize text is
424 * removed from the start, middle, or end of lines so they
425 * fit within the width of layout set with pango_layout_set_width().
426 * If the layout contains characters such as newlines that
427 * force it to be layed out in multiple lines, then each line
428 * is ellipsized separately.
429 * layout:
430 * a PangoLayout
431 * ellipsize:
432 * the new ellipsization mode for layout
433 * Since 1.6
435 public void setEllipsize(PangoEllipsizeMode ellipsize)
437 // void pango_layout_set_ellipsize (PangoLayout *layout, PangoEllipsizeMode ellipsize);
438 pango_layout_set_ellipsize(pangoLayout, ellipsize);
442 * Gets the type of ellipsization being performed for layout.
443 * See pango_layout_set_ellipsize()
444 * layout:
445 * a PangoLayout
446 * Returns:
447 * the current ellipsization mode for layout.
448 * Since 1.6
450 public PangoEllipsizeMode getEllipsize()
452 // PangoEllipsizeMode pango_layout_get_ellipsize (PangoLayout *layout);
453 return pango_layout_get_ellipsize(pangoLayout);
459 * Sets the width in Pango units to indent each paragraph. A negative value
460 * of indent will produce a hanging indentation. That is, the first line will
461 * have the full width, and subsequent lines will be indented by the
462 * absolute value of indent.
463 * layout:
464 * a PangoLayout.
465 * indent:
466 * the amount by which to indent.
468 public void setIndent(int indent)
470 // void pango_layout_set_indent (PangoLayout *layout, int indent);
471 pango_layout_set_indent(pangoLayout, indent);
475 * Gets the paragraph indent width in Pango units. A negative value
476 * indicates a hanging indentation.
477 * layout:
478 * a PangoLayout
479 * Returns:
480 * the indent.
482 public int getIndent()
484 // int pango_layout_get_indent (PangoLayout *layout);
485 return pango_layout_get_indent(pangoLayout);
489 * Gets the amount of spacing in PangoGlyphUnit between the lines of the
490 * layout.
491 * layout:
492 * a PangoLayout
493 * Returns:
494 * the spacing.
496 public int getSpacing()
498 // int pango_layout_get_spacing (PangoLayout *layout);
499 return pango_layout_get_spacing(pangoLayout);
503 * Sets the amount of spacing in PangoGlyphUnit between the lines of the
504 * layout.
505 * layout:
506 * a PangoLayout.
507 * spacing:
508 * the amount of spacing
510 public void setSpacing(int spacing)
512 // void pango_layout_set_spacing (PangoLayout *layout, int spacing);
513 pango_layout_set_spacing(pangoLayout, spacing);
517 * Sets whether each complete line should be stretched to
518 * fill the entire width of the layout. This stretching is typically
519 * done by adding whitespace, but for some scripts (such as Arabic),
520 * the justification may be done in more complex ways, like extending
521 * the characters.
522 * Note that as of Pango-1.10, this functionality is not yet implemented.
523 * layout:
524 * a PangoLayout
525 * justify:
526 * whether the lines in the layout should be justified.
528 public void setJustify(int justify)
530 // void pango_layout_set_justify (PangoLayout *layout, gboolean justify);
531 pango_layout_set_justify(pangoLayout, justify);
535 * Gets whether each complete line should be stretched to fill the entire
536 * width of the layout.
537 * layout:
538 * a PangoLayout
539 * Returns:
540 * the justify.
542 public int getJustify()
544 // gboolean pango_layout_get_justify (PangoLayout *layout);
545 return pango_layout_get_justify(pangoLayout);
549 * Sets whether to calculate the bidirectional base direction
550 * for the layout according to the contents of the layout;
551 * when this flag is on (the default), then paragraphs in
552 * layout that begin with strong right-to-left characters
553 * (Arabic and Hebrew principally), will have right-to-left
554 * layout, paragraphs with letters from other scripts will
555 * have left-to-right layout. Paragraphs with only neutral
556 * characters get their direction from the surrounding paragraphs.
557 * When FALSE, the choice between left-to-right and
558 * right-to-left layout is done according to the base direction
559 * of the layout's PangoContext. (See pango_context_set_base_dir()).
560 * When the auto-computed direction of a paragraph differs from the
561 * base direction of the context, the interpretation of
562 * PANGO_ALIGN_LEFT and PANGO_ALIGN_RIGHT are swapped.
563 * layout:
564 * a PangoLayout
565 * auto_dir:
566 * if TRUE, compute the bidirectional base direction
567 * from the layout's contents.
568 * Since 1.4
570 public void setAutoDir(int autoDir)
572 // void pango_layout_set_auto_dir (PangoLayout *layout, gboolean auto_dir);
573 pango_layout_set_auto_dir(pangoLayout, autoDir);
577 * Gets whether to calculate the bidirectional base direction
578 * for the layout according to the contents of the layout.
579 * See pango_layout_set_auto_dir().
580 * layout:
581 * a PangoLayout
582 * Returns:
583 * TRUE if the bidirectional base direction
584 * is computed from the layout's contents, FALSE otherwise.
585 * Since 1.4
587 public int getAutoDir()
589 // gboolean pango_layout_get_auto_dir (PangoLayout *layout);
590 return pango_layout_get_auto_dir(pangoLayout);
594 * Sets the alignment for the layout: how partial lines are
595 * positioned within the horizontal space available.
596 * layout:
597 * a PangoLayout
598 * alignment:
599 * the alignment
601 public void setAlignment(PangoAlignment alignment)
603 // void pango_layout_set_alignment (PangoLayout *layout, PangoAlignment alignment);
604 pango_layout_set_alignment(pangoLayout, alignment);
608 * Gets the alignment for the layout: how partial lines are
609 * positioned within the horizontal space available.
610 * layout:
611 * a PangoLayout
612 * Returns:
613 * the alignment.
615 public PangoAlignment getAlignment()
617 // PangoAlignment pango_layout_get_alignment (PangoLayout *layout);
618 return pango_layout_get_alignment(pangoLayout);
622 * Sets the tabs to use for layout, overriding the default tabs
623 * (by default, tabs are every 8 spaces). If tabs is NULL, the default
624 * tabs are reinstated. tabs is copied into the layout; you must
625 * free your copy of tabs yourself.
626 * layout:
627 * a PangoLayout
628 * tabs:
629 * a PangoTabArray
631 public void setTabs(PgTabArray tabs)
633 // void pango_layout_set_tabs (PangoLayout *layout, PangoTabArray *tabs);
634 pango_layout_set_tabs(pangoLayout, (tabs is null) ? null : tabs.getPgTabArrayStruct());
638 * Gets the current PangoTabArray used by this layout. If no
639 * PangoTabArray has been set, then the default tabs are in use
640 * and NULL is returned. Default tabs are every 8 spaces.
641 * The return value should be freed with pango_tab_array_free().
642 * layout:
643 * a PangoLayout
644 * Returns:
645 * a copy of the tabs for this layout, or NULL.
647 public PgTabArray getTabs()
649 // PangoTabArray* pango_layout_get_tabs (PangoLayout *layout);
650 return new PgTabArray( pango_layout_get_tabs(pangoLayout) );
654 * If setting is TRUE, do not treat newlines and similar characters
655 * as paragraph separators; instead, keep all text in a single paragraph,
656 * and display a glyph for paragraph separator characters. Used when
657 * you want to allow editing of newlines on a single text line.
658 * layout:
659 * a PangoLayout
660 * setting:
661 * new setting
663 public void setSingleParagraphMode(int setting)
665 // void pango_layout_set_single_paragraph_mode (PangoLayout *layout, gboolean setting);
666 pango_layout_set_single_paragraph_mode(pangoLayout, setting);
670 * Obtains the value set by pango_layout_set_single_paragraph_mode().
671 * layout:
672 * a PangoLayout
673 * Returns:
674 * TRUE if the layout does not break paragraphs at
675 * paragraph separator characters, FALSE otherwise.
677 public int getSingleParagraphMode()
679 // gboolean pango_layout_get_single_paragraph_mode (PangoLayout *layout);
680 return pango_layout_get_single_paragraph_mode(pangoLayout);
686 * Retrieves an array of logical attributes for each character in
687 * the layout.
688 * layout:
689 * a PangoLayout
690 * attrs:
691 * location to store a pointer to an array of logical attributes
692 * This value must be freed with g_free().
693 * n_attrs:
694 * location to store the number of the attributes in the
695 * array. (The stored value will be one more than the total number
696 * of characters in the layout, since there need to be attributes
697 * corresponding to both the position before the first character
698 * and the position after the last character.)
700 public void getLogAttrs(PangoLogAttr** attrs, int* nAttrs)
702 // void pango_layout_get_log_attrs (PangoLayout *layout, PangoLogAttr **attrs, gint *n_attrs);
703 pango_layout_get_log_attrs(pangoLayout, attrs, nAttrs);
707 * Converts from an index within a PangoLayout to the onscreen position
708 * corresponding to the grapheme at that index, which is represented
709 * as rectangle. Note that pos->x is always the leading
710 * edge of the grapheme and pos->x + pos->width the trailing
711 * edge of the grapheme. If the directionality of the grapheme is right-to-left,
712 * then pos->width will be negative.
713 * layout:
714 * a PangoLayout
715 * index_:
716 * byte index within layout
717 * pos:
718 * rectangle in which to store the position of the grapheme
720 public void indexToPos(int index, PangoRectangle* pos)
722 // void pango_layout_index_to_pos (PangoLayout *layout, int index_, PangoRectangle *pos);
723 pango_layout_index_to_pos(pangoLayout, index, pos);
727 * Converts from byte index_ within the layout to line and X position.
728 * (X position is measured from the left edge of the line)
729 * layout:
730 * a PangoLayout
731 * index_:
732 * the byte index of a grapheme within the layout.
733 * trailing:
734 * an integer indicating the edge of the grapheme to retrieve the
735 * position of. If 0, the trailing edge of the grapheme, if > 0,
736 * the leading of the grapheme.
737 * line:
738 * location to store resulting line index. (which will
739 * between 0 and pango_layout_get_line_count(layout) - 1)
740 * x_pos:
741 * location to store resulting position within line
742 * (PANGO_SCALE units per device unit)
744 public void indexToLineX(int index, int trailing, int* line, int* xPos)
746 // void pango_layout_index_to_line_x (PangoLayout *layout, int index_, gboolean trailing, int *line, int *x_pos);
747 pango_layout_index_to_line_x(pangoLayout, index, trailing, line, xPos);
751 * Converts from X and Y position within a layout to the byte
752 * index to the character at that logical position. If the
753 * Y position is not inside the layout, the closest position is chosen
754 * (the position will be clamped inside the layout). If the
755 * X position is not within the layout, then the start or the
756 * end of the line is chosen as described for pango_layout_x_to_index().
757 * If either the X or Y positions were not inside the layout, then the
758 * function returns FALSE; on an exact hit, it returns TRUE.
759 * layout:
760 * a PangoLayout
761 * x:
762 * the X offset (in PangoGlyphUnit)
763 * from the left edge of the layout.
764 * y:
765 * the Y offset (in PangoGlyphUnit)
766 * from the top edge of the layout
767 * index_:
768 * location to store calculated byte index
769 * trailing:
770 * location to store a integer indicating where
771 * in the grapheme the user clicked. It will either
772 * be zero, or the number of characters in the
773 * grapheme. 0 represents the trailing edge of the grapheme.
774 * Returns:
775 * TRUE if the coordinates were inside text, FALSE otherwise.
777 public int xyToIndex(int x, int y, int* index, int* trailing)
779 // gboolean pango_layout_xy_to_index (PangoLayout *layout, int x, int y, int *index_, int *trailing);
780 return pango_layout_xy_to_index(pangoLayout, x, y, index, trailing);
784 * Given an index within a layout, determines the positions that of the
785 * strong and weak cursors if the insertion point is at that
786 * index. The position of each cursor is stored as a zero-width
787 * rectangle. The strong cursor location is the location where
788 * characters of the directionality equal to the base direction of the
789 * layout are inserted. The weak cursor location is the location
790 * where characters of the directionality opposite to the base
791 * direction of the layout are inserted.
792 * layout:
793 * a PangoLayout
794 * index_:
795 * the byte index of the cursor
796 * strong_pos:
797 * location to store the strong cursor position (may be NULL)
798 * weak_pos:
799 * location to store the weak cursor position (may be NULL)
801 public void getCursorPos(int index, PangoRectangle* strongPos, PangoRectangle* weakPos)
803 // void pango_layout_get_cursor_pos (PangoLayout *layout, int index_, PangoRectangle *strong_pos, PangoRectangle *weak_pos);
804 pango_layout_get_cursor_pos(pangoLayout, index, strongPos, weakPos);
808 * Computes a new cursor position from an old position and
809 * a count of positions to move visually. If direction is positive,
810 * then the new strong cursor position will be one position
811 * to the right of the old cursor position. If direction is negative,
812 * then the new strong cursor position will be one position
813 * to the left of the old cursor position.
814 * In the presence of bidirectional text, the correspondence
815 * between logical and visual order will depend on the direction
816 * of the current run, and there may be jumps when the cursor
817 * is moved off of the end of a run.
818 * Motion here is in cursor positions, not in characters, so a
819 * single call to pango_layout_move_cursor_visually() may move the
820 * cursor over multiple characters when multiple characters combine
821 * to form a single grapheme.
822 * layout:
823 * a PangoLayout.
824 * strong:
825 * whether the moving cursor is the strong cursor or the
826 * weak cursor. The strong cursor is the cursor corresponding
827 * to text insertion in the base direction for the layout.
828 * old_index:
829 * the byte index of the grapheme for the old index
830 * old_trailing:
831 * if 0, the cursor was at the trailing edge of the
832 * grapheme indicated by old_index, if > 0, the cursor
833 * was at the leading edge.
834 * direction:
835 * direction to move cursor. A negative
836 * value indicates motion to the left.
837 * new_index:
838 * location to store the new cursor byte index. A value of -1
839 * indicates that the cursor has been moved off the beginning
840 * of the layout. A value of G_MAXINT indicates that
841 * the cursor has been moved off the end of the layout.
842 * new_trailing:
843 * number of characters to move forward from the location returned
844 * for new_index to get the position where the cursor should
845 * be displayed. This allows distinguishing the position at
846 * the beginning of one line from the position at the end
847 * of the preceding line. new_index is always on the line
848 * where the cursor should be displayed.
850 public void moveCursorVisually(int strong, int oldIndex, int oldTrailing, int direction, int* newIndex, int* newTrailing)
852 // void pango_layout_move_cursor_visually (PangoLayout *layout, gboolean strong, int old_index, int old_trailing, int direction, int *new_index, int *new_trailing);
853 pango_layout_move_cursor_visually(pangoLayout, strong, oldIndex, oldTrailing, direction, newIndex, newTrailing);
857 * Computes the logical and ink extents of layout. Logical extents
858 * are usually what you want for positioning things. Note that both extents
859 * may have non-zero x and y. You may want to use those to offset where you
860 * render the layout. Not doing that is a very typical bug that shows up as
861 * right-to-left layouts not being correctly positioned in a layout with
862 * a set width.
863 * The extents are given in layout coordinates and in Pango units; layout
864 * coordinates begin at the top left corner of the layout.
865 * layout:
866 * a PangoLayout
867 * ink_rect:
868 * rectangle used to store the extents of the layout as drawn
869 * or NULL to indicate that the result is not needed.
870 * logical_rect:
871 * rectangle used to store the logical extents of the layout
872 * or NULL to indicate that the result is not needed.
874 public void getExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
876 // void pango_layout_get_extents (PangoLayout *layout, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
877 pango_layout_get_extents(pangoLayout, inkRect, logicalRect);
881 * Computes the logical and ink extents of layout in device units.
882 * See pango_layout_get_extents(); this function just calls
883 * pango_layout_get_extents() and then converts the extents to
884 * device units using the PANGO_SCALE factor.
885 * layout:
886 * a PangoLayout
887 * ink_rect:
888 * rectangle used to store the extents of the layout as drawn
889 * or NULL to indicate that the result is not needed.
890 * logical_rect:
891 * rectangle used to store the logical extents of the
892 * layout or NULL to indicate that the result is not needed.
894 public void getPixelExtents(PangoRectangle* inkRect, PangoRectangle* logicalRect)
896 // void pango_layout_get_pixel_extents (PangoLayout *layout, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
897 pango_layout_get_pixel_extents(pangoLayout, inkRect, logicalRect);
901 * Determines the logical width and height of a PangoLayout
902 * in Pango units. (device units scaled by PANGO_SCALE). This
903 * is simply a convenience function around pango_layout_get_extents().
904 * layout:
905 * a PangoLayout
906 * width:
907 * location to store the logical width, or NULL
908 * height:
909 * location to store the logical height, or NULL
911 public void getSize(int* width, int* height)
913 // void pango_layout_get_size (PangoLayout *layout, int *width, int *height);
914 pango_layout_get_size(pangoLayout, width, height);
918 * Determines the logical width and height of a PangoLayout
919 * in device units. (pango_layout_get_size() returns the width
920 * and height scaled by PANGO_SCALE.) This
921 * is simply a convenience function around
922 * pango_layout_get_pixel_extents().
923 * layout:
924 * a PangoLayout
925 * width:
926 * location to store the logical width, or NULL
927 * height:
928 * location to store the logical height, or NULL
930 public void getPixelSize(int* width, int* height)
932 // void pango_layout_get_pixel_size (PangoLayout *layout, int *width, int *height);
933 pango_layout_get_pixel_size(pangoLayout, width, height);
937 * Retrieves the count of lines for the layout.
938 * layout:
939 * PangoLayout
940 * Returns:
941 * the line count.
943 public int getLineCount()
945 // int pango_layout_get_line_count (PangoLayout *layout);
946 return pango_layout_get_line_count(pangoLayout);
950 * Retrieves a particular line from a PangoLayout.
951 * layout:
952 * a PangoLayout
953 * line:
954 * the index of a line, which must be between 0 and
955 * pango_layout_get_line_count(layout) - 1, inclusive.
956 * Returns:
957 * the requested PangoLayoutLine, or NULL if the
958 * index is out of range. This layout line can
959 * be ref'ed and retained, but will become invalid
960 * if changes are made to the PangoLayout.
962 public PangoLayoutLine* getLine(int line)
964 // PangoLayoutLine* pango_layout_get_line (PangoLayout *layout, int line);
965 return pango_layout_get_line(pangoLayout, line);
969 * Returns the lines of the layout as a list.
970 * layout:
971 * a PangoLayout
972 * Returns:
973 * a GSList containing the lines in the layout. This
974 * points to internal data of the PangoLayout and must be used with
975 * care. It will become invalid on any change to the layout's
976 * text or properties.
978 public ListSG getLines()
980 // GSList* pango_layout_get_lines (PangoLayout *layout);
981 return new ListSG( pango_layout_get_lines(pangoLayout) );
985 * Returns an iterator to iterate over the visual extents of the layout.
986 * layout:
987 * a PangoLayout
988 * Returns:
989 * the new PangoLayoutIter that should be freed using
990 * pango_layout_iter_free().
992 public PgLayoutIter getIter()
994 // PangoLayoutIter* pango_layout_get_iter (PangoLayout *layout);
995 return new PgLayoutIter( pango_layout_get_iter(pangoLayout) );
1017 * Increase the reference count of a PangoLayoutLine by one.
1018 * line:
1019 * a PangoLayoutLine
1020 * Returns:
1021 * the line passed in.
1022 * Since 1.10
1024 public static PangoLayoutLine* lineRef(PangoLayoutLine* line)
1026 // PangoLayoutLine* pango_layout_line_ref (PangoLayoutLine *line);
1027 return pango_layout_line_ref(line);
1031 * Decrease the reference count of a PangoLayoutLine by one.
1032 * If the result is zero, the line and all associated memory
1033 * will be freed.
1034 * line:
1035 * a PangoLayoutLine
1037 public static void lineUnref(PangoLayoutLine* line)
1039 // void pango_layout_line_unref (PangoLayoutLine *line);
1040 pango_layout_line_unref(line);
1044 * Computes the logical and ink extents of a layout line. See
1045 * pango_font_get_glyph_extents() for details about the interpretation
1046 * of the rectangles.
1047 * line:
1048 * a PangoLayoutLine
1049 * ink_rect:
1050 * rectangle used to store the extents of the glyph string
1051 * as drawn, or NULL
1052 * logical_rect:
1053 * rectangle used to store the logical extents of the glyph
1054 * string, or NULL
1056 public static void lineGetExtents(PangoLayoutLine* line, PangoRectangle* inkRect, PangoRectangle* logicalRect)
1058 // void pango_layout_line_get_extents (PangoLayoutLine *line, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
1059 pango_layout_line_get_extents(line, inkRect, logicalRect);
1063 * Computes the logical and ink extents of a layout line. See
1064 * pango_font_get_glyph_extents() for details about the interpretation
1065 * of the rectangles. The returned rectangles are in device units, as
1066 * opposed to pango_layout_line_get_extents(), which returns the extents in
1067 * PangoGlyphUnit.
1068 * layout_line:
1069 * a PangoLayoutLine
1070 * ink_rect:
1071 * rectangle used to store the extents of the glyph string
1072 * as drawn, or NULL
1073 * logical_rect:
1074 * rectangle used to store the logical extents of the glyph
1075 * string, or NULL
1077 public static void lineGetPixelExtents(PangoLayoutLine* layoutLine, PangoRectangle* inkRect, PangoRectangle* logicalRect)
1079 // void pango_layout_line_get_pixel_extents (PangoLayoutLine *layout_line, PangoRectangle *ink_rect, PangoRectangle *logical_rect);
1080 pango_layout_line_get_pixel_extents(layoutLine, inkRect, logicalRect);
1084 * Converts an index within a line to a X position.
1085 * line:
1086 * a PangoLayoutLine
1087 * index_:
1088 * byte offset of a grapheme within the layout
1089 * trailing:
1090 * an integer indicating the edge of the grapheme to retrieve
1091 * the position of. If 0, the trailing edge of the grapheme,
1092 * if > 0, the leading of the grapheme.
1093 * x_pos:
1094 * location to store the x_offset (in PangoGlyphUnit)
1096 public static void lineIndexToX(PangoLayoutLine* line, int index, int trailing, int* xPos)
1098 // void pango_layout_line_index_to_x (PangoLayoutLine *line, int index_, gboolean trailing, int *x_pos);
1099 pango_layout_line_index_to_x(line, index, trailing, xPos);
1103 * Converts from x offset to the byte index of the corresponding
1104 * character within the text of the layout. If x_pos is outside the line,
1105 * index_ and trailing will point to the very first or very last position
1106 * in the line. This determination is based on the resolved direction
1107 * of the paragraph; for example, if the resolved direction is
1108 * right-to-left, then an X position to the right of the line (after it)
1109 * results in 0 being stored in index_ and trailing. An X position to the
1110 * left of the line results in index_ pointing to the (logical) last
1111 * grapheme in the line and trailing being set to the number of characters
1112 * in that grapheme. The reverse is true for a left-to-right line.
1113 * line:
1114 * a PangoLayoutLine
1115 * x_pos:
1116 * the X offset (in PangoGlyphUnit)
1117 * from the left edge of the line.
1118 * index_:
1119 * location to store calculated byte index for
1120 * the grapheme in which the user clicked.
1121 * trailing:
1122 * location to store a integer indicating where
1123 * in the grapheme the user clicked. It will either
1124 * be zero, or the number of characters in the
1125 * grapheme. 0 represents the trailing edge of the grapheme.
1126 * Returns:
1127 * FALSE if x_pos was outside the line, TRUE if inside
1129 public static int lineXToIndex(PangoLayoutLine* line, int xPos, int* index, int* trailing)
1131 // gboolean pango_layout_line_x_to_index (PangoLayoutLine *line, int x_pos, int *index_, int *trailing);
1132 return pango_layout_line_x_to_index(line, xPos, index, trailing);
1136 * Gets a list of visual ranges corresponding to a given logical range.
1137 * This list is not necessarily minimal - there may be consecutive
1138 * ranges which are adjacent. The ranges will be sorted from left to
1139 * right. The ranges are with respect to the left edge of the entire
1140 * layout, not with respect to the line.
1141 * line:
1142 * a PangoLayoutLine
1143 * start_index:
1144 * Start byte index of the logical range. If this value
1145 * is less than the start index for the line, then
1146 * the first range will extend all the way to the leading
1147 * edge of the layout. Otherwise it will start at the
1148 * leading edge of the first character.
1149 * end_index:
1150 * Ending byte index of the logical range. If this value
1151 * is greater than the end index for the line, then
1152 * the last range will extend all the way to the trailing
1153 * edge of the layout. Otherwise, it will end at the
1154 * trailing edge of the last character.
1155 * ranges:
1156 * location to store a pointer to an array of ranges.
1157 * The array will be of length 2*n_ranges,
1158 * with each range starting at (*ranges)[2*n]
1159 * and of width (*ranges)[2*n + 1] - (*ranges)[2*n].
1160 * This array must be freed with g_free(). The coordinates are relative
1161 * to the layout and are in PangoGlyphUnit.
1162 * n_ranges:
1163 * The number of ranges stored in ranges.
1165 public static void lineGetXRanges(PangoLayoutLine* line, int startIndex, int endIndex, int** ranges, int* nRanges)
1167 // void pango_layout_line_get_x_ranges (PangoLayoutLine *line, int start_index, int end_index, int **ranges, int *n_ranges);
1168 pango_layout_line_get_x_ranges(line, startIndex, endIndex, ranges, nRanges);