Mercurial > projects > dwt-addons
comparison dwtx/draw2d/ColorConstants.d @ 98:95307ad235d9
Added Draw2d code, still work in progress
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 03 Aug 2008 00:52:14 +0200 |
parents | |
children | 0de61c6f08ca |
comparison
equal
deleted
inserted
replaced
96:b492ba44e44d | 98:95307ad235d9 |
---|---|
1 /******************************************************************************* | |
2 * Copyright (c) 2000, 2008 IBM Corporation and others. | |
3 * All rights reserved. This program and the accompanying materials | |
4 * are made available under the terms of the Eclipse Public License v1.0 | |
5 * which accompanies this distribution, and is available at | |
6 * http://www.eclipse.org/legal/epl-v10.html | |
7 * | |
8 * Contributors: | |
9 * IBM Corporation - initial API and implementation | |
10 * Port to the D programming language: | |
11 * Frank Benoit <benoit@tionex.de> | |
12 *******************************************************************************/ | |
13 module dwtx.draw2d.ColorConstants; | |
14 | |
15 import dwt.dwthelper.utils; | |
16 import dwt.dwthelper.Runnable; | |
17 import tango.core.sync.Mutex; | |
18 | |
19 import dwt.DWT; | |
20 import dwt.graphics.Color; | |
21 import dwt.widgets.Display; | |
22 | |
23 /** | |
24 * A collection of color-related constants. | |
25 */ | |
26 public struct ColorConstants { | |
27 | |
28 class SystemColorFactory { | |
29 private static Color getColor(int which) { | |
30 Display display = Display.getCurrent(); | |
31 if (display !is null) | |
32 return display.getSystemColor(which); | |
33 display = Display.getDefault(); | |
34 Color result; | |
35 scope Mutex mutex = new Mutex; | |
36 display.syncExec(dgRunnable( { | |
37 synchronized (mutex) { | |
38 result = Display.getCurrent().getSystemColor(which); | |
39 } | |
40 } )); | |
41 synchronized (mutex) { | |
42 return result; | |
43 } | |
44 } | |
45 } | |
46 | |
47 /** | |
48 * @see DWT#COLOR_WIDGET_HIGHLIGHT_SHADOW | |
49 */ | |
50 static const Color buttonLightest; | |
51 /** | |
52 * @see DWT#COLOR_WIDGET_BACKGROUND | |
53 */ | |
54 static const Color button; | |
55 /** | |
56 * @see DWT#COLOR_WIDGET_NORMAL_SHADOW | |
57 */ | |
58 static const Color buttonDarker; | |
59 /** | |
60 * @see DWT#COLOR_WIDGET_DARK_SHADOW | |
61 */ | |
62 static const Color buttonDarkest; | |
63 | |
64 /** | |
65 * @see DWT#COLOR_LIST_BACKGROUND | |
66 */ | |
67 static const Color listBackground; | |
68 /** | |
69 * @see DWT#COLOR_LIST_FOREGROUND | |
70 */ | |
71 static const Color listForeground; | |
72 | |
73 /** | |
74 * @see DWT#COLOR_WIDGET_BACKGROUND | |
75 */ | |
76 static const Color menuBackground; | |
77 /** | |
78 * @see DWT#COLOR_WIDGET_FOREGROUND | |
79 */ | |
80 static const Color menuForeground; | |
81 /** | |
82 * @see DWT#COLOR_LIST_SELECTION | |
83 */ | |
84 static const Color menuBackgroundSelected; | |
85 /** | |
86 * @see DWT#COLOR_LIST_SELECTION_TEXT | |
87 */ | |
88 static const Color menuForegroundSelected; | |
89 | |
90 /** | |
91 * @see DWT#COLOR_TITLE_BACKGROUND | |
92 */ | |
93 static const Color titleBackground; | |
94 /** | |
95 * @see DWT#COLOR_TITLE_BACKGROUND_GRADIENT | |
96 */ | |
97 static const Color titleGradient; | |
98 /** | |
99 * @see DWT#COLOR_TITLE_FOREGROUND | |
100 */ | |
101 static const Color titleForeground; | |
102 /** | |
103 * @see DWT#COLOR_TITLE_INACTIVE_FOREGROUND | |
104 */ | |
105 static const Color titleInactiveForeground; | |
106 /** | |
107 * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND | |
108 */ | |
109 static const Color titleInactiveBackground; | |
110 /** | |
111 * @see DWT#COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT | |
112 */ | |
113 static const Color titleInactiveGradient; | |
114 | |
115 /** | |
116 * @see DWT#COLOR_INFO_FOREGROUND | |
117 */ | |
118 static const Color tooltipForeground; | |
119 /** | |
120 * @see DWT#COLOR_INFO_BACKGROUND | |
121 */ | |
122 static const Color tooltipBackground; | |
123 | |
124 /* | |
125 * Misc. colors | |
126 */ | |
127 /** One of the pre-defined colors */ | |
128 static const Color white; | |
129 /** One of the pre-defined colors */ | |
130 static const Color lightGray; | |
131 /** One of the pre-defined colors */ | |
132 static const Color gray; | |
133 /** One of the pre-defined colors */ | |
134 static const Color darkGray; | |
135 /** One of the pre-defined colors */ | |
136 static const Color black; | |
137 /** One of the pre-defined colors */ | |
138 static const Color red; | |
139 /** One of the pre-defined colors */ | |
140 static const Color orange; | |
141 /** One of the pre-defined colors */ | |
142 static const Color yellow; | |
143 /** One of the pre-defined colors */ | |
144 static const Color green; | |
145 /** One of the pre-defined colors */ | |
146 static const Color lightGreen; | |
147 /** One of the pre-defined colors */ | |
148 static const Color darkGreen; | |
149 /** One of the pre-defined colors */ | |
150 static const Color cyan; | |
151 /** One of the pre-defined colors */ | |
152 static const Color lightBlue; | |
153 /** One of the pre-defined colors */ | |
154 static const Color blue; | |
155 /** One of the pre-defined colors */ | |
156 static const Color darkBlue; | |
157 | |
158 | |
159 static this(){ | |
160 buttonLightest = SystemColorFactory.getColor(DWT.COLOR_WIDGET_HIGHLIGHT_SHADOW); | |
161 button = SystemColorFactory.getColor(DWT.COLOR_WIDGET_BACKGROUND); | |
162 buttonDarker = SystemColorFactory.getColor(DWT.COLOR_WIDGET_NORMAL_SHADOW); | |
163 buttonDarkest = SystemColorFactory.getColor(DWT.COLOR_WIDGET_DARK_SHADOW); | |
164 listBackground = SystemColorFactory.getColor(DWT.COLOR_LIST_BACKGROUND); | |
165 listForeground = SystemColorFactory.getColor(DWT.COLOR_LIST_FOREGROUND); | |
166 menuBackground = SystemColorFactory.getColor(DWT.COLOR_WIDGET_BACKGROUND); | |
167 menuForeground = SystemColorFactory.getColor(DWT.COLOR_WIDGET_FOREGROUND); | |
168 menuBackgroundSelected = SystemColorFactory.getColor(DWT.COLOR_LIST_SELECTION); | |
169 menuForegroundSelected = SystemColorFactory.getColor(DWT.COLOR_LIST_SELECTION_TEXT); | |
170 titleBackground = SystemColorFactory.getColor(DWT.COLOR_TITLE_BACKGROUND); | |
171 titleGradient = SystemColorFactory.getColor(DWT.COLOR_TITLE_BACKGROUND_GRADIENT); | |
172 titleForeground = SystemColorFactory.getColor(DWT.COLOR_TITLE_FOREGROUND); | |
173 titleInactiveForeground = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_FOREGROUND); | |
174 titleInactiveBackground = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND); | |
175 titleInactiveGradient = SystemColorFactory.getColor(DWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT); | |
176 tooltipForeground = SystemColorFactory.getColor(DWT.COLOR_INFO_FOREGROUND); | |
177 tooltipBackground = SystemColorFactory.getColor(DWT.COLOR_INFO_BACKGROUND); | |
178 white = new Color(null, 255, 255, 255); | |
179 lightGray = new Color(null, 192, 192, 192); | |
180 gray = new Color(null, 128, 128, 128); | |
181 darkGray = new Color(null, 64, 64, 64); | |
182 black = new Color(null, 0, 0, 0); | |
183 red = new Color(null, 255, 0, 0); | |
184 orange = new Color(null, 255, 196, 0); | |
185 yellow = new Color(null, 255, 255, 0); | |
186 green = new Color(null, 0, 255, 0); | |
187 lightGreen = new Color(null, 96, 255, 96); | |
188 darkGreen = new Color(null, 0, 127, 0); | |
189 cyan = new Color(null, 0, 255, 255); | |
190 lightBlue = new Color(null, 127, 127, 255); | |
191 blue = new Color(null, 0, 0, 255); | |
192 darkBlue = new Color(null, 0, 0, 127); | |
193 } | |
194 } | |
195 | |
196 |