comparison dynamin/gui/basic_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
25 * - black (0, 0, 0) 25 * - black (0, 0, 0)
26 * - light gray (220, 220, 220) 26 * - light gray (220, 220, 220)
27 * - dark gray (70, 70, 70) 27 * - dark gray (70, 70, 70)
28 */ 28 */
29 class BasicTheme : Theme { 29 class BasicTheme : Theme {
30 string name() { 30 override string name() {
31 return "Basic"; 31 return "Basic";
32 } 32 }
33 33
34 void Window_paint(Window c, Graphics g) { 34 override void Window_paint(Window c, Graphics g) {
35 g.source = Color.White; 35 g.source = Color.White;
36 g.paint(); 36 g.paint();
37 } 37 }
38 Size Button_bestSize(Button c) { 38 override Size Button_bestSize(Button c) {
39 return Size(60, 25); 39 return Size(60, 25);
40 } 40 }
41 41
42 void Button_paint(Button c, Graphics g) { 42 override void Button_paint(Button c, Graphics g) {
43 with(g) { 43 with(g) {
44 if(c.state == ButtonState.Pressed) 44 if(c.state == ButtonState.Pressed)
45 g.source = Color.Black; 45 g.source = Color.Black;
46 else 46 else
47 g.source = Color.White; 47 g.source = Color.White;
60 g.source = c.foreColor; 60 g.source = c.foreColor;
61 c.paintFore(g); 61 c.paintFore(g);
62 } 62 }
63 } 63 }
64 64
65 void CheckBox_paint(CheckBox c, Graphics g) { 65 override void CheckBox_paint(CheckBox c, Graphics g) {
66 with(g) { 66 with(g) {
67 Point box = Point(2, cast(int)(c.height/2-6)); 67 Point box = Point(2, cast(int)(c.height/2-6));
68 fontSize = 13; 68 fontSize = 13;
69 drawText(c.text, box.x+18, 2); 69 drawText(c.text, box.x+18, 2);
70 70
86 relLineTo(6, -8); 86 relLineTo(6, -8);
87 stroke(); 87 stroke();
88 } 88 }
89 } 89 }
90 } 90 }
91 void RadioButton_paint(CheckBox c, Graphics g) { 91 override void RadioButton_paint(CheckBox c, Graphics g) {
92 with(g) { 92 with(g) {
93 int radius = 6; 93 int radius = 6;
94 Point circle = Point(2, cast(int)(c.height/2-radius)); 94 Point circle = Point(2, cast(int)(c.height/2-radius));
95 fontSize = 13; 95 fontSize = 13;
96 drawText(c.text, circle.x+18, 2); 96 drawText(c.text, circle.x+18, 2);
114 fill(); 114 fill();
115 } 115 }
116 } 116 }
117 } 117 }
118 118
119 void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g) { 119 override void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g) {
120 if(c.state == ButtonState.Pressed) 120 if(c.state == ButtonState.Pressed)
121 g.paint(); 121 g.paint();
122 else if(isOdd(cast(int)round(c.x)) || isOdd(cast(int)round(c.y))) 122 else if(isOdd(cast(int)round(c.x)) || isOdd(cast(int)round(c.y)))
123 drawCheckerboard(g, 0, 0, c.width, c.height, 123 drawCheckerboard(g, 0, 0, c.width, c.height,
124 Color.White, Color.Black); 124 Color.White, Color.Black);
125 else 125 else
126 drawCheckerboard(g, 0, 0, c.width, c.height, 126 drawCheckerboard(g, 0, 0, c.width, c.height,
127 Color.Black, Color.White); 127 Color.Black, Color.White);
128 } 128 }
129 129
130 void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g) { 130 override void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g) {
131 with(g) { 131 with(g) {
132 source = Color.White; 132 source = Color.White;
133 paint(); 133 paint();
134 source = Color.Black; 134 source = Color.Black;
135 rectangle(0.5, 0.5, c.width-1, c.height-1); 135 rectangle(0.5, 0.5, c.width-1, c.height-1);
136 stroke(); 136 stroke();
137 } 137 }
138 } 138 }
139 139
140 double ScrollBar_size() { 140 override double ScrollBar_size() {
141 // TODO: all themes should get this from SystemGui.ScrollBarSize 141 // TODO: all themes should get this from SystemGui.ScrollBarSize
142 return 18; 142 return 18;
143 } 143 }
144 144
145 void ArrowButton_paint(ArrowButton c, Graphics g) { 145 override void ArrowButton_paint(ArrowButton c, Graphics g) {
146 Button_paint(c, g); 146 Button_paint(c, g);
147 } 147 }
148 148
149 BorderSize Scrollable_borderSize(Scrollable c) { 149 override BorderSize Scrollable_borderSize(Scrollable c) {
150 return BorderSize(1, 1, 1, 1); 150 return BorderSize(1, 1, 1, 1);
151 } 151 }
152 152
153 void Scrollable_paint(Scrollable c, Graphics g) { 153 override void Scrollable_paint(Scrollable c, Graphics g) {
154 g.source = Color.White; 154 g.source = Color.White;
155 g.paint(); 155 g.paint();
156 g.source = Color.Black; 156 g.source = Color.Black;
157 g.rectangle(0.5, 0.5, c.width-0.5, c.height-0.5); 157 g.rectangle(0.5, 0.5, c.width-0.5, c.height-0.5);
158 g.stroke(); 158 g.stroke();
159 } 159 }
160 160
161 BorderSize Notebook_borderSize(Notebook c) { 161 override BorderSize Notebook_borderSize(Notebook c) {
162 return BorderSize(1, 1, 1, 1); 162 return BorderSize(1, 1, 1, 1);
163 } 163 }
164 void Tab_paint(TabPage page, Notebook c, Graphics g){} 164 override void Tab_paint(TabPage page, Notebook c, Graphics g){}
165 void Notebook_paint(Notebook c, Graphics g){} 165 override void Notebook_paint(Notebook c, Graphics g){}
166 166
167 } 167 }
168 168