Mercurial > projects > dynamin
annotate dynamin/gui/basic_theme.d @ 113:4636a64afabc default tip
Add reverse() function.
author | Jordan Miner <jminer7@gmail.com> |
---|---|
date | Sat, 19 Jan 2013 21:08:52 -0600 |
parents | acdbb30fee7e |
children |
rev | line source |
---|---|
0 | 1 |
2 /* | |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
3 * Copyright Jordan Miner |
0 | 4 * |
103
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
5 * This Source Code Form is subject to the terms of the Mozilla Public |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
6 * License, v. 2.0. If a copy of the MPL was not distributed with this |
73060bc3f004
Change license to Boost 1.0 and MPL 2.0.
Jordan Miner <jminer7@gmail.com>
parents:
0
diff
changeset
|
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
0 | 8 * |
9 */ | |
10 | |
11 module dynamin.gui.basic_theme; | |
12 | |
13 import dynamin.core.string; | |
14 import dynamin.all_painting; | |
15 import dynamin.all_gui; | |
16 import dynamin.core.math; | |
17 | |
18 static this() { | |
19 Theme.add(new BasicTheme()); | |
20 } | |
21 | |
22 /* | |
23 * Four colors used in this theme: | |
24 * - white (255, 255, 255) | |
25 * - black (0, 0, 0) | |
26 * - light gray (220, 220, 220) | |
27 * - dark gray (70, 70, 70) | |
28 */ | |
29 class BasicTheme : Theme { | |
106 | 30 override string name() { |
0 | 31 return "Basic"; |
32 } | |
33 | |
106 | 34 override void Window_paint(Window c, Graphics g) { |
0 | 35 g.source = Color.White; |
36 g.paint(); | |
37 } | |
106 | 38 override Size Button_bestSize(Button c) { |
0 | 39 return Size(60, 25); |
40 } | |
41 | |
106 | 42 override void Button_paint(Button c, Graphics g) { |
0 | 43 with(g) { |
44 if(c.state == ButtonState.Pressed) | |
45 g.source = Color.Black; | |
46 else | |
47 g.source = Color.White; | |
48 paint(); | |
49 | |
50 source = Color.Black; | |
51 rectangle(0.5, 0.5, c.width-1, c.height-1); | |
52 stroke(); | |
53 if(c.state == ButtonState.Hot) { | |
54 rectangle(1.5, 1.5, c.width-3, c.height-3); | |
55 stroke(); | |
56 } | |
57 if(c.state == ButtonState.Pressed) | |
58 g.source = Color.White; | |
59 else | |
60 g.source = c.foreColor; | |
61 c.paintFore(g); | |
62 } | |
63 } | |
64 | |
106 | 65 override void CheckBox_paint(CheckBox c, Graphics g) { |
0 | 66 with(g) { |
67 Point box = Point(2, cast(int)(c.height/2-6)); | |
68 fontSize = 13; | |
69 drawText(c.text, box.x+18, 2); | |
70 | |
71 source = c.state == ButtonState.Pressed ? Color.Black : Color.White; | |
72 rectangle(box.x, box.y, 13, 13); | |
73 fill(); | |
74 source = Color.Black; | |
75 rectangle(box.x+0.5, box.y+0.5, 12, 12); | |
76 stroke(); | |
77 if(c.state == ButtonState.Hot) { | |
78 rectangle(box.x+1.5, box.y+1.5, 10, 10); | |
79 stroke(); | |
80 } | |
81 | |
82 source = c.state == ButtonState.Pressed ? Color.White : Color.Black; | |
83 if(c.checked) { | |
84 moveTo(box.x+2.5, box.y+7.5); | |
85 relLineTo(2, 3); | |
86 relLineTo(6, -8); | |
87 stroke(); | |
88 } | |
89 } | |
90 } | |
106 | 91 override void RadioButton_paint(CheckBox c, Graphics g) { |
0 | 92 with(g) { |
93 int radius = 6; | |
94 Point circle = Point(2, cast(int)(c.height/2-radius)); | |
95 fontSize = 13; | |
96 drawText(c.text, circle.x+18, 2); | |
97 | |
98 source = c.state == ButtonState.Pressed ? Color.Black : Color.White; | |
99 ellipse(circle.x+radius, circle.y+radius, radius); | |
100 fill(); | |
101 source = Color.Black; | |
102 if(c.state == ButtonState.Hot) { | |
103 lineWidth = 2; | |
104 ellipse(circle.x+radius, circle.y+radius, radius-1); | |
105 } else { | |
106 ellipse(circle.x+radius, circle.y+radius, radius-0.5); | |
107 } | |
108 stroke(); | |
109 lineWidth = 1; | |
110 | |
111 source = c.state == ButtonState.Pressed ? Color.White : Color.Black; | |
112 if(c.checked) { | |
113 ellipse(circle.x+radius, circle.y+radius, radius-4); | |
114 fill(); | |
115 } | |
116 } | |
117 } | |
118 | |
106 | 119 override void ScrollBarTrack_paint(ScrollBarTrack c, Graphics g) { |
0 | 120 if(c.state == ButtonState.Pressed) |
121 g.paint(); | |
122 else if(isOdd(cast(int)round(c.x)) || isOdd(cast(int)round(c.y))) | |
123 drawCheckerboard(g, 0, 0, c.width, c.height, | |
124 Color.White, Color.Black); | |
125 else | |
126 drawCheckerboard(g, 0, 0, c.width, c.height, | |
127 Color.Black, Color.White); | |
128 } | |
129 | |
106 | 130 override void ScrollBarThumb_paint(ScrollBarThumb c, Graphics g) { |
0 | 131 with(g) { |
132 source = Color.White; | |
133 paint(); | |
134 source = Color.Black; | |
135 rectangle(0.5, 0.5, c.width-1, c.height-1); | |
136 stroke(); | |
137 } | |
138 } | |
139 | |
106 | 140 override double ScrollBar_size() { |
0 | 141 // TODO: all themes should get this from SystemGui.ScrollBarSize |
142 return 18; | |
143 } | |
144 | |
106 | 145 override void ArrowButton_paint(ArrowButton c, Graphics g) { |
0 | 146 Button_paint(c, g); |
147 } | |
148 | |
106 | 149 override BorderSize Scrollable_borderSize(Scrollable c) { |
0 | 150 return BorderSize(1, 1, 1, 1); |
151 } | |
152 | |
106 | 153 override void Scrollable_paint(Scrollable c, Graphics g) { |
0 | 154 g.source = Color.White; |
155 g.paint(); | |
156 g.source = Color.Black; | |
157 g.rectangle(0.5, 0.5, c.width-0.5, c.height-0.5); | |
158 g.stroke(); | |
159 } | |
160 | |
106 | 161 override BorderSize Notebook_borderSize(Notebook c) { |
0 | 162 return BorderSize(1, 1, 1, 1); |
163 } | |
106 | 164 override void Tab_paint(TabPage page, Notebook c, Graphics g){} |
165 override void Notebook_paint(Notebook c, Graphics g){} | |
0 | 166 |
167 } | |
168 |