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