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