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