1 /**
2  * Image specific module.
3  *
4  * License:
5  *     MIT. See LICENSE for full details.
6  */
7 module tkd.widget.common.canvas.imagespecific;
8 
9 /**
10  * These are common commands that apply to all widgets that have them injected.
11  */
12 mixin template ImageSpecific()
13 {
14 	/**
15 	 * The image.
16 	 */
17 	private Image _image;
18 
19 	/**
20 	 * The active image.
21 	 */
22 	private Image _activeImage;
23 
24 	/**
25 	 * The disabled image.
26 	 */
27 	private Image _disabledImage;
28 
29 	/**
30 	 * Get the image.
31 	 *
32 	 * Returns:
33 	 *     The image;
34 	 */
35 	public Image getImage()
36 	{
37 		return this._image;
38 	}
39 
40 	/**
41 	 * Set the image.
42 	 *
43 	 * Params:
44 	 *    image = The image.
45 	 *
46 	 * Returns:
47 	 *     This item to aid method chaining.
48 	 *
49 	 * See_Also:
50 	 *     $(LINK2 ../../../image/gif.html, tkd.image.gif) $(BR)
51 	 *     $(LINK2 ../../../image/image.html, tkd.image.image) $(BR)
52 	 *     $(LINK2 ../../../image/png.html, tkd.image.png) $(BR)
53 	 */
54 	public auto setImage(this T)(Image image)
55 	{
56 		this._image = image;
57 
58 		if (this._parent && this._image)
59 		{
60 			this._tk.eval("%s itemconfigure %s -image %s", this._parent.id, this.id, this._image.id);
61 		}
62 
63 		return cast(T) this;
64 	}
65 
66 	/**
67 	 * Get the active image.
68 	 *
69 	 * Returns:
70 	 *     The active image;
71 	 */
72 	public Image getActiveImage()
73 	{
74 		return this._activeImage;
75 	}
76 
77 	/**
78 	 * Set the active image.
79 	 *
80 	 * Params:
81 	 *    image = The active image.
82 	 *
83 	 * Returns:
84 	 *     This item to aid method chaining.
85 	 *
86 	 * See_Also:
87 	 *     $(LINK2 ../../../image/gif.html, tkd.image.gif) $(BR)
88 	 *     $(LINK2 ../../../image/image.html, tkd.image.image) $(BR)
89 	 *     $(LINK2 ../../../image/png.html, tkd.image.png) $(BR)
90 	 */
91 	public auto setActiveImage(this T)(Image image)
92 	{
93 		this._activeImage = image;
94 
95 		if (this._parent && this._activeImage)
96 		{
97 			this._tk.eval("%s itemconfigure %s -activeimage %s", this._parent.id, this.id, this._activeImage.id);
98 		}
99 
100 		return cast(T) this;
101 	}
102 
103 	/**
104 	 * Get the disabled image.
105 	 *
106 	 * Returns:
107 	 *     The disabled image;
108 	 */
109 	public Image getDisabledImage()
110 	{
111 		return this._disabledImage;
112 	}
113 
114 	/**
115 	 * Set the disabled image.
116 	 *
117 	 * Params:
118 	 *    image = The disabled image.
119 	 *
120 	 * Returns:
121 	 *     This item to aid method chaining.
122 	 *
123 	 * See_Also:
124 	 *     $(LINK2 ../../../image/gif.html, tkd.image.gif) $(BR)
125 	 *     $(LINK2 ../../../image/image.html, tkd.image.image) $(BR)
126 	 *     $(LINK2 ../../../image/png.html, tkd.image.png) $(BR)
127 	 */
128 	public auto setDisabledImage(this T)(Image image)
129 	{
130 		this._disabledImage = image;
131 
132 		if (this._parent && this._disabledImage)
133 		{
134 			this._tk.eval("%s itemconfigure %s -disabledimage %s", this._parent.id, this.id, this._disabledImage.id);
135 		}
136 
137 		return cast(T) this;
138 	}
139 }