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