1 /** 2 * Widget module. 3 * 4 * License: 5 * MIT. See LICENSE for full details. 6 */ 7 module tkd.widget.labelframe; 8 9 /** 10 * Imports. 11 */ 12 import tkd.element.uielement; 13 import tkd.widget.common.anchor; 14 import tkd.widget.common.height; 15 import tkd.widget.common.padding; 16 import tkd.widget.common.text; 17 import tkd.widget.common.underline; 18 import tkd.widget.common.width; 19 import tkd.widget.widget; 20 21 /** 22 * A label frame widget is a container used to group other widgets together. It 23 * has an optional label, which may be a plain text string or another widget. 24 * 25 * Example: 26 * --- 27 * auto labelFrame = new LabelFrame("Text") 28 * .pack(0, 10); 29 * 30 * // Add a button to the label frame. 31 * auto button = new Button(labelFrame, "Text") 32 * .pack(); 33 * --- 34 * 35 * Common_Commands: 36 * These are injected common commands that can also be used with this widget. 37 * $(P 38 * $(LINK2 ./common/anchor.html, Anchor) $(BR) 39 * $(LINK2 ./common/height.html, Height) $(BR) 40 * $(LINK2 ./common/padding.html, Padding) $(BR) 41 * $(LINK2 ./common/text.html, Text) $(BR) 42 * $(LINK2 ./common/underline.html, Underline) $(BR) 43 * $(LINK2 ./common/width.html, Width) $(BR) 44 * ) 45 * 46 * Additional_Events: 47 * Additional events that can also be bound to using the $(LINK2 ../element/uielement.html#UiElement.bind, bind) method. 48 * $(P 49 * <<Invoke>>, 50 * <<PrevWindow>>, 51 * <Alt-Key>, 52 * <Key-F10>, 53 * <Key-Tab>, 54 * ) 55 * 56 * See_Also: 57 * $(LINK2 ./widget.html, tkd.widget.widget) 58 */ 59 class LabelFrame : Widget 60 { 61 /** 62 * Construct the widget. 63 * 64 * Params: 65 * parent = The parent of this widget. 66 * text = The text of the widget. 67 * 68 * See_Also: 69 * $(LINK2 ../element/uielement.html, tkd.element.UiElement) $(BR) 70 */ 71 public this(UiElement parent, string text) 72 { 73 super(parent); 74 this._elementId = "labelframe"; 75 76 this._tk.eval("ttk::labelframe %s -text {%s}", this.id, text); 77 } 78 79 /** 80 * Construct the widget. 81 * 82 * Params: 83 * text = The text of the widget. 84 */ 85 public this(string text) 86 { 87 this(null, text); 88 } 89 90 /** 91 * Set a widget to use for the label. The widget must be a child of the 92 * labelframe widget or one of the labelframe's ancestors, and must belong 93 * to the same top-level widget as the labelframe. If set, overrides the 94 * text parameter. 95 * 96 * Params: 97 * widget = The widget to use as the label. 98 * 99 * Returns: 100 * This widget to aid method chaining. 101 */ 102 public auto setLabel(this T)(Widget widget) 103 { 104 this._tk.eval("%s configure -labelwidget %s", this.id, widget.id); 105 106 return cast(T) this; 107 } 108 109 /** 110 * Mixin common commands. 111 */ 112 mixin Anchor!("-labelanchor"); 113 mixin Height; 114 mixin Padding; 115 mixin Text; 116 mixin Underline; 117 mixin Width; 118 }