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