1 /** 2 * Color module. 3 * 4 * License: 5 * MIT. See LICENSE for full details. 6 */ 7 module tkd.widget.common.color; 8 9 /** 10 * These are common commands that apply to all widgets that have them injected. 11 */ 12 mixin template Color() 13 { 14 /** 15 * Set the foreground color of the widget. 16 * 17 * Params: 18 * color = The name of the color, e.g. 'black' or a hex value, e.g. '#000000'. 19 * 20 * Returns: 21 * This widget to aid method chaining. 22 * 23 * See_Also: 24 * $(LINK2 ../../element/color.html, tkd.element.color) for standard defined colors. 25 */ 26 public auto setForegroundColor(this T)(string color) 27 { 28 this._tk.eval("%s configure -foreground %s", this.id, color); 29 30 return cast(T) this; 31 } 32 33 /** 34 * Set the background color of the widget. 35 * 36 * Params: 37 * color = The name of the color, e.g. 'black' or a hex value, e.g. '#000000'. 38 * 39 * Returns: 40 * This widget to aid method chaining. 41 * 42 * See_Also: 43 * $(LINK2 ../../element/color.html, tkd.element.color) for standard defined colors. 44 */ 45 public auto setBackgroundColor(this T)(string color) 46 { 47 this._tk.eval("%s configure -background %s", this.id, color); 48 49 return cast(T) this; 50 } 51 52 /** 53 * Set the insert cursor color of the widget. 54 * 55 * Params: 56 * color = The name of the color, e.g. 'black' or a hex value, e.g. '#000000'. 57 * 58 * Returns: 59 * This widget to aid method chaining. 60 * 61 * See_Also: 62 * $(LINK2 ../../element/color.html, tkd.element.color) for standard defined colors. 63 */ 64 public auto setInsertColor(this T)(string color) 65 { 66 this._tk.eval("%s configure -insertbackground %s", this.id, color); 67 68 return cast(T) this; 69 } 70 }