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