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.PgLayout;
26 
27 private import glib.ConstructionException;
28 private import glib.ListSG;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 public  import gtkc.pangotypes;
32 private import pango.PgAttributeList;
33 private import pango.PgContext;
34 private import pango.PgFontDescription;
35 private import pango.PgLayoutIter;
36 private import pango.PgLayoutLine;
37 private import pango.PgTabArray;
38 private import pango.c.functions;
39 public  import pango.c.types;
40 
41 
42 /**
43  * The #PangoLayout structure represents an entire paragraph
44  * of text. It is initialized with a #PangoContext, UTF-8 string
45  * and set of attributes for that string. Once that is done, the
46  * set of formatted lines can be extracted from the object,
47  * the layout can be rendered, and conversion between logical
48  * character positions within the layout's text, and the physical
49  * position of the resulting glyphs can be made.
50  * 
51  * There are also a number of parameters to adjust the formatting
52  * of a #PangoLayout, which are illustrated in <xref linkend="parameters"/>.
53  * It is possible, as well, to ignore the 2-D setup, and simply
54  * treat the results of a #PangoLayout as a list of lines.
55  * 
56  * <figure id="parameters">
57  * <title>Adjustable parameters for a PangoLayout</title>
58  * <graphic fileref="layout.gif" format="GIF"></graphic>
59  * </figure>
60  * 
61  * The #PangoLayout structure is opaque, and has no user-visible
62  * fields.
63  */
64 public class PgLayout : ObjectG
65 {
66 	/** the main Gtk struct */
67 	protected PangoLayout* pangoLayout;
68 
69 	/** Get the main Gtk struct */
70 	public PangoLayout* getPgLayoutStruct(bool transferOwnership = false)
71 	{
72 		if (transferOwnership)
73 			ownedRef = false;
74 		return pangoLayout;
75 	}
76 
77 	/** the main Gtk struct as a void* */
78 	protected override void* getStruct()
79 	{
80 		return cast(void*)pangoLayout;
81 	}
82 
83 	/**
84 	 * Sets our main struct and passes it to the parent class.
85 	 */
86 	public this (PangoLayout* pangoLayout, bool ownedRef = false)
87 	{
88 		this.pangoLayout = pangoLayout;
89 		super(cast(GObject*)pangoLayout, ownedRef);
90 	}
91 
92 
93 	/** */
94 	public static GType getType()
95 	{
96 		return pango_layout_get_type();
97 	}
98 
99 	/**
100 	 * Create a new #PangoLayout object with attributes initialized to
101 	 * default values for a particular #PangoContext.
102 	 *
103 	 * Params:
104 	 *     context = a #PangoContext
105 	 *
106 	 * Returns: the newly allocated #PangoLayout, with a reference
107 	 *     count of one, which should be freed with
108 	 *     g_object_unref().
109 	 *
110 	 * Throws: ConstructionException GTK+ fails to create the object.
111 	 */
112 	public this(PgContext context)
113 	{
114 		auto p = pango_layout_new((context is null) ? null : context.getPgContextStruct());
115 
116 		if(p is null)
117 		{
118 			throw new ConstructionException("null returned by new");
119 		}
120 
121 		this(cast(PangoLayout*) p, true);
122 	}
123 
124 	/**
125 	 * Forces recomputation of any state in the #PangoLayout that
126 	 * might depend on the layout's context. This function should
127 	 * be called if you make changes to the context subsequent
128 	 * to creating the layout.
129 	 */
130 	public void contextChanged()
131 	{
132 		pango_layout_context_changed(pangoLayout);
133 	}
134 
135 	/**
136 	 * Does a deep copy-by-value of the @src layout. The attribute list,
137 	 * tab array, and text from the original layout are all copied by
138 	 * value.
139 	 *
140 	 * Returns: the newly allocated #PangoLayout,
141 	 *     with a reference count of one, which should be freed
142 	 *     with g_object_unref().
143 	 */
144 	public PgLayout copy()
145 	{
146 		auto p = pango_layout_copy(pangoLayout);
147 
148 		if(p is null)
149 		{
150 			return null;
151 		}
152 
153 		return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p, true);
154 	}
155 
156 	/**
157 	 * Gets the alignment for the layout: how partial lines are
158 	 * positioned within the horizontal space available.
159 	 *
160 	 * Returns: the alignment.
161 	 */
162 	public PangoAlignment getAlignment()
163 	{
164 		return pango_layout_get_alignment(pangoLayout);
165 	}
166 
167 	/**
168 	 * Gets the attribute list for the layout, if any.
169 	 *
170 	 * Returns: a #PangoAttrList.
171 	 */
172 	public PgAttributeList getAttributes()
173 	{
174 		auto p = pango_layout_get_attributes(pangoLayout);
175 
176 		if(p is null)
177 		{
178 			return null;
179 		}
180 
181 		return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p);
182 	}
183 
184 	/**
185 	 * Gets whether to calculate the bidirectional base direction
186 	 * for the layout according to the contents of the layout.
187 	 * See pango_layout_set_auto_dir().
188 	 *
189 	 * Returns: %TRUE if the bidirectional base direction
190 	 *     is computed from the layout's contents, %FALSE otherwise.
191 	 *
192 	 * Since: 1.4
193 	 */
194 	public bool getAutoDir()
195 	{
196 		return pango_layout_get_auto_dir(pangoLayout) != 0;
197 	}
198 
199 	/**
200 	 * Gets the Y position of baseline of the first line in @layout.
201 	 *
202 	 * Returns: baseline of first line, from top of @layout.
203 	 *
204 	 * Since: 1.22
205 	 */
206 	public int getBaseline()
207 	{
208 		return pango_layout_get_baseline(pangoLayout);
209 	}
210 
211 	/**
212 	 * Returns the number of Unicode characters in the
213 	 * the text of @layout.
214 	 *
215 	 * Returns: the number of Unicode characters
216 	 *     in the text of @layout
217 	 *
218 	 * Since: 1.30
219 	 */
220 	public int getCharacterCount()
221 	{
222 		return pango_layout_get_character_count(pangoLayout);
223 	}
224 
225 	/**
226 	 * Retrieves the #PangoContext used for this layout.
227 	 *
228 	 * Returns: the #PangoContext for the layout.
229 	 *     This does not have an additional refcount added, so if you want to
230 	 *     keep a copy of this around, you must reference it yourself.
231 	 */
232 	public PgContext getContext()
233 	{
234 		auto p = pango_layout_get_context(pangoLayout);
235 
236 		if(p is null)
237 		{
238 			return null;
239 		}
240 
241 		return ObjectG.getDObject!(PgContext)(cast(PangoContext*) p);
242 	}
243 
244 	/**
245 	 * Given an index within a layout, determines the positions that of the
246 	 * strong and weak cursors if the insertion point is at that
247 	 * index. The position of each cursor is stored as a zero-width
248 	 * rectangle. The strong cursor location is the location where
249 	 * characters of the directionality equal to the base direction of the
250 	 * layout are inserted.  The weak cursor location is the location
251 	 * where characters of the directionality opposite to the base
252 	 * direction of the layout are inserted.
253 	 *
254 	 * Params:
255 	 *     index = the byte index of the cursor
256 	 *     strongPos = location to store the strong cursor position
257 	 *         (may be %NULL)
258 	 *     weakPos = location to store the weak cursor position (may be %NULL)
259 	 */
260 	public void getCursorPos(int index, out PangoRectangle strongPos, out PangoRectangle weakPos)
261 	{
262 		pango_layout_get_cursor_pos(pangoLayout, index, &strongPos, &weakPos);
263 	}
264 
265 	/**
266 	 * Gets the type of ellipsization being performed for @layout.
267 	 * See pango_layout_set_ellipsize()
268 	 *
269 	 * Returns: the current ellipsization mode for @layout.
270 	 *
271 	 *     Use pango_layout_is_ellipsized() to query whether any paragraphs
272 	 *     were actually ellipsized.
273 	 *
274 	 * Since: 1.6
275 	 */
276 	public PangoEllipsizeMode getEllipsize()
277 	{
278 		return pango_layout_get_ellipsize(pangoLayout);
279 	}
280 
281 	/**
282 	 * Computes the logical and ink extents of @layout. Logical extents
283 	 * are usually what you want for positioning things.  Note that both extents
284 	 * may have non-zero x and y.  You may want to use those to offset where you
285 	 * render the layout.  Not doing that is a very typical bug that shows up as
286 	 * right-to-left layouts not being correctly positioned in a layout with
287 	 * a set width.
288 	 *
289 	 * The extents are given in layout coordinates and in Pango units; layout
290 	 * coordinates begin at the top left corner of the layout.
291 	 *
292 	 * Params:
293 	 *     inkRect = rectangle used to store the extents of the
294 	 *         layout as drawn or %NULL to indicate that the result is
295 	 *         not needed.
296 	 *     logicalRect = rectangle used to store the logical
297 	 *         extents of the layout or %NULL to indicate that the
298 	 *         result is not needed.
299 	 */
300 	public void getExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
301 	{
302 		pango_layout_get_extents(pangoLayout, &inkRect, &logicalRect);
303 	}
304 
305 	/**
306 	 * Gets the font description for the layout, if any.
307 	 *
308 	 * Returns: a pointer to the layout's font
309 	 *     description, or %NULL if the font description from the layout's
310 	 *     context is inherited. This value is owned by the layout and must
311 	 *     not be modified or freed.
312 	 *
313 	 * Since: 1.8
314 	 */
315 	public PgFontDescription getFontDescription()
316 	{
317 		auto p = pango_layout_get_font_description(pangoLayout);
318 
319 		if(p is null)
320 		{
321 			return null;
322 		}
323 
324 		return ObjectG.getDObject!(PgFontDescription)(cast(PangoFontDescription*) p);
325 	}
326 
327 	/**
328 	 * Gets the height of layout used for ellipsization.  See
329 	 * pango_layout_set_height() for details.
330 	 *
331 	 * Returns: the height, in Pango units if positive, or
332 	 *     number of lines if negative.
333 	 *
334 	 * Since: 1.20
335 	 */
336 	public int getHeight()
337 	{
338 		return pango_layout_get_height(pangoLayout);
339 	}
340 
341 	/**
342 	 * Gets the paragraph indent width in Pango units. A negative value
343 	 * indicates a hanging indentation.
344 	 *
345 	 * Returns: the indent in Pango units.
346 	 */
347 	public int getIndent()
348 	{
349 		return pango_layout_get_indent(pangoLayout);
350 	}
351 
352 	/**
353 	 * Returns an iterator to iterate over the visual extents of the layout.
354 	 *
355 	 * Returns: the new #PangoLayoutIter that should be freed using
356 	 *     pango_layout_iter_free().
357 	 */
358 	public PgLayoutIter getIter()
359 	{
360 		auto p = pango_layout_get_iter(pangoLayout);
361 
362 		if(p is null)
363 		{
364 			return null;
365 		}
366 
367 		return ObjectG.getDObject!(PgLayoutIter)(cast(PangoLayoutIter*) p, true);
368 	}
369 
370 	/**
371 	 * Gets whether each complete line should be stretched to fill the entire
372 	 * width of the layout.
373 	 *
374 	 * Returns: the justify.
375 	 */
376 	public bool getJustify()
377 	{
378 		return pango_layout_get_justify(pangoLayout) != 0;
379 	}
380 
381 	/**
382 	 * Retrieves a particular line from a #PangoLayout.
383 	 *
384 	 * Use the faster pango_layout_get_line_readonly() if you do not plan
385 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
386 	 *
387 	 * Params:
388 	 *     line = the index of a line, which must be between 0 and
389 	 *         <literal>pango_layout_get_line_count(layout) - 1</literal>, inclusive.
390 	 *
391 	 * Returns: the requested
392 	 *     #PangoLayoutLine, or %NULL if the index is out of
393 	 *     range. This layout line can be ref'ed and retained,
394 	 *     but will become invalid if changes are made to the
395 	 *     #PangoLayout.
396 	 */
397 	public PgLayoutLine getLine(int line)
398 	{
399 		auto p = pango_layout_get_line(pangoLayout, line);
400 
401 		if(p is null)
402 		{
403 			return null;
404 		}
405 
406 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
407 	}
408 
409 	/**
410 	 * Retrieves the count of lines for the @layout.
411 	 *
412 	 * Returns: the line count.
413 	 */
414 	public int getLineCount()
415 	{
416 		return pango_layout_get_line_count(pangoLayout);
417 	}
418 
419 	/**
420 	 * Retrieves a particular line from a #PangoLayout.
421 	 *
422 	 * This is a faster alternative to pango_layout_get_line(),
423 	 * but the user is not expected
424 	 * to modify the contents of the line (glyphs, glyph widths, etc.).
425 	 *
426 	 * Params:
427 	 *     line = the index of a line, which must be between 0 and
428 	 *         <literal>pango_layout_get_line_count(layout) - 1</literal>, inclusive.
429 	 *
430 	 * Returns: the requested
431 	 *     #PangoLayoutLine, or %NULL if the index is out of
432 	 *     range. This layout line can be ref'ed and retained,
433 	 *     but will become invalid if changes are made to the
434 	 *     #PangoLayout.  No changes should be made to the line.
435 	 *
436 	 * Since: 1.16
437 	 */
438 	public PgLayoutLine getLineReadonly(int line)
439 	{
440 		auto p = pango_layout_get_line_readonly(pangoLayout, line);
441 
442 		if(p is null)
443 		{
444 			return null;
445 		}
446 
447 		return ObjectG.getDObject!(PgLayoutLine)(cast(PangoLayoutLine*) p);
448 	}
449 
450 	/**
451 	 * Returns the lines of the @layout as a list.
452 	 *
453 	 * Use the faster pango_layout_get_lines_readonly() if you do not plan
454 	 * to modify the contents of the lines (glyphs, glyph widths, etc.).
455 	 *
456 	 * Returns: a #GSList containing
457 	 *     the lines in the layout. This points to internal data of the #PangoLayout
458 	 *     and must be used with care. It will become invalid on any change to the layout's
459 	 *     text or properties.
460 	 */
461 	public ListSG getLines()
462 	{
463 		auto p = pango_layout_get_lines(pangoLayout);
464 
465 		if(p is null)
466 		{
467 			return null;
468 		}
469 
470 		return new ListSG(cast(GSList*) p);
471 	}
472 
473 	/**
474 	 * Returns the lines of the @layout as a list.
475 	 *
476 	 * This is a faster alternative to pango_layout_get_lines(),
477 	 * but the user is not expected
478 	 * to modify the contents of the lines (glyphs, glyph widths, etc.).
479 	 *
480 	 * Returns: a #GSList containing
481 	 *     the lines in the layout. This points to internal data of the #PangoLayout and
482 	 *     must be used with care. It will become invalid on any change to the layout's
483 	 *     text or properties.  No changes should be made to the lines.
484 	 *
485 	 * Since: 1.16
486 	 */
487 	public ListSG getLinesReadonly()
488 	{
489 		auto p = pango_layout_get_lines_readonly(pangoLayout);
490 
491 		if(p is null)
492 		{
493 			return null;
494 		}
495 
496 		return new ListSG(cast(GSList*) p);
497 	}
498 
499 	/**
500 	 * Retrieves an array of logical attributes for each character in
501 	 * the @layout.
502 	 *
503 	 * Params:
504 	 *     attrs = location to store a pointer to an array of logical attributes
505 	 *         This value must be freed with g_free().
506 	 */
507 	public void getLogAttrs(out PangoLogAttr[] attrs)
508 	{
509 		PangoLogAttr* outattrs = null;
510 		int nAttrs;
511 
512 		pango_layout_get_log_attrs(pangoLayout, &outattrs, &nAttrs);
513 
514 		attrs = outattrs[0 .. nAttrs];
515 	}
516 
517 	/**
518 	 * Retrieves an array of logical attributes for each character in
519 	 * the @layout.
520 	 *
521 	 * This is a faster alternative to pango_layout_get_log_attrs().
522 	 * The returned array is part of @layout and must not be modified.
523 	 * Modifying the layout will invalidate the returned array.
524 	 *
525 	 * The number of attributes returned in @n_attrs will be one more
526 	 * than the total number of characters in the layout, since there
527 	 * need to be attributes corresponding to both the position before
528 	 * the first character and the position after the last character.
529 	 *
530 	 * Returns: an array of logical attributes
531 	 *
532 	 * Since: 1.30
533 	 */
534 	public PangoLogAttr[] getLogAttrsReadonly()
535 	{
536 		int nAttrs;
537 
538 		auto p = pango_layout_get_log_attrs_readonly(pangoLayout, &nAttrs);
539 
540 		return p[0 .. nAttrs];
541 	}
542 
543 	/**
544 	 * Computes the logical and ink extents of @layout in device units.
545 	 * This function just calls pango_layout_get_extents() followed by
546 	 * two pango_extents_to_pixels() calls, rounding @ink_rect and @logical_rect
547 	 * such that the rounded rectangles fully contain the unrounded one (that is,
548 	 * passes them as first argument to pango_extents_to_pixels()).
549 	 *
550 	 * Params:
551 	 *     inkRect = rectangle used to store the extents of the
552 	 *         layout as drawn or %NULL to indicate that the result is
553 	 *         not needed.
554 	 *     logicalRect = rectangle used to store the logical
555 	 *         extents of the layout or %NULL to indicate that the
556 	 *         result is not needed.
557 	 */
558 	public void getPixelExtents(out PangoRectangle inkRect, out PangoRectangle logicalRect)
559 	{
560 		pango_layout_get_pixel_extents(pangoLayout, &inkRect, &logicalRect);
561 	}
562 
563 	/**
564 	 * Determines the logical width and height of a #PangoLayout
565 	 * in device units. (pango_layout_get_size() returns the width
566 	 * and height scaled by %PANGO_SCALE.) This
567 	 * is simply a convenience function around
568 	 * pango_layout_get_pixel_extents().
569 	 *
570 	 * Params:
571 	 *     width = location to store the logical width, or %NULL
572 	 *     height = location to store the logical height, or %NULL
573 	 */
574 	public void getPixelSize(out int width, out int height)
575 	{
576 		pango_layout_get_pixel_size(pangoLayout, &width, &height);
577 	}
578 
579 	/**
580 	 * Returns the current serial number of @layout.  The serial number is
581 	 * initialized to an small number  larger than zero when a new layout
582 	 * is created and is increased whenever the layout is changed using any
583 	 * of the setter functions, or the #PangoContext it uses has changed.
584 	 * The serial may wrap, but will never have the value 0. Since it
585 	 * can wrap, never compare it with "less than", always use "not equals".
586 	 *
587 	 * This can be used to automatically detect changes to a #PangoLayout, and
588 	 * is useful for example to decide whether a layout needs redrawing.
589 	 * To force the serial to be increased, use pango_layout_context_changed().
590 	 *
591 	 * Returns: The current serial number of @layout.
592 	 *
593 	 * Since: 1.32.4
594 	 */
595 	public uint getSerial()
596 	{
597 		return pango_layout_get_serial(pangoLayout);
598 	}
599 
600 	/**
601 	 * Obtains the value set by pango_layout_set_single_paragraph_mode().
602 	 *
603 	 * Returns: %TRUE if the layout does not break paragraphs at
604 	 *     paragraph separator characters, %FALSE otherwise.
605 	 */
606 	public bool getSingleParagraphMode()
607 	{
608 		return pango_layout_get_single_paragraph_mode(pangoLayout) != 0;
609 	}
610 
611 	/**
612 	 * Determines the logical width and height of a #PangoLayout
613 	 * in Pango units (device units scaled by %PANGO_SCALE). This
614 	 * is simply a convenience function around pango_layout_get_extents().
615 	 *
616 	 * Params:
617 	 *     width = location to store the logical width, or %NULL
618 	 *     height = location to store the logical height, or %NULL
619 	 */
620 	public void getSize(out int width, out int height)
621 	{
622 		pango_layout_get_size(pangoLayout, &width, &height);
623 	}
624 
625 	/**
626 	 * Gets the amount of spacing between the lines of the layout.
627 	 *
628 	 * Returns: the spacing in Pango units.
629 	 */
630 	public int getSpacing()
631 	{
632 		return pango_layout_get_spacing(pangoLayout);
633 	}
634 
635 	/**
636 	 * Gets the current #PangoTabArray used by this layout. If no
637 	 * #PangoTabArray has been set, then the default tabs are in use
638 	 * and %NULL is returned. Default tabs are every 8 spaces.
639 	 * The return value should be freed with pango_tab_array_free().
640 	 *
641 	 * Returns: a copy of the tabs for this layout, or
642 	 *     %NULL.
643 	 */
644 	public PgTabArray getTabs()
645 	{
646 		auto p = pango_layout_get_tabs(pangoLayout);
647 
648 		if(p is null)
649 		{
650 			return null;
651 		}
652 
653 		return ObjectG.getDObject!(PgTabArray)(cast(PangoTabArray*) p, true);
654 	}
655 
656 	/**
657 	 * Gets the text in the layout. The returned text should not
658 	 * be freed or modified.
659 	 *
660 	 * Returns: the text in the @layout.
661 	 */
662 	public string getText()
663 	{
664 		return Str.toString(pango_layout_get_text(pangoLayout));
665 	}
666 
667 	/**
668 	 * Counts the number unknown glyphs in @layout.  That is, zero if
669 	 * glyphs for all characters in the layout text were found, or more
670 	 * than zero otherwise.
671 	 *
672 	 * This function can be used to determine if there are any fonts
673 	 * available to render all characters in a certain string, or when
674 	 * used in combination with %PANGO_ATTR_FALLBACK, to check if a
675 	 * certain font supports all the characters in the string.
676 	 *
677 	 * Returns: The number of unknown glyphs in @layout.
678 	 *
679 	 * Since: 1.16
680 	 */
681 	public int getUnknownGlyphsCount()
682 	{
683 		return pango_layout_get_unknown_glyphs_count(pangoLayout);
684 	}
685 
686 	/**
687 	 * Gets the width to which the lines of the #PangoLayout should wrap.
688 	 *
689 	 * Returns: the width in Pango units, or -1 if no width set.
690 	 */
691 	public int getWidth()
692 	{
693 		return pango_layout_get_width(pangoLayout);
694 	}
695 
696 	/**
697 	 * Gets the wrap mode for the layout.
698 	 *
699 	 * Use pango_layout_is_wrapped() to query whether any paragraphs
700 	 * were actually wrapped.
701 	 *
702 	 * Returns: active wrap mode.
703 	 */
704 	public PangoWrapMode getWrap()
705 	{
706 		return pango_layout_get_wrap(pangoLayout);
707 	}
708 
709 	/**
710 	 * Converts from byte @index_ within the @layout to line and X position.
711 	 * (X position is measured from the left edge of the line)
712 	 *
713 	 * Params:
714 	 *     index = the byte index of a grapheme within the layout.
715 	 *     trailing = an integer indicating the edge of the grapheme to retrieve the
716 	 *         position of. If > 0, the trailing edge of the grapheme, if 0,
717 	 *         the leading of the grapheme.
718 	 *     line = location to store resulting line index. (which will
719 	 *         between 0 and pango_layout_get_line_count(layout) - 1), or %NULL
720 	 *     xPos = location to store resulting position within line
721 	 *         (%PANGO_SCALE units per device unit), or %NULL
722 	 */
723 	public void indexToLineX(int index, bool trailing, out int line, out int xPos)
724 	{
725 		pango_layout_index_to_line_x(pangoLayout, index, trailing, &line, &xPos);
726 	}
727 
728 	/**
729 	 * Converts from an index within a #PangoLayout to the onscreen position
730 	 * corresponding to the grapheme at that index, which is represented
731 	 * as rectangle.  Note that <literal>pos->x</literal> is always the leading
732 	 * edge of the grapheme and <literal>pos->x + pos->width</literal> the trailing
733 	 * edge of the grapheme. If the directionality of the grapheme is right-to-left,
734 	 * then <literal>pos->width</literal> will be negative.
735 	 *
736 	 * Params:
737 	 *     index = byte index within @layout
738 	 *     pos = rectangle in which to store the position of the grapheme
739 	 */
740 	public void indexToPos(int index, out PangoRectangle pos)
741 	{
742 		pango_layout_index_to_pos(pangoLayout, index, &pos);
743 	}
744 
745 	/**
746 	 * Queries whether the layout had to ellipsize any paragraphs.
747 	 *
748 	 * This returns %TRUE if the ellipsization mode for @layout
749 	 * is not %PANGO_ELLIPSIZE_NONE, a positive width is set on @layout,
750 	 * and there are paragraphs exceeding that width that have to be
751 	 * ellipsized.
752 	 *
753 	 * Returns: %TRUE if any paragraphs had to be ellipsized, %FALSE
754 	 *     otherwise.
755 	 *
756 	 * Since: 1.16
757 	 */
758 	public bool isEllipsized()
759 	{
760 		return pango_layout_is_ellipsized(pangoLayout) != 0;
761 	}
762 
763 	/**
764 	 * Queries whether the layout had to wrap any paragraphs.
765 	 *
766 	 * This returns %TRUE if a positive width is set on @layout,
767 	 * ellipsization mode of @layout is set to %PANGO_ELLIPSIZE_NONE,
768 	 * and there are paragraphs exceeding the layout width that have
769 	 * to be wrapped.
770 	 *
771 	 * Returns: %TRUE if any paragraphs had to be wrapped, %FALSE
772 	 *     otherwise.
773 	 *
774 	 * Since: 1.16
775 	 */
776 	public bool isWrapped()
777 	{
778 		return pango_layout_is_wrapped(pangoLayout) != 0;
779 	}
780 
781 	/**
782 	 * Computes a new cursor position from an old position and
783 	 * a count of positions to move visually. If @direction is positive,
784 	 * then the new strong cursor position will be one position
785 	 * to the right of the old cursor position. If @direction is negative,
786 	 * then the new strong cursor position will be one position
787 	 * to the left of the old cursor position.
788 	 *
789 	 * In the presence of bidirectional text, the correspondence
790 	 * between logical and visual order will depend on the direction
791 	 * of the current run, and there may be jumps when the cursor
792 	 * is moved off of the end of a run.
793 	 *
794 	 * Motion here is in cursor positions, not in characters, so a
795 	 * single call to pango_layout_move_cursor_visually() may move the
796 	 * cursor over multiple characters when multiple characters combine
797 	 * to form a single grapheme.
798 	 *
799 	 * Params:
800 	 *     strong = whether the moving cursor is the strong cursor or the
801 	 *         weak cursor. The strong cursor is the cursor corresponding
802 	 *         to text insertion in the base direction for the layout.
803 	 *     oldIndex = the byte index of the grapheme for the old index
804 	 *     oldTrailing = if 0, the cursor was at the leading edge of the
805 	 *         grapheme indicated by @old_index, if > 0, the cursor
806 	 *         was at the trailing edge.
807 	 *     direction = direction to move cursor. A negative
808 	 *         value indicates motion to the left.
809 	 *     newIndex = location to store the new cursor byte index. A value of -1
810 	 *         indicates that the cursor has been moved off the beginning
811 	 *         of the layout. A value of %G_MAXINT indicates that
812 	 *         the cursor has been moved off the end of the layout.
813 	 *     newTrailing = number of characters to move forward from the
814 	 *         location returned for @new_index to get the position
815 	 *         where the cursor should be displayed. This allows
816 	 *         distinguishing the position at the beginning of one
817 	 *         line from the position at the end of the preceding
818 	 *         line. @new_index is always on the line where the
819 	 *         cursor should be displayed.
820 	 */
821 	public void moveCursorVisually(bool strong, int oldIndex, int oldTrailing, int direction, out int newIndex, out int newTrailing)
822 	{
823 		pango_layout_move_cursor_visually(pangoLayout, strong, oldIndex, oldTrailing, direction, &newIndex, &newTrailing);
824 	}
825 
826 	/**
827 	 * Sets the alignment for the layout: how partial lines are
828 	 * positioned within the horizontal space available.
829 	 *
830 	 * Params:
831 	 *     alignment = the alignment
832 	 */
833 	public void setAlignment(PangoAlignment alignment)
834 	{
835 		pango_layout_set_alignment(pangoLayout, alignment);
836 	}
837 
838 	/**
839 	 * Sets the text attributes for a layout object.
840 	 * References @attrs, so the caller can unref its reference.
841 	 *
842 	 * Params:
843 	 *     attrs = a #PangoAttrList, can be %NULL
844 	 */
845 	public void setAttributes(PgAttributeList attrs)
846 	{
847 		pango_layout_set_attributes(pangoLayout, (attrs is null) ? null : attrs.getPgAttributeListStruct());
848 	}
849 
850 	/**
851 	 * Sets whether to calculate the bidirectional base direction
852 	 * for the layout according to the contents of the layout;
853 	 * when this flag is on (the default), then paragraphs in
854 	 * @layout that begin with strong right-to-left characters
855 	 * (Arabic and Hebrew principally), will have right-to-left
856 	 * layout, paragraphs with letters from other scripts will
857 	 * have left-to-right layout. Paragraphs with only neutral
858 	 * characters get their direction from the surrounding paragraphs.
859 	 *
860 	 * When %FALSE, the choice between left-to-right and
861 	 * right-to-left layout is done according to the base direction
862 	 * of the layout's #PangoContext. (See pango_context_set_base_dir()).
863 	 *
864 	 * When the auto-computed direction of a paragraph differs from the
865 	 * base direction of the context, the interpretation of
866 	 * %PANGO_ALIGN_LEFT and %PANGO_ALIGN_RIGHT are swapped.
867 	 *
868 	 * Params:
869 	 *     autoDir = if %TRUE, compute the bidirectional base direction
870 	 *         from the layout's contents.
871 	 *
872 	 * Since: 1.4
873 	 */
874 	public void setAutoDir(bool autoDir)
875 	{
876 		pango_layout_set_auto_dir(pangoLayout, autoDir);
877 	}
878 
879 	/**
880 	 * Sets the type of ellipsization being performed for @layout.
881 	 * Depending on the ellipsization mode @ellipsize text is
882 	 * removed from the start, middle, or end of text so they
883 	 * fit within the width and height of layout set with
884 	 * pango_layout_set_width() and pango_layout_set_height().
885 	 *
886 	 * If the layout contains characters such as newlines that
887 	 * force it to be layed out in multiple paragraphs, then whether
888 	 * each paragraph is ellipsized separately or the entire layout
889 	 * is ellipsized as a whole depends on the set height of the layout.
890 	 * See pango_layout_set_height() for details.
891 	 *
892 	 * Params:
893 	 *     ellipsize = the new ellipsization mode for @layout
894 	 *
895 	 * Since: 1.6
896 	 */
897 	public void setEllipsize(PangoEllipsizeMode ellipsize)
898 	{
899 		pango_layout_set_ellipsize(pangoLayout, ellipsize);
900 	}
901 
902 	/**
903 	 * Sets the default font description for the layout. If no font
904 	 * description is set on the layout, the font description from
905 	 * the layout's context is used.
906 	 *
907 	 * Params:
908 	 *     desc = the new #PangoFontDescription, or %NULL to unset the
909 	 *         current font description
910 	 */
911 	public void setFontDescription(PgFontDescription desc)
912 	{
913 		pango_layout_set_font_description(pangoLayout, (desc is null) ? null : desc.getPgFontDescriptionStruct());
914 	}
915 
916 	/**
917 	 * Sets the height to which the #PangoLayout should be ellipsized at.  There
918 	 * are two different behaviors, based on whether @height is positive or
919 	 * negative.
920 	 *
921 	 * If @height is positive, it will be the maximum height of the layout.  Only
922 	 * lines would be shown that would fit, and if there is any text omitted,
923 	 * an ellipsis added.  At least one line is included in each paragraph regardless
924 	 * of how small the height value is.  A value of zero will render exactly one
925 	 * line for the entire layout.
926 	 *
927 	 * If @height is negative, it will be the (negative of) maximum number of lines per
928 	 * paragraph.  That is, the total number of lines shown may well be more than
929 	 * this value if the layout contains multiple paragraphs of text.
930 	 * The default value of -1 means that first line of each paragraph is ellipsized.
931 	 * This behvaior may be changed in the future to act per layout instead of per
932 	 * paragraph.  File a bug against pango at <ulink
933 	 * url="http://bugzilla.gnome.org/">http://bugzilla.gnome.org/</ulink> if your
934 	 * code relies on this behavior.
935 	 *
936 	 * Height setting only has effect if a positive width is set on
937 	 * @layout and ellipsization mode of @layout is not %PANGO_ELLIPSIZE_NONE.
938 	 * The behavior is undefined if a height other than -1 is set and
939 	 * ellipsization mode is set to %PANGO_ELLIPSIZE_NONE, and may change in the
940 	 * future.
941 	 *
942 	 * Params:
943 	 *     height = the desired height of the layout in Pango units if positive,
944 	 *         or desired number of lines if negative.
945 	 *
946 	 * Since: 1.20
947 	 */
948 	public void setHeight(int height)
949 	{
950 		pango_layout_set_height(pangoLayout, height);
951 	}
952 
953 	/**
954 	 * Sets the width in Pango units to indent each paragraph. A negative value
955 	 * of @indent will produce a hanging indentation. That is, the first line will
956 	 * have the full width, and subsequent lines will be indented by the
957 	 * absolute value of @indent.
958 	 *
959 	 * The indent setting is ignored if layout alignment is set to
960 	 * %PANGO_ALIGN_CENTER.
961 	 *
962 	 * Params:
963 	 *     indent = the amount by which to indent.
964 	 */
965 	public void setIndent(int indent)
966 	{
967 		pango_layout_set_indent(pangoLayout, indent);
968 	}
969 
970 	/**
971 	 * Sets whether each complete line should be stretched to
972 	 * fill the entire width of the layout. This stretching is typically
973 	 * done by adding whitespace, but for some scripts (such as Arabic),
974 	 * the justification may be done in more complex ways, like extending
975 	 * the characters.
976 	 *
977 	 * Note that this setting is not implemented and so is ignored in Pango
978 	 * older than 1.18.
979 	 *
980 	 * Params:
981 	 *     justify = whether the lines in the layout should be justified.
982 	 */
983 	public void setJustify(bool justify)
984 	{
985 		pango_layout_set_justify(pangoLayout, justify);
986 	}
987 
988 	/**
989 	 * Same as pango_layout_set_markup_with_accel(), but
990 	 * the markup text isn't scanned for accelerators.
991 	 *
992 	 * Params:
993 	 *     markup = marked-up text
994 	 *     length = length of marked-up text in bytes, or -1 if @markup is
995 	 *         null-terminated
996 	 */
997 	public void setMarkup(string markup, int length)
998 	{
999 		pango_layout_set_markup(pangoLayout, Str.toStringz(markup), length);
1000 	}
1001 
1002 	/**
1003 	 * Sets the layout text and attribute list from marked-up text (see
1004 	 * <link linkend="PangoMarkupFormat">markup format</link>). Replaces
1005 	 * the current text and attribute list.
1006 	 *
1007 	 * If @accel_marker is nonzero, the given character will mark the
1008 	 * character following it as an accelerator. For example, @accel_marker
1009 	 * might be an ampersand or underscore. All characters marked
1010 	 * as an accelerator will receive a %PANGO_UNDERLINE_LOW attribute,
1011 	 * and the first character so marked will be returned in @accel_char.
1012 	 * Two @accel_marker characters following each other produce a single
1013 	 * literal @accel_marker character.
1014 	 *
1015 	 * Params:
1016 	 *     markup = marked-up text
1017 	 *         (see <link linkend="PangoMarkupFormat">markup format</link>)
1018 	 *     length = length of marked-up text in bytes, or -1 if @markup is
1019 	 *         null-terminated
1020 	 *     accelMarker = marker for accelerators in the text
1021 	 *     accelChar = return location
1022 	 *         for first located accelerator, or %NULL
1023 	 */
1024 	public void setMarkupWithAccel(string markup, int length, dchar accelMarker, out dchar accelChar)
1025 	{
1026 		pango_layout_set_markup_with_accel(pangoLayout, Str.toStringz(markup), length, accelMarker, &accelChar);
1027 	}
1028 
1029 	/**
1030 	 * If @setting is %TRUE, do not treat newlines and similar characters
1031 	 * as paragraph separators; instead, keep all text in a single paragraph,
1032 	 * and display a glyph for paragraph separator characters. Used when
1033 	 * you want to allow editing of newlines on a single text line.
1034 	 *
1035 	 * Params:
1036 	 *     setting = new setting
1037 	 */
1038 	public void setSingleParagraphMode(bool setting)
1039 	{
1040 		pango_layout_set_single_paragraph_mode(pangoLayout, setting);
1041 	}
1042 
1043 	/**
1044 	 * Sets the amount of spacing in Pango unit between the lines of the
1045 	 * layout.
1046 	 *
1047 	 * Params:
1048 	 *     spacing = the amount of spacing
1049 	 */
1050 	public void setSpacing(int spacing)
1051 	{
1052 		pango_layout_set_spacing(pangoLayout, spacing);
1053 	}
1054 
1055 	/**
1056 	 * Sets the tabs to use for @layout, overriding the default tabs
1057 	 * (by default, tabs are every 8 spaces). If @tabs is %NULL, the default
1058 	 * tabs are reinstated. @tabs is copied into the layout; you must
1059 	 * free your copy of @tabs yourself.
1060 	 *
1061 	 * Params:
1062 	 *     tabs = a #PangoTabArray, or %NULL
1063 	 */
1064 	public void setTabs(PgTabArray tabs)
1065 	{
1066 		pango_layout_set_tabs(pangoLayout, (tabs is null) ? null : tabs.getPgTabArrayStruct());
1067 	}
1068 
1069 	/**
1070 	 * Sets the text of the layout.
1071 	 *
1072 	 * Note that if you have used
1073 	 * pango_layout_set_markup() or pango_layout_set_markup_with_accel() on
1074 	 * @layout before, you may want to call pango_layout_set_attributes() to clear
1075 	 * the attributes set on the layout from the markup as this function does not
1076 	 * clear attributes.
1077 	 *
1078 	 * Params:
1079 	 *     text = a valid UTF-8 string
1080 	 */
1081 	public void setText(string text)
1082 	{
1083 		pango_layout_set_text(pangoLayout, Str.toStringz(text), cast(int)text.length);
1084 	}
1085 
1086 	/**
1087 	 * Sets the width to which the lines of the #PangoLayout should wrap or
1088 	 * ellipsized.  The default value is -1: no width set.
1089 	 *
1090 	 * Params:
1091 	 *     width = the desired width in Pango units, or -1 to indicate that no
1092 	 *         wrapping or ellipsization should be performed.
1093 	 */
1094 	public void setWidth(int width)
1095 	{
1096 		pango_layout_set_width(pangoLayout, width);
1097 	}
1098 
1099 	/**
1100 	 * Sets the wrap mode; the wrap mode only has effect if a width
1101 	 * is set on the layout with pango_layout_set_width().
1102 	 * To turn off wrapping, set the width to -1.
1103 	 *
1104 	 * Params:
1105 	 *     wrap = the wrap mode
1106 	 */
1107 	public void setWrap(PangoWrapMode wrap)
1108 	{
1109 		pango_layout_set_wrap(pangoLayout, wrap);
1110 	}
1111 
1112 	/**
1113 	 * Converts from X and Y position within a layout to the byte
1114 	 * index to the character at that logical position. If the
1115 	 * Y position is not inside the layout, the closest position is chosen
1116 	 * (the position will be clamped inside the layout). If the
1117 	 * X position is not within the layout, then the start or the
1118 	 * end of the line is chosen as described for pango_layout_line_x_to_index().
1119 	 * If either the X or Y positions were not inside the layout, then the
1120 	 * function returns %FALSE; on an exact hit, it returns %TRUE.
1121 	 *
1122 	 * Params:
1123 	 *     x = the X offset (in Pango units)
1124 	 *         from the left edge of the layout.
1125 	 *     y = the Y offset (in Pango units)
1126 	 *         from the top edge of the layout
1127 	 *     index = location to store calculated byte index
1128 	 *     trailing = location to store a integer indicating where
1129 	 *         in the grapheme the user clicked. It will either
1130 	 *         be zero, or the number of characters in the
1131 	 *         grapheme. 0 represents the leading edge of the grapheme.
1132 	 *
1133 	 * Returns: %TRUE if the coordinates were inside text, %FALSE otherwise.
1134 	 */
1135 	public bool xyToIndex(int x, int y, out int index, out int trailing)
1136 	{
1137 		return pango_layout_xy_to_index(pangoLayout, x, y, &index, &trailing) != 0;
1138 	}
1139 }