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-Text-Attributes.html 27 * outPack = pango 28 * outFile = PgAttribute 29 * strct = PangoAttribute 30 * realStrct= 31 * ctorStrct= 32 * clss = PgAttribute 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - pango_attr_ 41 * - pango_ 42 * omit structs: 43 * omit prefixes: 44 * - pango_color_ 45 * - pango_language_ 46 * - pango_attr_list_ 47 * - pango_attr_iterator_ 48 * omit code: 49 * omit signals: 50 * imports: 51 * - glib.Str 52 * - glib.ErrorG 53 * - glib.GException 54 * - pango.PgAttributeList 55 * - pango.PgLanguage 56 * - pango.PgFontDescription 57 * structWrap: 58 * - PangoAttrList* -> PgAttributeList 59 * - PangoAttribute* -> PgAttribute 60 * - PangoFontDescription* -> PgFontDescription 61 * - PangoLanguage* -> PgLanguage 62 * module aliases: 63 * local aliases: 64 * overrides: 65 */ 66 67 module pango.PgAttribute; 68 69 public import gtkc.pangotypes; 70 71 private import gtkc.pango; 72 private import glib.ConstructionException; 73 private import gobject.ObjectG; 74 75 76 private import glib.Str; 77 private import glib.ErrorG; 78 private import glib.GException; 79 private import pango.PgAttributeList; 80 private import pango.PgLanguage; 81 private import pango.PgFontDescription; 82 83 84 85 86 /** 87 * Description 88 * Attributed text is used in a number of places in Pango. It 89 * is used as the input to the itemization process and also when 90 * creating a PangoLayout. The data types and functions in 91 * this section are used to represent and manipulate sets 92 * of attributes applied to a portion of text. 93 */ 94 public class PgAttribute 95 { 96 97 /** the main Gtk struct */ 98 protected PangoAttribute* pangoAttribute; 99 100 101 public PangoAttribute* getPgAttributeStruct() 102 { 103 return pangoAttribute; 104 } 105 106 107 /** the main Gtk struct as a void* */ 108 protected void* getStruct() 109 { 110 return cast(void*)pangoAttribute; 111 } 112 113 /** 114 * Sets our main struct and passes it to the parent class 115 */ 116 public this (PangoAttribute* pangoAttribute) 117 { 118 this.pangoAttribute = pangoAttribute; 119 } 120 121 /** 122 */ 123 124 /** 125 * Parses marked-up text (see 126 * markup format) to create 127 * a plain-text string and an attribute list. 128 * If accel_marker is nonzero, the given character will mark the 129 * character following it as an accelerator. For example, accel_marker 130 * might be an ampersand or underscore. All characters marked 131 * as an accelerator will receive a PANGO_UNDERLINE_LOW attribute, 132 * and the first character so marked will be returned in accel_char. 133 * Two accel_marker characters following each other produce a single 134 * literal accel_marker character. 135 * If any error happens, none of the output arguments are touched except 136 * for error. 137 * Params: 138 * markupText = markup to parse (see markup format) 139 * length = length of markup_text, or -1 if nul-terminated 140 * accelMarker = character that precedes an accelerator, or 0 for none 141 * attrList = address of return location for a PangoAttrList, or NULL. [out][allow-none] 142 * text = address of return location for text with tags stripped, or NULL. [out][allow-none] 143 * accelChar = address of return location for accelerator char, or NULL. [out][allow-none] 144 * Returns: FALSE if error is set, otherwise TRUE 145 * Throws: GException on failure. 146 */ 147 public static int parseMarkup(string markupText, int length, gunichar accelMarker, out PgAttributeList attrList, out string text, gunichar* accelChar) 148 { 149 // gboolean pango_parse_markup (const char *markup_text, int length, gunichar accel_marker, PangoAttrList **attr_list, char **text, gunichar *accel_char, GError **error); 150 PangoAttrList* outattrList = null; 151 char* outtext = null; 152 GError* err = null; 153 154 auto p = pango_parse_markup(Str.toStringz(markupText), length, accelMarker, &outattrList, &outtext, accelChar, &err); 155 156 if (err !is null) 157 { 158 throw new GException( new ErrorG(err) ); 159 } 160 161 attrList = ObjectG.getDObject!(PgAttributeList)(outattrList); 162 text = Str.toString(outtext); 163 return p; 164 } 165 166 /** 167 * Allocate a new attribute type ID. The attribute type name can be accessed 168 * later by using pango_attr_type_get_name(). 169 * Params: 170 * name = an identifier for the type 171 * Returns: the new type ID. 172 */ 173 public static PangoAttrType typeRegister(string name) 174 { 175 // PangoAttrType pango_attr_type_register (const gchar *name); 176 return pango_attr_type_register(Str.toStringz(name)); 177 } 178 179 /** 180 * Fetches the attribute type name passed in when registering the type using 181 * pango_attr_type_register(). 182 * The returned value is an interned string (see g_intern_string() for what 183 * that means) that should not be modified or freed. 184 * Since 1.22 185 * Params: 186 * type = an attribute type ID to fetch the name for 187 * Returns: the type ID name (which may be NULL), or NULL if type is a built-in Pango attribute type or invalid. 188 */ 189 public static string typeGetName(PangoAttrType type) 190 { 191 // const char * pango_attr_type_get_name (PangoAttrType type); 192 return Str.toString(pango_attr_type_get_name(type)); 193 } 194 195 /** 196 * Initializes attr's klass to klass, 197 * it's start_index to PANGO_ATTR_INDEX_FROM_TEXT_BEGINNING 198 * and end_index to PANGO_ATTR_INDEX_TO_TEXT_END 199 * such that the attribute applies 200 * to the entire text by default. 201 * Since 1.20 202 * Params: 203 * attr = a PangoAttribute 204 * klass = a PangoAttributeClass 205 */ 206 public void attributeInit(PangoAttrClass* klass) 207 { 208 // void pango_attribute_init (PangoAttribute *attr, const PangoAttrClass *klass); 209 pango_attribute_init(pangoAttribute, klass); 210 } 211 212 /** 213 * Make a copy of an attribute. 214 * Params: 215 * attr = a PangoAttribute 216 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 217 */ 218 public PgAttribute attributeCopy() 219 { 220 // PangoAttribute * pango_attribute_copy (const PangoAttribute *attr); 221 auto p = pango_attribute_copy(pangoAttribute); 222 223 if(p is null) 224 { 225 return null; 226 } 227 228 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 229 } 230 231 /** 232 * Compare two attributes for equality. This compares only the 233 * actual value of the two attributes and not the ranges that the 234 * attributes apply to. 235 * Params: 236 * attr2 = another PangoAttribute 237 * Returns: TRUE if the two attributes have the same value. 238 */ 239 public int attributeEqual(PgAttribute attr2) 240 { 241 // gboolean pango_attribute_equal (const PangoAttribute *attr1, const PangoAttribute *attr2); 242 return pango_attribute_equal(pangoAttribute, (attr2 is null) ? null : attr2.getPgAttributeStruct()); 243 } 244 245 /** 246 * Destroy a PangoAttribute and free all associated memory. 247 * Params: 248 * attr = a PangoAttribute. 249 */ 250 public void attributeDestroy() 251 { 252 // void pango_attribute_destroy (PangoAttribute *attr); 253 pango_attribute_destroy(pangoAttribute); 254 } 255 256 /** 257 * Create a new language tag attribute. 258 * Params: 259 * language = language tag 260 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 261 */ 262 public static PgAttribute languageNew(PgLanguage language) 263 { 264 // PangoAttribute * pango_attr_language_new (PangoLanguage *language); 265 auto p = pango_attr_language_new((language is null) ? null : language.getPgLanguageStruct()); 266 267 if(p is null) 268 { 269 return null; 270 } 271 272 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 273 } 274 275 /** 276 * Create a new font family attribute. 277 * Params: 278 * family = the family or comma separated list of families 279 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 280 */ 281 public static PgAttribute familyNew(string family) 282 { 283 // PangoAttribute * pango_attr_family_new (const char *family); 284 auto p = pango_attr_family_new(Str.toStringz(family)); 285 286 if(p is null) 287 { 288 return null; 289 } 290 291 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 292 } 293 294 /** 295 * Create a new font slant style attribute. 296 * Params: 297 * style = the slant style 298 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 299 */ 300 public static PgAttribute styleNew(PangoStyle style) 301 { 302 // PangoAttribute * pango_attr_style_new (PangoStyle style); 303 auto p = pango_attr_style_new(style); 304 305 if(p is null) 306 { 307 return null; 308 } 309 310 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 311 } 312 313 /** 314 * Create a new font variant attribute (normal or small caps) 315 * Params: 316 * variant = the variant 317 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 318 */ 319 public static PgAttribute variantNew(PangoVariant variant) 320 { 321 // PangoAttribute * pango_attr_variant_new (PangoVariant variant); 322 auto p = pango_attr_variant_new(variant); 323 324 if(p is null) 325 { 326 return null; 327 } 328 329 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 330 } 331 332 /** 333 * Create a new font stretch attribute 334 * Params: 335 * stretch = the stretch 336 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 337 */ 338 public static PgAttribute stretchNew(PangoStretch stretch) 339 { 340 // PangoAttribute * pango_attr_stretch_new (PangoStretch stretch); 341 auto p = pango_attr_stretch_new(stretch); 342 343 if(p is null) 344 { 345 return null; 346 } 347 348 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 349 } 350 351 /** 352 * Create a new font weight attribute. 353 * Params: 354 * weight = the weight 355 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 356 */ 357 public static PgAttribute weightNew(PangoWeight weight) 358 { 359 // PangoAttribute * pango_attr_weight_new (PangoWeight weight); 360 auto p = pango_attr_weight_new(weight); 361 362 if(p is null) 363 { 364 return null; 365 } 366 367 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 368 } 369 370 /** 371 * Create a new font-size attribute in fractional points. 372 * Params: 373 * size = the font size, in PANGO_SCALEths of a point. 374 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 375 */ 376 public static PgAttribute sizeNew(int size) 377 { 378 // PangoAttribute * pango_attr_size_new (int size); 379 auto p = pango_attr_size_new(size); 380 381 if(p is null) 382 { 383 return null; 384 } 385 386 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 387 } 388 389 /** 390 * Create a new font-size attribute in device units. 391 * Since 1.8 392 * Params: 393 * size = the font size, in PANGO_SCALEths of a device unit. 394 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 395 */ 396 public static PgAttribute sizeNewAbsolute(int size) 397 { 398 // PangoAttribute * pango_attr_size_new_absolute (int size); 399 auto p = pango_attr_size_new_absolute(size); 400 401 if(p is null) 402 { 403 return null; 404 } 405 406 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 407 } 408 409 /** 410 * Create a new font description attribute. This attribute 411 * allows setting family, style, weight, variant, stretch, 412 * and size simultaneously. 413 * Params: 414 * desc = the font description 415 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 416 */ 417 public static PgAttribute fontDescNew(PgFontDescription desc) 418 { 419 // PangoAttribute * pango_attr_font_desc_new (const PangoFontDescription *desc); 420 auto p = pango_attr_font_desc_new((desc is null) ? null : desc.getPgFontDescriptionStruct()); 421 422 if(p is null) 423 { 424 return null; 425 } 426 427 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 428 } 429 430 /** 431 * Create a new foreground color attribute. 432 * Params: 433 * red = the red value (ranging from 0 to 65535) 434 * green = the green value 435 * blue = the blue value 436 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 437 */ 438 public static PgAttribute foregroundNew(ushort red, ushort green, ushort blue) 439 { 440 // PangoAttribute * pango_attr_foreground_new (guint16 red, guint16 green, guint16 blue); 441 auto p = pango_attr_foreground_new(red, green, blue); 442 443 if(p is null) 444 { 445 return null; 446 } 447 448 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 449 } 450 451 /** 452 * Create a new background color attribute. 453 * Params: 454 * red = the red value (ranging from 0 to 65535) 455 * green = the green value 456 * blue = the blue value 457 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 458 */ 459 public static PgAttribute backgroundNew(ushort red, ushort green, ushort blue) 460 { 461 // PangoAttribute * pango_attr_background_new (guint16 red, guint16 green, guint16 blue); 462 auto p = pango_attr_background_new(red, green, blue); 463 464 if(p is null) 465 { 466 return null; 467 } 468 469 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 470 } 471 472 /** 473 * Create a new strike-through attribute. 474 * Params: 475 * strikethrough = TRUE if the text should be struck-through. 476 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 477 */ 478 public static PgAttribute strikethroughNew(int strikethrough) 479 { 480 // PangoAttribute * pango_attr_strikethrough_new (gboolean strikethrough); 481 auto p = pango_attr_strikethrough_new(strikethrough); 482 483 if(p is null) 484 { 485 return null; 486 } 487 488 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 489 } 490 491 /** 492 * Create a new strikethrough color attribute. This attribute 493 * modifies the color of strikethrough lines. If not set, strikethrough 494 * lines will use the foreground color. 495 * Since 1.8 496 * Params: 497 * red = the red value (ranging from 0 to 65535) 498 * green = the green value 499 * blue = the blue value 500 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 501 */ 502 public static PgAttribute strikethroughColorNew(ushort red, ushort green, ushort blue) 503 { 504 // PangoAttribute * pango_attr_strikethrough_color_new (guint16 red, guint16 green, guint16 blue); 505 auto p = pango_attr_strikethrough_color_new(red, green, blue); 506 507 if(p is null) 508 { 509 return null; 510 } 511 512 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 513 } 514 515 /** 516 * Create a new underline-style attribute. 517 * Params: 518 * underline = the underline style. 519 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 520 */ 521 public static PgAttribute underlineNew(PangoUnderline underline) 522 { 523 // PangoAttribute * pango_attr_underline_new (PangoUnderline underline); 524 auto p = pango_attr_underline_new(underline); 525 526 if(p is null) 527 { 528 return null; 529 } 530 531 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 532 } 533 534 /** 535 * Create a new underline color attribute. This attribute 536 * modifies the color of underlines. If not set, underlines 537 * will use the foreground color. 538 * Since 1.8 539 * Params: 540 * red = the red value (ranging from 0 to 65535) 541 * green = the green value 542 * blue = the blue value 543 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 544 */ 545 public static PgAttribute underlineColorNew(ushort red, ushort green, ushort blue) 546 { 547 // PangoAttribute * pango_attr_underline_color_new (guint16 red, guint16 green, guint16 blue); 548 auto p = pango_attr_underline_color_new(red, green, blue); 549 550 if(p is null) 551 { 552 return null; 553 } 554 555 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 556 } 557 558 /** 559 * Create a new shape attribute. A shape is used to impose a 560 * particular ink and logical rectangle on the result of shaping a 561 * particular glyph. This might be used, for instance, for 562 * embedding a picture or a widget inside a PangoLayout. 563 * Params: 564 * inkRect = ink rectangle to assign to each character 565 * logicalRect = logical rectangle to assign to each character 566 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 567 */ 568 public static PgAttribute shapeNew(PangoRectangle* inkRect, PangoRectangle* logicalRect) 569 { 570 // PangoAttribute * pango_attr_shape_new (const PangoRectangle *ink_rect, const PangoRectangle *logical_rect); 571 auto p = pango_attr_shape_new(inkRect, logicalRect); 572 573 if(p is null) 574 { 575 return null; 576 } 577 578 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 579 } 580 581 /** 582 * Like pango_attr_shape_new(), but a user data pointer is also 583 * provided; this pointer can be accessed when later 584 * rendering the glyph. 585 * Since 1.8 586 * Params: 587 * inkRect = ink rectangle to assign to each character 588 * logicalRect = logical rectangle to assign to each character 589 * data = user data pointer 590 * copyFunc = function to copy data when the attribute 591 * is copied. If NULL, data is simply copied 592 * as a pointer. 593 * destroyFunc = function to free data when the attribute 594 * is freed, or NULL 595 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 596 */ 597 public static PgAttribute shapeNewWithData(PangoRectangle* inkRect, PangoRectangle* logicalRect, void* data, PangoAttrDataCopyFunc copyFunc, GDestroyNotify destroyFunc) 598 { 599 // PangoAttribute * pango_attr_shape_new_with_data (const PangoRectangle *ink_rect, const PangoRectangle *logical_rect, gpointer data, PangoAttrDataCopyFunc copy_func, GDestroyNotify destroy_func); 600 auto p = pango_attr_shape_new_with_data(inkRect, logicalRect, data, copyFunc, destroyFunc); 601 602 if(p is null) 603 { 604 return null; 605 } 606 607 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 608 } 609 610 /** 611 * Create a new font size scale attribute. The base font for the 612 * affected text will have its size multiplied by scale_factor. 613 * Params: 614 * scaleFactor = factor to scale the font 615 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 616 */ 617 public static PgAttribute scaleNew(double scaleFactor) 618 { 619 // PangoAttribute * pango_attr_scale_new (double scale_factor); 620 auto p = pango_attr_scale_new(scaleFactor); 621 622 if(p is null) 623 { 624 return null; 625 } 626 627 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 628 } 629 630 /** 631 * Create a new baseline displacement attribute. 632 * Params: 633 * rise = the amount that the text should be displaced vertically, 634 * in Pango units. Positive values displace the text upwards. 635 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 636 */ 637 public static PgAttribute riseNew(int rise) 638 { 639 // PangoAttribute * pango_attr_rise_new (int rise); 640 auto p = pango_attr_rise_new(rise); 641 642 if(p is null) 643 { 644 return null; 645 } 646 647 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 648 } 649 650 /** 651 * Create a new letter-spacing attribute. 652 * Since 1.6 653 * Params: 654 * letterSpacing = amount of extra space to add between graphemes 655 * of the text, in Pango units. 656 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 657 */ 658 public static PgAttribute letterSpacingNew(int letterSpacing) 659 { 660 // PangoAttribute * pango_attr_letter_spacing_new (int letter_spacing); 661 auto p = pango_attr_letter_spacing_new(letterSpacing); 662 663 if(p is null) 664 { 665 return null; 666 } 667 668 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 669 } 670 671 /** 672 * Create a new font fallback attribute. 673 * If fallback is disabled, characters will only be used from the 674 * closest matching font on the system. No fallback will be done to 675 * other fonts on the system that might contain the characters in the 676 * text. 677 * Since 1.4 678 * Params: 679 * enableFallback = TRUE if we should fall back on other fonts 680 * for characters the active font is missing. 681 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 682 */ 683 public static PgAttribute fallbackNew(int enableFallback) 684 { 685 // PangoAttribute * pango_attr_fallback_new (gboolean enable_fallback); 686 auto p = pango_attr_fallback_new(enableFallback); 687 688 if(p is null) 689 { 690 return null; 691 } 692 693 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 694 } 695 696 /** 697 * Create a new gravity attribute. 698 * Since 1.16 699 * Params: 700 * gravity = the gravity value; should not be PANGO_GRAVITY_AUTO. 701 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 702 */ 703 public static PgAttribute gravityNew(PangoGravity gravity) 704 { 705 // PangoAttribute * pango_attr_gravity_new (PangoGravity gravity); 706 auto p = pango_attr_gravity_new(gravity); 707 708 if(p is null) 709 { 710 return null; 711 } 712 713 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 714 } 715 716 /** 717 * Create a new gravity hint attribute. 718 * Since 1.16 719 * Params: 720 * hint = the gravity hint value. 721 * Returns: the newly allocated PangoAttribute, which should be freed with pango_attribute_destroy(). 722 */ 723 public static PgAttribute gravityHintNew(PangoGravityHint hint) 724 { 725 // PangoAttribute * pango_attr_gravity_hint_new (PangoGravityHint hint); 726 auto p = pango_attr_gravity_hint_new(hint); 727 728 if(p is null) 729 { 730 return null; 731 } 732 733 return ObjectG.getDObject!(PgAttribute)(cast(PangoAttribute*) p); 734 } 735 }