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