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