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 = GtkLabel.html 27 * outPack = gtk 28 * outFile = Label 29 * strct = GtkLabel 30 * realStrct= 31 * ctorStrct= 32 * clss = Label 33 * interf = 34 * class Code: Yes 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gtk_label_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * - gtk_label_new 45 * - gtk_label_new_with_mnemonic 46 * omit signals: 47 * imports: 48 * - glib.Str 49 * - gtk.Menu 50 * - gtk.Widget 51 * - pango.PgAttributeList 52 * - pango.PgLayout 53 * structWrap: 54 * - GtkMenu* -> Menu 55 * - GtkWidget* -> Widget 56 * - PangoAttrList* -> PgAttributeList 57 * - PangoLayout* -> PgLayout 58 * module aliases: 59 * local aliases: 60 * overrides: 61 */ 62 63 module gtk.Label; 64 65 public import gtkc.gtktypes; 66 67 private import gtkc.gtk; 68 private import glib.ConstructionException; 69 private import gobject.ObjectG; 70 71 private import gobject.Signals; 72 public import gtkc.gdktypes; 73 private import glib.Str; 74 private import gtk.Menu; 75 private import gtk.Widget; 76 private import pango.PgAttributeList; 77 private import pango.PgLayout; 78 79 80 private import gtk.Misc; 81 82 /** 83 * The GtkLabel widget displays a small amount of text. As the name 84 * implies, most labels are used to label another widget such as a 85 * GtkButton, a GtkMenuItem, or a GtkComboBox. 86 * 87 * GtkLabel as GtkBuildable 88 * 89 * The GtkLabel implementation of the GtkBuildable interface supports a 90 * custom <attributes> element, which supports any number of <attribute> 91 * elements. the <attribute> element has attributes named name, value, 92 * start and end and allows you to specify PangoAttribute values for this label. 93 * 94 * $(DDOC_COMMENT example) 95 * 96 * The start and end attributes specify the range of characters to which the 97 * Pango attribute applies. If start and end are not specified, the attribute is 98 * applied to the whole text. Note that specifying ranges does not make much 99 * sense with translatable attributes. Use markup embedded in the translatable 100 * content instead. 101 * 102 * <hr> 103 * 104 * Mnemonics 105 * 106 * Labels may contain mnemonics. Mnemonics are 107 * underlined characters in the label, used for keyboard navigation. 108 * Mnemonics are created by providing a string with an underscore before 109 * the mnemonic character, such as "_File", to the 110 * functions gtk_label_new_with_mnemonic() or 111 * gtk_label_set_text_with_mnemonic(). 112 * 113 * Mnemonics automatically activate any activatable widget the label is 114 * inside, such as a GtkButton; if the label is not inside the 115 * mnemonic's target widget, you have to tell the label about the target 116 * using gtk_label_set_mnemonic_widget(). Here's a simple example where 117 * the label is inside a button: 118 * 119 * $(DDOC_COMMENT example) 120 * 121 * There's a convenience function to create buttons with a mnemonic label 122 * already inside: 123 * 124 * $(DDOC_COMMENT example) 125 * 126 * To create a mnemonic for a widget alongside the label, such as a 127 * GtkEntry, you have to point the label at the entry with 128 * gtk_label_set_mnemonic_widget(): 129 * 130 * $(DDOC_COMMENT example) 131 * 132 * <hr> 133 * 134 * Markup (styled text) 135 * 136 * To make it easy to format text in a label (changing colors, fonts, 137 * etc.), label text can be provided in a simple markup format. 138 * Here's how to create a label with a small font: 139 * 140 * $(DDOC_COMMENT example) 141 * 142 * (See complete documentation of available 143 * tags in the Pango manual.) 144 * 145 * The markup passed to gtk_label_set_markup() must be valid; for example, 146 * literal <, > and characters must be escaped as \<, 147 * \gt;, and \. If you pass text obtained from the user, file, 148 * or a network to gtk_label_set_markup(), you'll want to escape it with 149 * g_markup_escape_text() or g_markup_printf_escaped(). 150 * 151 * Markup strings are just a convenient way to set the PangoAttrList on 152 * a label; gtk_label_set_attributes() may be a simpler way to set 153 * attributes in some cases. Be careful though; PangoAttrList tends to 154 * cause internationalization problems, unless you're applying attributes 155 * to the entire string (i.e. unless you set the range of each attribute 156 * to [0, G_MAXINT)). The reason is that specifying the start_index and 157 * end_index for a PangoAttribute requires knowledge of the exact string 158 * being displayed, so translations will cause problems. 159 * 160 * <hr> 161 * 162 * Selectable labels 163 * 164 * Labels can be made selectable with gtk_label_set_selectable(). 165 * Selectable labels allow the user to copy the label contents to 166 * the clipboard. Only labels that contain useful-to-copy information 167 * — such as error messages — should be made selectable. 168 * 169 * <hr> 170 * 171 * Text layout 172 * 173 * A label can contain any number of paragraphs, but will have 174 * performance problems if it contains more than a small number. 175 * Paragraphs are separated by newlines or other paragraph separators 176 * understood by Pango. 177 * 178 * Labels can automatically wrap text if you call 179 * gtk_label_set_line_wrap(). 180 * 181 * gtk_label_set_justify() sets how the lines in a label align 182 * with one another. If you want to set how the label as a whole 183 * aligns in its available space, see gtk_misc_set_alignment(). 184 * 185 * The "width-chars" and "max-width-chars" properties 186 * can be used to control the size allocation of ellipsized or wrapped 187 * labels. For ellipsizing labels, if either is specified (and less 188 * than the actual text size), it is used as the minimum width, and the actual 189 * text size is used as the natural width of the label. For wrapping labels, 190 * width-chars is used as the minimum width, if specified, and max-width-chars 191 * is used as the natural width. Even if max-width-chars specified, wrapping 192 * labels will be rewrapped to use all of the available width. 193 * 194 * Note 195 * 196 * Note that the interpretation of "width-chars" and 197 * "max-width-chars" has changed a bit with the introduction of 198 * width-for-height geometry management. 199 * 200 * <hr> 201 * 202 * Links 203 * 204 * Since 2.18, GTK+ supports markup for clickable hyperlinks in addition 205 * to regular Pango markup. The markup for links is borrowed from HTML, using the 206 * a with href and title attributes. GTK+ renders links similar to the 207 * way they appear in web browsers, with colored, underlined text. The title 208 * attribute is displayed as a tooltip on the link. An example looks like this: 209 * 210 * $(DDOC_COMMENT example) 211 * 212 * It is possible to implement custom handling for links and their tooltips with 213 * the "activate-link" signal and the gtk_label_get_current_uri() function. 214 */ 215 public class Label : Misc 216 { 217 218 /** the main Gtk struct */ 219 protected GtkLabel* gtkLabel; 220 221 222 /** Get the main Gtk struct */ 223 public GtkLabel* getLabelStruct() 224 { 225 return gtkLabel; 226 } 227 228 229 /** the main Gtk struct as a void* */ 230 protected override void* getStruct() 231 { 232 return cast(void*)gtkLabel; 233 } 234 235 /** 236 * Sets our main struct and passes it to the parent class 237 */ 238 public this (GtkLabel* gtkLabel) 239 { 240 super(cast(GtkMisc*)gtkLabel); 241 this.gtkLabel = gtkLabel; 242 } 243 244 protected override void setStruct(GObject* obj) 245 { 246 super.setStruct(obj); 247 gtkLabel = cast(GtkLabel*)obj; 248 } 249 250 /** 251 * Creates a new GtkLabel, containing the text in str. 252 * If characters in str are preceded by an underscore, they are 253 * underlined. If you need a literal underscore character in a label, use 254 * '__' (two underscores). The first underlined character represents a 255 * keyboard accelerator called a mnemonic. The mnemonic key can be used 256 * to activate another widget, chosen automatically, or explicitly using 257 * gtk_label_set_mnemonic_widget(). 258 * If gtk_label_set_mnemonic_widget() 259 * is not called, then the first activatable ancestor of the GtkLabel 260 * will be chosen as the mnemonic widget. For instance, if the 261 * label is inside a button or menu item, the button or menu item will 262 * automatically become the mnemonic widget and be activated by 263 * the mnemonic. 264 * Params: 265 * str = The text of the label, with an underscore in front of the 266 * mnemonic character 267 * mnemonic = when false uses the literal text passed in without mnemonic 268 * Throws: ConstructionException GTK+ fails to create the object. 269 */ 270 public this (string str, bool mnemonic=true) 271 { 272 GtkLabel* p; 273 274 if ( mnemonic ) 275 { 276 // GtkWidget* gtk_label_new_with_mnemonic (const gchar *str); 277 p = cast(GtkLabel*)gtk_label_new_with_mnemonic(Str.toStringz(str)); 278 } 279 else 280 { 281 // GtkWidget* gtk_label_new (const gchar *str); 282 p = cast(GtkLabel*)gtk_label_new(Str.toStringz(str)); 283 } 284 285 if(p is null) 286 { 287 throw new ConstructionException("null returned by gtk_label_new"); 288 } 289 290 this(p); 291 } 292 293 /** 294 */ 295 int[string] connectedSignals; 296 297 void delegate(Label)[] onActivateCurrentLinkListeners; 298 /** 299 * A keybinding signal 300 * which gets emitted when the user activates a link in the label. 301 * Applications may also emit the signal with g_signal_emit_by_name() 302 * if they need to control activation of URIs programmatically. 303 * The default bindings for this signal are all forms of the Enter key. 304 * Since 2.18 305 */ 306 void addOnActivateCurrentLink(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 307 { 308 if ( !("activate-current-link" in connectedSignals) ) 309 { 310 Signals.connectData( 311 getStruct(), 312 "activate-current-link", 313 cast(GCallback)&callBackActivateCurrentLink, 314 cast(void*)this, 315 null, 316 connectFlags); 317 connectedSignals["activate-current-link"] = 1; 318 } 319 onActivateCurrentLinkListeners ~= dlg; 320 } 321 extern(C) static void callBackActivateCurrentLink(GtkLabel* labelStruct, Label _label) 322 { 323 foreach ( void delegate(Label) dlg ; _label.onActivateCurrentLinkListeners ) 324 { 325 dlg(_label); 326 } 327 } 328 329 bool delegate(string, Label)[] onActivateLinkListeners; 330 /** 331 * The signal which gets emitted to activate a URI. 332 * Applications may connect to it to override the default behaviour, 333 * which is to call gtk_show_uri(). 334 * TRUE if the link has been activated 335 * Since 2.18 336 */ 337 void addOnActivateLink(bool delegate(string, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 338 { 339 if ( !("activate-link" in connectedSignals) ) 340 { 341 Signals.connectData( 342 getStruct(), 343 "activate-link", 344 cast(GCallback)&callBackActivateLink, 345 cast(void*)this, 346 null, 347 connectFlags); 348 connectedSignals["activate-link"] = 1; 349 } 350 onActivateLinkListeners ~= dlg; 351 } 352 extern(C) static gboolean callBackActivateLink(GtkLabel* labelStruct, gchar* uri, Label _label) 353 { 354 foreach ( bool delegate(string, Label) dlg ; _label.onActivateLinkListeners ) 355 { 356 if ( dlg(Str.toString(uri), _label) ) 357 { 358 return 1; 359 } 360 } 361 362 return 0; 363 } 364 365 void delegate(Label)[] onCopyClipboardListeners; 366 /** 367 * The ::copy-clipboard signal is a 368 * keybinding signal 369 * which gets emitted to copy the selection to the clipboard. 370 * The default binding for this signal is Ctrl-c. 371 */ 372 void addOnCopyClipboard(void delegate(Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 373 { 374 if ( !("copy-clipboard" in connectedSignals) ) 375 { 376 Signals.connectData( 377 getStruct(), 378 "copy-clipboard", 379 cast(GCallback)&callBackCopyClipboard, 380 cast(void*)this, 381 null, 382 connectFlags); 383 connectedSignals["copy-clipboard"] = 1; 384 } 385 onCopyClipboardListeners ~= dlg; 386 } 387 extern(C) static void callBackCopyClipboard(GtkLabel* labelStruct, Label _label) 388 { 389 foreach ( void delegate(Label) dlg ; _label.onCopyClipboardListeners ) 390 { 391 dlg(_label); 392 } 393 } 394 395 void delegate(GtkMovementStep, gint, gboolean, Label)[] onMoveCursorListeners; 396 /** 397 * The ::move-cursor signal is a 398 * keybinding signal 399 * which gets emitted when the user initiates a cursor movement. 400 * If the cursor is not visible in entry, this signal causes 401 * the viewport to be moved instead. 402 * Applications should not connect to it, but may emit it with 403 * g_signal_emit_by_name() if they need to control the cursor 404 * programmatically. 405 * The default bindings for this signal come in two variants, 406 * the variant with the Shift modifier extends the selection, 407 * the variant without the Shift modifer does not. 408 * There are too many key combinations to list them all here. 409 * Arrow keys move by individual characters/lines 410 * Ctrl-arrow key combinations move by words/paragraphs 411 * Home/End keys move to the ends of the buffer 412 * TRUE if the move should extend the selection 413 */ 414 void addOnMoveCursor(void delegate(GtkMovementStep, gint, gboolean, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 415 { 416 if ( !("move-cursor" in connectedSignals) ) 417 { 418 Signals.connectData( 419 getStruct(), 420 "move-cursor", 421 cast(GCallback)&callBackMoveCursor, 422 cast(void*)this, 423 null, 424 connectFlags); 425 connectedSignals["move-cursor"] = 1; 426 } 427 onMoveCursorListeners ~= dlg; 428 } 429 extern(C) static void callBackMoveCursor(GtkLabel* entryStruct, GtkMovementStep step, gint count, gboolean extendSelection, Label _label) 430 { 431 foreach ( void delegate(GtkMovementStep, gint, gboolean, Label) dlg ; _label.onMoveCursorListeners ) 432 { 433 dlg(step, count, extendSelection, _label); 434 } 435 } 436 437 void delegate(Menu, Label)[] onPopulatePopupListeners; 438 /** 439 * The ::populate-popup signal gets emitted before showing the 440 * context menu of the label. Note that only selectable labels 441 * have context menus. 442 * If you need to add items to the context menu, connect 443 * to this signal and append your menuitems to the menu. 444 */ 445 void addOnPopulatePopup(void delegate(Menu, Label) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 446 { 447 if ( !("populate-popup" in connectedSignals) ) 448 { 449 Signals.connectData( 450 getStruct(), 451 "populate-popup", 452 cast(GCallback)&callBackPopulatePopup, 453 cast(void*)this, 454 null, 455 connectFlags); 456 connectedSignals["populate-popup"] = 1; 457 } 458 onPopulatePopupListeners ~= dlg; 459 } 460 extern(C) static void callBackPopulatePopup(GtkLabel* labelStruct, GtkMenu* menu, Label _label) 461 { 462 foreach ( void delegate(Menu, Label) dlg ; _label.onPopulatePopupListeners ) 463 { 464 dlg(ObjectG.getDObject!(Menu)(menu), _label); 465 } 466 } 467 468 469 /** 470 * Sets the text within the GtkLabel widget. It overwrites any text that 471 * was there before. 472 * This will also clear any previously set mnemonic accelerators. 473 * Params: 474 * str = The text you want to set 475 */ 476 public void setText(string str) 477 { 478 // void gtk_label_set_text (GtkLabel *label, const gchar *str); 479 gtk_label_set_text(gtkLabel, Str.toStringz(str)); 480 } 481 482 /** 483 * Sets a PangoAttrList; the attributes in the list are applied to the 484 * label text. 485 * Note 486 * The attributes set with this function will be applied 487 * and merged with any other attributes previously effected by way 488 * of the "use-underline" or "use-markup" properties. 489 * While it is not recommended to mix markup strings with manually set 490 * attributes, if you must; know that the attributes will be applied 491 * to the label after the markup string is parsed. 492 * Params: 493 * attrs = a PangoAttrList 494 */ 495 public void setAttributes(PgAttributeList attrs) 496 { 497 // void gtk_label_set_attributes (GtkLabel *label, PangoAttrList *attrs); 498 gtk_label_set_attributes(gtkLabel, (attrs is null) ? null : attrs.getPgAttributeListStruct()); 499 } 500 501 /** 502 * Parses str which is marked up with the Pango text markup language, setting the 503 * label's text and attribute list based on the parse results. If the str is 504 * external data, you may need to escape it with g_markup_escape_text() or 505 * Params: 506 * str = a markup string (see Pango markup format) 507 */ 508 public void setMarkup(string str) 509 { 510 // void gtk_label_set_markup (GtkLabel *label, const gchar *str); 511 gtk_label_set_markup(gtkLabel, Str.toStringz(str)); 512 } 513 514 /** 515 * Parses str which is marked up with the 516 * Pango text markup language, 517 * setting the label's text and attribute list based on the parse results. 518 * If characters in str are preceded by an underscore, they are underlined 519 * indicating that they represent a keyboard accelerator called a mnemonic. 520 * The mnemonic key can be used to activate another widget, chosen 521 * automatically, or explicitly using gtk_label_set_mnemonic_widget(). 522 * Params: 523 * str = a markup string (see 524 * Pango markup format) 525 */ 526 public void setMarkupWithMnemonic(string str) 527 { 528 // void gtk_label_set_markup_with_mnemonic (GtkLabel *label, const gchar *str); 529 gtk_label_set_markup_with_mnemonic(gtkLabel, Str.toStringz(str)); 530 } 531 532 /** 533 * The pattern of underlines you want under the existing text within the 534 * GtkLabel widget. For example if the current text of the label says 535 * "FooBarBaz" passing a pattern of "___ ___" will underline 536 * "Foo" and "Baz" but not "Bar". 537 * Params: 538 * pattern = The pattern as described above. 539 */ 540 public void setPattern(string pattern) 541 { 542 // void gtk_label_set_pattern (GtkLabel *label, const gchar *pattern); 543 gtk_label_set_pattern(gtkLabel, Str.toStringz(pattern)); 544 } 545 546 /** 547 * Sets the alignment of the lines in the text of the label relative to 548 * each other. GTK_JUSTIFY_LEFT is the default value when the 549 * widget is first created with gtk_label_new(). If you instead want 550 * to set the alignment of the label as a whole, use 551 * gtk_misc_set_alignment() instead. gtk_label_set_justify() has no 552 * effect on labels containing only a single line. 553 * Params: 554 * jtype = a GtkJustification 555 */ 556 public void setJustify(GtkJustification jtype) 557 { 558 // void gtk_label_set_justify (GtkLabel *label, GtkJustification jtype); 559 gtk_label_set_justify(gtkLabel, jtype); 560 } 561 562 /** 563 * Sets the mode used to ellipsize (add an ellipsis: "...") to the text 564 * if there is not enough space to render the entire string. 565 * Since 2.6 566 * Params: 567 * mode = a PangoEllipsizeMode 568 */ 569 public void setEllipsize(PangoEllipsizeMode mode) 570 { 571 // void gtk_label_set_ellipsize (GtkLabel *label, PangoEllipsizeMode mode); 572 gtk_label_set_ellipsize(gtkLabel, mode); 573 } 574 575 /** 576 * Sets the desired width in characters of label to n_chars. 577 * Since 2.6 578 * Params: 579 * nChars = the new desired width, in characters. 580 */ 581 public void setWidthChars(int nChars) 582 { 583 // void gtk_label_set_width_chars (GtkLabel *label, gint n_chars); 584 gtk_label_set_width_chars(gtkLabel, nChars); 585 } 586 587 /** 588 * Sets the desired maximum width in characters of label to n_chars. 589 * Since 2.6 590 * Params: 591 * nChars = the new desired maximum width, in characters. 592 */ 593 public void setMaxWidthChars(int nChars) 594 { 595 // void gtk_label_set_max_width_chars (GtkLabel *label, gint n_chars); 596 gtk_label_set_max_width_chars(gtkLabel, nChars); 597 } 598 599 /** 600 * Toggles line wrapping within the GtkLabel widget. TRUE makes it break 601 * lines if text exceeds the widget's size. FALSE lets the text get cut off 602 * by the edge of the widget if it exceeds the widget size. 603 * Note that setting line wrapping to TRUE does not make the label 604 * wrap at its parent container's width, because GTK+ widgets 605 * conceptually can't make their requisition depend on the parent 606 * container's size. For a label that wraps at a specific position, 607 * set the label's width using gtk_widget_set_size_request(). 608 * Params: 609 * wrap = the setting 610 */ 611 public void setLineWrap(int wrap) 612 { 613 // void gtk_label_set_line_wrap (GtkLabel *label, gboolean wrap); 614 gtk_label_set_line_wrap(gtkLabel, wrap); 615 } 616 617 /** 618 * If line wrapping is on (see gtk_label_set_line_wrap()) this controls how 619 * the line wrapping is done. The default is PANGO_WRAP_WORD which means 620 * wrap on word boundaries. 621 * Since 2.10 622 * Params: 623 * wrapMode = the line wrapping mode 624 */ 625 public void setLineWrapMode(PangoWrapMode wrapMode) 626 { 627 // void gtk_label_set_line_wrap_mode (GtkLabel *label, PangoWrapMode wrap_mode); 628 gtk_label_set_line_wrap_mode(gtkLabel, wrapMode); 629 } 630 631 /** 632 * Sets the number of lines to which an ellipsized, wrapping label 633 * should be limited. This has no effect if the label is not wrapping 634 * or ellipsized. Set this to -1 if you don't want to limit the 635 * number of lines. 636 * Params: 637 * lines = the desired number of lines, or -1 638 * Since 3.10 639 */ 640 public void setLines(int lines) 641 { 642 // void gtk_label_set_lines (GtkLabel *label, gint lines); 643 gtk_label_set_lines(gtkLabel, lines); 644 } 645 646 /** 647 * Obtains the coordinates where the label will draw the PangoLayout 648 * representing the text in the label; useful to convert mouse events 649 * into coordinates inside the PangoLayout, e.g. to take some action 650 * if some part of the label is clicked. Of course you will need to 651 * create a GtkEventBox to receive the events, and pack the label 652 * inside it, since labels are a GTK_NO_WINDOW widget. Remember 653 * when using the PangoLayout functions you need to convert to 654 * and from pixels using PANGO_PIXELS() or PANGO_SCALE. 655 * Params: 656 * x = location to store X offset of layout, or NULL. [out][allow-none] 657 * y = location to store Y offset of layout, or NULL. [out][allow-none] 658 */ 659 public void getLayoutOffsets(out int x, out int y) 660 { 661 // void gtk_label_get_layout_offsets (GtkLabel *label, gint *x, gint *y); 662 gtk_label_get_layout_offsets(gtkLabel, &x, &y); 663 } 664 665 /** 666 * If the label has been set so that it has an mnemonic key this function 667 * returns the keyval used for the mnemonic accelerator. If there is no 668 * mnemonic set up it returns GDK_KEY_VoidSymbol. 669 * Returns: GDK keyval usable for accelerators, or GDK_KEY_VoidSymbol 670 */ 671 public uint getMnemonicKeyval() 672 { 673 // guint gtk_label_get_mnemonic_keyval (GtkLabel *label); 674 return gtk_label_get_mnemonic_keyval(gtkLabel); 675 } 676 677 /** 678 * Gets the value set by gtk_label_set_selectable(). 679 * Returns: TRUE if the user can copy text from the label 680 */ 681 public int getSelectable() 682 { 683 // gboolean gtk_label_get_selectable (GtkLabel *label); 684 return gtk_label_get_selectable(gtkLabel); 685 } 686 687 /** 688 * Fetches the text from a label widget, as displayed on the 689 * screen. This does not include any embedded underlines 690 * indicating mnemonics or Pango markup. (See gtk_label_get_label()) 691 * Returns: the text in the label widget. This is the internal string used by the label, and must not be modified. 692 */ 693 public string getText() 694 { 695 // const gchar * gtk_label_get_text (GtkLabel *label); 696 return Str.toString(gtk_label_get_text(gtkLabel)); 697 } 698 699 /** 700 * Selects a range of characters in the label, if the label is selectable. 701 * See gtk_label_set_selectable(). If the label is not selectable, 702 * this function has no effect. If start_offset or 703 * end_offset are -1, then the end of the label will be substituted. 704 * Params: 705 * startOffset = start offset (in characters not bytes) 706 * endOffset = end offset (in characters not bytes) 707 */ 708 public void selectRegion(int startOffset, int endOffset) 709 { 710 // void gtk_label_select_region (GtkLabel *label, gint start_offset, gint end_offset); 711 gtk_label_select_region(gtkLabel, startOffset, endOffset); 712 } 713 714 /** 715 * If the label has been set so that it has an mnemonic key (using 716 * i.e. gtk_label_set_markup_with_mnemonic(), 717 * gtk_label_set_text_with_mnemonic(), gtk_label_new_with_mnemonic() 718 * or the "use_underline" property) the label can be associated with a 719 * widget that is the target of the mnemonic. When the label is inside 720 * a widget (like a GtkButton or a GtkNotebook tab) it is 721 * automatically associated with the correct widget, but sometimes 722 * (i.e. when the target is a GtkEntry next to the label) you need to 723 * set it explicitly using this function. 724 * The target widget will be accelerated by emitting the 725 * GtkWidget::mnemonic-activate signal on it. The default handler for 726 * this signal will activate the widget if there are no mnemonic collisions 727 * and toggle focus between the colliding widgets otherwise. 728 * Params: 729 * widget = the target GtkWidget. [allow-none] 730 */ 731 public void setMnemonicWidget(Widget widget) 732 { 733 // void gtk_label_set_mnemonic_widget (GtkLabel *label, GtkWidget *widget); 734 gtk_label_set_mnemonic_widget(gtkLabel, (widget is null) ? null : widget.getWidgetStruct()); 735 } 736 737 /** 738 * Selectable labels allow the user to select text from the label, for 739 * copy-and-paste. 740 * Params: 741 * setting = TRUE to allow selecting text in the label 742 */ 743 public void setSelectable(int setting) 744 { 745 // void gtk_label_set_selectable (GtkLabel *label, gboolean setting); 746 gtk_label_set_selectable(gtkLabel, setting); 747 } 748 749 /** 750 * Sets the label's text from the string str. 751 * If characters in str are preceded by an underscore, they are underlined 752 * indicating that they represent a keyboard accelerator called a mnemonic. 753 * The mnemonic key can be used to activate another widget, chosen 754 * automatically, or explicitly using gtk_label_set_mnemonic_widget(). 755 * Params: 756 * str = a string 757 */ 758 public void setTextWithMnemonic(string str) 759 { 760 // void gtk_label_set_text_with_mnemonic (GtkLabel *label, const gchar *str); 761 gtk_label_set_text_with_mnemonic(gtkLabel, Str.toStringz(str)); 762 } 763 764 /** 765 * Gets the attribute list that was set on the label using 766 * gtk_label_set_attributes(), if any. This function does 767 * not reflect attributes that come from the labels markup 768 * (see gtk_label_set_markup()). If you want to get the 769 * effective attributes for the label, use 770 * pango_layout_get_attribute (gtk_label_get_layout (label)). 771 * Returns: the attribute list, or NULL if none was set. [transfer none] 772 */ 773 public PgAttributeList getAttributes() 774 { 775 // PangoAttrList * gtk_label_get_attributes (GtkLabel *label); 776 auto p = gtk_label_get_attributes(gtkLabel); 777 778 if(p is null) 779 { 780 return null; 781 } 782 783 return ObjectG.getDObject!(PgAttributeList)(cast(PangoAttrList*) p); 784 } 785 786 /** 787 * Returns the justification of the label. See gtk_label_set_justify(). 788 * Returns: GtkJustification 789 */ 790 public GtkJustification getJustify() 791 { 792 // GtkJustification gtk_label_get_justify (GtkLabel *label); 793 return gtk_label_get_justify(gtkLabel); 794 } 795 796 /** 797 * Returns the ellipsizing position of the label. See gtk_label_set_ellipsize(). 798 * Since 2.6 799 * Returns: PangoEllipsizeMode 800 */ 801 public PangoEllipsizeMode getEllipsize() 802 { 803 // PangoEllipsizeMode gtk_label_get_ellipsize (GtkLabel *label); 804 return gtk_label_get_ellipsize(gtkLabel); 805 } 806 807 /** 808 * Retrieves the desired width of label, in characters. See 809 * gtk_label_set_width_chars(). 810 * Since 2.6 811 * Returns: the width of the label in characters. 812 */ 813 public int getWidthChars() 814 { 815 // gint gtk_label_get_width_chars (GtkLabel *label); 816 return gtk_label_get_width_chars(gtkLabel); 817 } 818 819 /** 820 * Retrieves the desired maximum width of label, in characters. See 821 * gtk_label_set_width_chars(). 822 * Since 2.6 823 * Returns: the maximum width of the label in characters. 824 */ 825 public int getMaxWidthChars() 826 { 827 // gint gtk_label_get_max_width_chars (GtkLabel *label); 828 return gtk_label_get_max_width_chars(gtkLabel); 829 } 830 831 /** 832 * Fetches the text from a label widget including any embedded 833 * underlines indicating mnemonics and Pango markup. (See 834 * gtk_label_get_text()). 835 * Returns: the text of the label widget. This string is owned by the widget and must not be modified or freed. 836 */ 837 public string getLabel() 838 { 839 // const gchar * gtk_label_get_label (GtkLabel *label); 840 return Str.toString(gtk_label_get_label(gtkLabel)); 841 } 842 843 /** 844 * Gets the PangoLayout used to display the label. 845 * The layout is useful to e.g. convert text positions to 846 * pixel positions, in combination with gtk_label_get_layout_offsets(). 847 * The returned layout is owned by the label so need not be 848 * freed by the caller. The label is free to recreate its layout at 849 * any time, so it should be considered read-only. 850 * Returns: the PangoLayout for this label. [transfer none] 851 */ 852 public PgLayout getLayout() 853 { 854 // PangoLayout * gtk_label_get_layout (GtkLabel *label); 855 auto p = gtk_label_get_layout(gtkLabel); 856 857 if(p is null) 858 { 859 return null; 860 } 861 862 return ObjectG.getDObject!(PgLayout)(cast(PangoLayout*) p); 863 } 864 865 /** 866 * Returns whether lines in the label are automatically wrapped. 867 * See gtk_label_set_line_wrap(). 868 * Returns: TRUE if the lines of the label are automatically wrapped. 869 */ 870 public int getLineWrap() 871 { 872 // gboolean gtk_label_get_line_wrap (GtkLabel *label); 873 return gtk_label_get_line_wrap(gtkLabel); 874 } 875 876 /** 877 * Returns line wrap mode used by the label. See gtk_label_set_line_wrap_mode(). 878 * Since 2.10 879 * Returns: TRUE if the lines of the label are automatically wrapped. 880 */ 881 public PangoWrapMode getLineWrapMode() 882 { 883 // PangoWrapMode gtk_label_get_line_wrap_mode (GtkLabel *label); 884 return gtk_label_get_line_wrap_mode(gtkLabel); 885 } 886 887 /** 888 * Gets the number of lines to which an ellipsized, wrapping 889 * label should be limited. See gtk_label_set_lines(). 890 * Returns: The number of lines Since 3.10 891 */ 892 public int getLines() 893 { 894 // gint gtk_label_get_lines (GtkLabel *label); 895 return gtk_label_get_lines(gtkLabel); 896 } 897 898 /** 899 * Retrieves the target of the mnemonic (keyboard shortcut) of this 900 * label. See gtk_label_set_mnemonic_widget(). 901 * Returns: the target of the label's mnemonic, or NULL if none has been set and the default algorithm will be used. [transfer none] 902 */ 903 public Widget getMnemonicWidget() 904 { 905 // GtkWidget * gtk_label_get_mnemonic_widget (GtkLabel *label); 906 auto p = gtk_label_get_mnemonic_widget(gtkLabel); 907 908 if(p is null) 909 { 910 return null; 911 } 912 913 return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p); 914 } 915 916 /** 917 * Gets the selected range of characters in the label, returning TRUE 918 * if there's a selection. 919 * Params: 920 * start = return location for start of selection, as a character offset. [out] 921 * end = return location for end of selection, as a character offset. [out] 922 * Returns: TRUE if selection is non-empty 923 */ 924 public int getSelectionBounds(out int start, out int end) 925 { 926 // gboolean gtk_label_get_selection_bounds (GtkLabel *label, gint *start, gint *end); 927 return gtk_label_get_selection_bounds(gtkLabel, &start, &end); 928 } 929 930 /** 931 * Returns whether the label's text is interpreted as marked up with 932 * the Pango text markup 933 * language. See gtk_label_set_use_markup(). 934 * Returns: TRUE if the label's text will be parsed for markup. 935 */ 936 public int getUseMarkup() 937 { 938 // gboolean gtk_label_get_use_markup (GtkLabel *label); 939 return gtk_label_get_use_markup(gtkLabel); 940 } 941 942 /** 943 * Returns whether an embedded underline in the label indicates a 944 * mnemonic. See gtk_label_set_use_underline(). 945 * Returns: TRUE whether an embedded underline in the label indicates the mnemonic accelerator keys. 946 */ 947 public int getUseUnderline() 948 { 949 // gboolean gtk_label_get_use_underline (GtkLabel *label); 950 return gtk_label_get_use_underline(gtkLabel); 951 } 952 953 /** 954 * Returns whether the label is in single line mode. 955 * Since 2.6 956 * Returns: TRUE when the label is in single line mode. 957 */ 958 public int getSingleLineMode() 959 { 960 // gboolean gtk_label_get_single_line_mode (GtkLabel *label); 961 return gtk_label_get_single_line_mode(gtkLabel); 962 } 963 964 /** 965 * Gets the angle of rotation for the label. See 966 * gtk_label_set_angle(). 967 * Since 2.6 968 * Returns: the angle of rotation for the label 969 */ 970 public double getAngle() 971 { 972 // gdouble gtk_label_get_angle (GtkLabel *label); 973 return gtk_label_get_angle(gtkLabel); 974 } 975 976 /** 977 * Sets the text of the label. The label is interpreted as 978 * including embedded underlines and/or Pango markup depending 979 * on the values of the "use-underline"" and 980 * "use-markup" properties. 981 * Params: 982 * str = the new text to set for the label 983 */ 984 public void setLabel(string str) 985 { 986 // void gtk_label_set_label (GtkLabel *label, const gchar *str); 987 gtk_label_set_label(gtkLabel, Str.toStringz(str)); 988 } 989 990 /** 991 * Sets whether the text of the label contains markup in Pango's text markup 992 * language. See gtk_label_set_markup(). 993 * Params: 994 * setting = TRUE if the label's text should be parsed for markup. 995 */ 996 public void setUseMarkup(int setting) 997 { 998 // void gtk_label_set_use_markup (GtkLabel *label, gboolean setting); 999 gtk_label_set_use_markup(gtkLabel, setting); 1000 } 1001 1002 /** 1003 * If true, an underline in the text indicates the next character should be 1004 * used for the mnemonic accelerator key. 1005 * Params: 1006 * setting = TRUE if underlines in the text indicate mnemonics 1007 */ 1008 public void setUseUnderline(int setting) 1009 { 1010 // void gtk_label_set_use_underline (GtkLabel *label, gboolean setting); 1011 gtk_label_set_use_underline(gtkLabel, setting); 1012 } 1013 1014 /** 1015 * Sets whether the label is in single line mode. 1016 * Since 2.6 1017 * Params: 1018 * singleLineMode = TRUE if the label should be in single line mode 1019 */ 1020 public void setSingleLineMode(int singleLineMode) 1021 { 1022 // void gtk_label_set_single_line_mode (GtkLabel *label, gboolean single_line_mode); 1023 gtk_label_set_single_line_mode(gtkLabel, singleLineMode); 1024 } 1025 1026 /** 1027 * Sets the angle of rotation for the label. An angle of 90 reads from 1028 * from bottom to top, an angle of 270, from top to bottom. The angle 1029 * setting for the label is ignored if the label is selectable, 1030 * wrapped, or ellipsized. 1031 * Since 2.6 1032 * Params: 1033 * angle = the angle that the baseline of the label makes with 1034 * the horizontal, in degrees, measured counterclockwise 1035 */ 1036 public void setAngle(double angle) 1037 { 1038 // void gtk_label_set_angle (GtkLabel *label, gdouble angle); 1039 gtk_label_set_angle(gtkLabel, angle); 1040 } 1041 1042 /** 1043 * Returns the URI for the currently active link in the label. 1044 * The active link is the one under the mouse pointer or, in a 1045 * selectable label, the link in which the text cursor is currently 1046 * positioned. 1047 * This function is intended for use in a "activate-link" handler 1048 * or for use in a "query-tooltip" handler. 1049 * Since 2.18 1050 * Returns: the currently active URI. The string is owned by GTK+ and must not be freed or modified. 1051 */ 1052 public string getCurrentUri() 1053 { 1054 // const gchar * gtk_label_get_current_uri (GtkLabel *label); 1055 return Str.toString(gtk_label_get_current_uri(gtkLabel)); 1056 } 1057 1058 /** 1059 * Sets whether the label should keep track of clicked 1060 * links (and use a different color for them). 1061 * Since 2.18 1062 * Params: 1063 * trackLinks = TRUE to track visited links 1064 */ 1065 public void setTrackVisitedLinks(int trackLinks) 1066 { 1067 // void gtk_label_set_track_visited_links (GtkLabel *label, gboolean track_links); 1068 gtk_label_set_track_visited_links(gtkLabel, trackLinks); 1069 } 1070 1071 /** 1072 * Returns whether the label is currently keeping track 1073 * of clicked links. 1074 * Since 2.18 1075 * Returns: TRUE if clicked links are remembered 1076 */ 1077 public int getTrackVisitedLinks() 1078 { 1079 // gboolean gtk_label_get_track_visited_links (GtkLabel *label); 1080 return gtk_label_get_track_visited_links(gtkLabel); 1081 } 1082 }