1 /**
2  * Fill color module.
3  *
4  * License:
5  *     MIT. See LICENSE for full details.
6  */
7 module tkd.widget.common.canvas.fillcolor;
8 
9 /**
10  * These are common commands that apply to all widgets that have them injected.
11  */
12 mixin template FillColor()
13 {
14 	/**
15 	 * The fill color.
16 	 */
17 	private string _fillColor;
18 
19 	/**
20 	 * The active fill color.
21 	 */
22 	private string _activeFillColor;
23 
24 	/**
25 	 * The disabled fill color.
26 	 */
27 	private string _disabledFillColor;
28 
29 	/**
30 	 * Get the fill color.
31 	 *
32 	 * Returns:
33 	 *     The fill color;
34 	 */
35 	public string getFillColor()
36 	{
37 		if (this._parent)
38 		{
39 			this._tk.eval("%s itemcget %s -fill", this._parent.id, this.id);
40 			this._fillColor = this._tk.getResult!(string);
41 		}
42 
43 		return this._fillColor;
44 	}
45 
46 	/**
47 	 * Set the fill color.
48 	 * Use colors from the preset color $(LINK2 ../../../element/color.html, list) or a web style hex color.
49 	 *
50 	 * Params:
51 	 *    color = The fill color.
52 	 *
53 	 * Returns:
54 	 *     This widget to aid method chaining.
55 	 *
56 	 * See_Also:
57 	 *     $(LINK2 ../../../element/color.html, tkd.widget.color) $(BR)
58 	 */
59 	public auto setFillColor(this T)(string color)
60 	{
61 		this._fillColor = color;
62 
63 		if (this._parent && this._fillColor.length)
64 		{
65 			this._tk.eval("%s itemconfigure %s -fill {%s}", this._parent.id, this.id, this._fillColor);
66 		}
67 
68 		return cast(T) this;
69 	}
70 
71 	/**
72 	 * Get the active fill color.
73 	 * An item's active state is triggered when the mouse rolls over the item.
74 	 *
75 	 * Returns:
76 	 *     The active fill color;
77 	 */
78 	public string getActiveFillColor()
79 	{
80 		if (this._parent)
81 		{
82 			this._tk.eval("%s itemcget %s -activefill", this._parent.id, this.id);
83 			this._activeFillColor = this._tk.getResult!(string);
84 		}
85 
86 		return this._activeFillColor;
87 	}
88 
89 	/**
90 	 * Set the active fill color.
91 	 * An item's active state is triggered when the mouse rolls over the item.
92 	 * Use colors from the preset color $(LINK2 ../../../element/color.html, list) or a web style hex color.
93 	 *
94 	 * Params:
95 	 *    color = The fill color.
96 	 *
97 	 * Returns:
98 	 *     This widget to aid method chaining.
99 	 *
100 	 * See_Also:
101 	 *     $(LINK2 ../../../element/color.html, tkd.widget.color) $(BR)
102 	 */
103 	public auto setActiveFillColor(this T)(string color)
104 	{
105 		this._activeFillColor = color;
106 
107 		if (this._parent && this._activeFillColor.length)
108 		{
109 			this._tk.eval("%s itemconfigure %s -activefill {%s}", this._parent.id, this.id, this._activeFillColor);
110 		}
111 
112 		return cast(T) this;
113 	}
114 
115 	/**
116 	 * Get the disabled fill color.
117 	 *
118 	 * Returns:
119 	 *     The disabled fill color;
120 	 */
121 	public string getDisabledFillColor()
122 	{
123 		if (this._parent)
124 		{
125 			this._tk.eval("%s itemcget %s -disabledfill", this._parent.id, this.id);
126 			this._disabledFillColor = this._tk.getResult!(string);
127 		}
128 
129 		return this._disabledFillColor;
130 	}
131 
132 	/**
133 	 * Set the disabled fill color.
134 	 * Use colors from the preset color $(LINK2 ../../../element/color.html, list) or a web style hex color.
135 	 *
136 	 * Params:
137 	 *    color = The fill color.
138 	 *
139 	 * Returns:
140 	 *     This widget to aid method chaining.
141 	 *
142 	 * See_Also:
143 	 *     $(LINK2 ../../../element/color.html, tkd.widget.color) $(BR)
144 	 */
145 	public auto setDisabledFillColor(this T)(string color)
146 	{
147 		this._disabledFillColor = color;
148 
149 		if (this._parent && this._disabledFillColor.length)
150 		{
151 			this._tk.eval("%s itemconfigure %s -disabledfill {%s}", this._parent.id, this.id, this._disabledFillColor);
152 		}
153 
154 		return cast(T) this;
155 	}
156 }