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