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