1 /** 2 * Widget module. 3 * 4 * License: 5 * MIT. See LICENSE for full details. 6 */ 7 module tkd.widget.label; 8 9 /** 10 * Imports. 11 */ 12 import tkd.element.uielement; 13 import tkd.widget.common.anchor; 14 import tkd.widget.common.color; 15 import tkd.widget.common.font; 16 import tkd.widget.common.justify; 17 import tkd.widget.common.padding; 18 import tkd.widget.common.relief; 19 import tkd.widget.common.wraplength; 20 import tkd.widget.textwidget; 21 22 /** 23 * A label widget displays a textual label and/or image. 24 * 25 * Example: 26 * --- 27 * auto label = new Label("Text") 28 * .pack(); 29 * --- 30 * 31 * Common_Commands: 32 * These are injected common commands that can also be used with this widget. 33 * $(P 34 * $(LINK2 ./common/anchor.html, Anchor) $(BR) 35 * $(LINK2 ./common/color.html, Color) $(BR) 36 * $(LINK2 ./common/font.html, Font) $(BR) 37 * $(LINK2 ./common/justify.html, Justify) $(BR) 38 * $(LINK2 ./common/padding.html, Padding) $(BR) 39 * $(LINK2 ./common/relief.html, Relief) $(BR) 40 * $(LINK2 ./common/wraplength.html, WrapLength) $(BR) 41 * ) 42 * 43 * Additional_Events: 44 * Additional events that can also be bound to using the $(LINK2 ../element/uielement.html#UiElement.bind, bind) method. 45 * $(P 46 * <<Invoke>>, 47 * <<PrevWindow>>, 48 * <Key-Tab>, 49 * <Key-F10>, 50 * <Alt-Key>, 51 * ) 52 * 53 * See_Also: 54 * $(LINK2 ./textwidget.html, tkd.widget.textwidget) 55 */ 56 class Label : TextWidget 57 { 58 /** 59 * Construct the widget. 60 * 61 * Params: 62 * parent = The parent of this widget. 63 * text = The text of the label. 64 * 65 * See_Also: 66 * $(LINK2 ../element/uielement.html, tkd.element.uielement) $(BR) 67 */ 68 this(UiElement parent, string text) 69 { 70 super(parent); 71 this._elementId = "label"; 72 73 this._tk.eval("ttk::label %s -textvariable %s", this.id, this._textVariable); 74 75 this.setText(text); 76 } 77 78 /** 79 * Construct the widget. 80 * 81 * Params: 82 * text = The text of the label. 83 */ 84 this(string text) 85 { 86 this(null, text); 87 } 88 89 /** 90 * Mixin common commands. 91 */ 92 mixin Anchor; 93 mixin Color; 94 mixin Font; 95 mixin Justify; 96 mixin Padding; 97 mixin Relief; 98 mixin WrapLength; 99 }