1 /** 2 * State module. 3 * 4 * License: 5 * MIT. See LICENSE for full details. 6 */ 7 module tkd.widget.common.canvas.state; 8 9 /** 10 * These are common commands that apply to all widgets that have them injected. 11 */ 12 mixin template State() 13 { 14 /** 15 * The state of the item. 16 */ 17 private string _state; 18 19 /** 20 * Get the state of this item. 21 * 22 * Returns: 23 * The state of this item. 24 */ 25 public string getState() 26 { 27 if (this._parent) 28 { 29 this._tk.eval("%s itemcget %s -state", this._parent.id, this.id); 30 this._state = this._tk.getResult!(string); 31 } 32 33 return this._state; 34 } 35 36 /** 37 * Set the item state. The only valid states are normal, disabled or 38 * hidden. 39 * 40 * Params: 41 * state = The state to set. 42 * 43 * Returns: 44 * This item to aid method chaining. 45 * 46 * See_Also: 47 * $(LINK2 ./state.html, tkd.widget.state) $(BR) 48 */ 49 public auto setState(this T)(string state) 50 { 51 this._state = state; 52 53 if (this._parent && this._state.length) 54 { 55 this._tk.eval("%s itemconfigure %s -state {%s}", this._parent.id, this.id, this._state); 56 } 57 58 return cast(T) this; 59 } 60 }