comparison dynamin/gui/silver_theme.d @ 106:acdbb30fee7e

Port to D2. Most of the effort was dealing with immutable and const.
author Jordan Miner <jminer7@gmail.com>
date Mon, 17 Dec 2012 23:41:50 -0600
parents 5c8c1c2e12c0
children
comparison
equal deleted inserted replaced
105:97997a544ac0 106:acdbb30fee7e
26 * - Light Silver (220, 220, 220) 26 * - Light Silver (220, 220, 220)
27 * - Dark Silver (170, 170, 170) 27 * - Dark Silver (170, 170, 170)
28 * - (150, 150, 150) 28 * - (150, 150, 150)
29 */ 29 */
30 class SilverTheme : Theme { 30 class SilverTheme : Theme {
31 string name() { 31 override string name() {
32 return "Silver"; 32 return "Silver";
33 } 33 }
34 34
35 void Window_paint(Window c, Graphics g) { 35 override void Window_paint(Window c, Graphics g) {
36 g.source = Color.Silver; 36 g.source = Color.Silver;
37 g.paint(); 37 g.paint();
38 } 38 }
39 Size Button_bestSize(Button c) { 39 override Size Button_bestSize(Button c) {
40 return Size(70, 25); 40 return Size(70, 25);
41 } 41 }
42 42
43 private Color _silver = Color(192, 192, 192); 43 private Color _silver = Color(192, 192, 192);
44 private Color _lightSilver = Color(220, 220, 220); 44 private Color _lightSilver = Color(220, 220, 220);
72 stroke(); 72 stroke();
73 } 73 }
74 } 74 }
75 //}}} 75 //}}}
76 76
77 void Button_paint(Button c, Graphics g) { 77 override void Button_paint(Button c, Graphics g) {
78 with(g) { 78 with(g) {
79 drawButtonBack(g, 0, 0, c.width, c.height, c.state); 79 drawButtonBack(g, 0, 0, c.width, c.height, c.state);
80 source = _black; 80 source = _black;
81 c.paintFore(g); 81 c.paintFore(g);
82 } 82 }
83 } 83 }
84 84
85 void CheckBox_paint(CheckBox c, Graphics g) { 85 override void CheckBox_paint(CheckBox c, Graphics g) {
86 with(g) { 86 with(g) {
87 Point box = Point(2, cast(int)(c.height/2-6)); 87 Point box = Point(2, cast(int)(c.height/2-6));
88 fontSize = 13; 88 fontSize = 13;
89 drawText(c.text, box.x+18, 2); 89 drawText(c.text, box.x+18, 2);
90 90
106 relLineTo(6, -8); 106 relLineTo(6, -8);
107 stroke(); 107 stroke();
108 } 108 }
109 } 109 }
110 } 110 }
111 void RadioButton_paint(CheckBox c, Graphics g) { 111 override void RadioButton_paint(CheckBox c, Graphics g) {
112 with(g) { 112 with(g) {
113 int radius = 6; 113 int radius = 6;
114 Point circle = Point(2, cast(int)(c.height/2-radius)); 114 Point circle = Point(2, cast(int)(c.height/2-radius));
115 fontSize = 13; 115 fontSize = 13;
116 drawText(c.text, circle.x+18, 2); 116 drawText(c.text, circle.x+18, 2);
134 fill(); 134 fill();
135 } 135 }
136 } 136 }
137 } 137 }
138 138
139 void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g) { 139 override void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g) {
140 if(c.state == ButtonState.Pressed) 140 if(c.state == ButtonState.Pressed)
141 g.paint(); 141 g.paint();
142 else if(isOdd(cast(int)round(c.x)) || isOdd(cast(int)round(c.y))) 142 else if(isOdd(cast(int)round(c.x)) || isOdd(cast(int)round(c.y)))
143 drawCheckerboard(g, 0, 0, c.width, c.height, 143 drawCheckerboard(g, 0, 0, c.width, c.height,
144 Color.White, Color.Black); 144 Color.White, Color.Black);
145 else 145 else
146 drawCheckerboard(g, 0, 0, c.width, c.height, 146 drawCheckerboard(g, 0, 0, c.width, c.height,
147 Color.Black, Color.White); 147 Color.Black, Color.White);
148 } 148 }
149 149
150 void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g) { 150 override void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g) {
151 with(g) { 151 with(g) {
152 source = Color.White; 152 source = Color.White;
153 paint(); 153 paint();
154 source = Color.Black; 154 source = Color.Black;
155 rectangle(0.5, 0.5, c.width-1, c.height-1); 155 rectangle(0.5, 0.5, c.width-1, c.height-1);
156 stroke(); 156 stroke();
157 } 157 }
158 } 158 }
159 159
160 double ScrollBar_size() { 160 override double ScrollBar_size() {
161 // TODO: all themes should get this from SystemGui.ScrollBarSize 161 // TODO: all themes should get this from SystemGui.ScrollBarSize
162 return 18; 162 return 18;
163 } 163 }
164 164
165 void ArrowButton_paint(ArrowButton c, Graphics g) { 165 override void ArrowButton_paint(ArrowButton c, Graphics g) {
166 Button_paint(c, g); 166 Button_paint(c, g);
167 } 167 }
168 168
169 BorderSize Scrollable_borderSize(Scrollable c) { 169 override BorderSize Scrollable_borderSize(Scrollable c) {
170 return BorderSize(1, 1, 1, 1); 170 return BorderSize(1, 1, 1, 1);
171 } 171 }
172 172
173 void Scrollable_paint(Scrollable c, Graphics g) { 173 override void Scrollable_paint(Scrollable c, Graphics g) {
174 g.source = Color.White; 174 g.source = Color.White;
175 g.paint(); 175 g.paint();
176 g.source = Color.Black; 176 g.source = Color.Black;
177 g.rectangle(0.5, 0.5, c.width-0.5, c.height-0.5); 177 g.rectangle(0.5, 0.5, c.width-0.5, c.height-0.5);
178 g.stroke(); 178 g.stroke();
179 } 179 }
180 180
181 BorderSize Notebook_borderSize(Notebook c) { 181 override BorderSize Notebook_borderSize(Notebook c) {
182 return BorderSize(1, 1, 1, 1); 182 return BorderSize(1, 1, 1, 1);
183 } 183 }
184 void Tab_paint(TabPage page, Notebook c, Graphics g){ 184 override void Tab_paint(TabPage page, Notebook c, Graphics g){
185 g.translate(page.tabLocation); 185 g.translate(page.tabLocation);
186 g.drawText(page.text, 5, (page.tabSize.height-g.getTextExtents(page.text).height)/2); 186 g.drawText(page.text, 5, (page.tabSize.height-g.getTextExtents(page.text).height)/2);
187 g.translate(-page.tabLocation); 187 g.translate(-page.tabLocation);
188 } 188 }
189 void Notebook_paint(Notebook c, Graphics g){} 189 override void Notebook_paint(Notebook c, Graphics g){}
190 190
191 } 191 }
192 192