New test.
[mono.git] / mcs / class / System.Drawing / System.Drawing / SystemColors.jvm.cs
1 //
2 // System.Drawing.SystemColors.cs
3 //
4 // Authors:
5 //      Andrew Skiba (andrews@mainsoft.com)
6 //  Konstantin Triger (kostat@mainsoft.com)
7 //
8 // Copyright (C) 2005 Mainsoft Corporation (http://www.mainsoft.com)
9 // 
10
11 //
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
19 // 
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
22 // 
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 //
31
32 using awt = java.awt;
33 namespace System.Drawing {
34
35         public sealed class SystemColors
36         {
37                 static readonly Color[] SystemColorsCache;
38
39                 private SystemColors (){}
40                 
41                 static SystemColors ()
42                 {
43 #if !NET_2_0
44                         SystemColorsCache = new Color[27]; //enough for all system color indices\r
45 #else\r
46                         SystemColorsCache = new Color [175]; //enough for all system color indices
47 #endif
48
49                         if (Graphics.IsHeadless) {
50                                 SystemColorsCache[(int)KnownColor.ActiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "ActiveBorder", KnownColor.ActiveBorder);
51                                 SystemColorsCache[(int)KnownColor.ActiveCaption] = Color.FromArgbSystem (255, 10, 36, 106, "ActiveCaption", KnownColor.ActiveCaption);
52                                 SystemColorsCache[(int)KnownColor.ActiveCaptionText] = Color.FromArgbSystem (255, 255, 255, 255, "ActiveCaptionText", KnownColor.ActiveCaptionText);
53                                 //TODO: find a more close approximation
54                                 SystemColorsCache[(int)KnownColor.AppWorkspace] = Color.FromArgbSystem (255, 128, 128, 128, "AppWorkspace", KnownColor.AppWorkspace);
55                                 SystemColorsCache[(int)KnownColor.Control] = Color.FromArgbSystem (255, 212, 208, 200, "Control", KnownColor.Control);
56                                 SystemColorsCache[(int)KnownColor.ControlDark] = Color.FromArgbSystem (255, 128, 128, 128, "ControlDark", KnownColor.ControlDark);
57                                 SystemColorsCache[(int)KnownColor.ControlDarkDark] = Color.FromArgbSystem (255, 64, 64, 64, "ControlDarkDark", KnownColor.ControlDarkDark);
58                                 SystemColorsCache[(int)KnownColor.ControlLight] = Color.FromArgbSystem (255, 212, 208, 200, "ControlLight", KnownColor.ControlLight);
59                                 SystemColorsCache[(int)KnownColor.ControlLightLight] = Color.FromArgbSystem (255, 255, 255, 255, "ControlLightLight", KnownColor.ControlLightLight);
60                                 SystemColorsCache[(int)KnownColor.ControlText] = Color.FromArgbSystem (255, 0, 0, 0, "ControlText", KnownColor.ControlText);
61                                 SystemColorsCache[(int)KnownColor.Desktop] = Color.FromArgbSystem (255, 58, 110, 165, "Desktop", KnownColor.Desktop);
62                                 SystemColorsCache[(int)KnownColor.GrayText] = Color.FromArgbSystem (255, 128, 128, 128, "GrayText", KnownColor.GrayText);
63                                 SystemColorsCache[(int)KnownColor.Highlight] = Color.FromArgbSystem (255, 10, 36, 106, "Highlight", KnownColor.Highlight);
64                                 SystemColorsCache[(int)KnownColor.HighlightText] = Color.FromArgbSystem (255, 255, 255, 255, "HighlightText", KnownColor.HighlightText);
65                                 //TODO: find a more close approximation
66                                 SystemColorsCache[(int)KnownColor.HotTrack] = Color.FromArgbSystem (255, 0, 0, 128, "HotTrack", KnownColor.HotTrack);
67                                 SystemColorsCache[(int)KnownColor.InactiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveBorder", KnownColor.InactiveBorder);
68                                 SystemColorsCache[(int)KnownColor.InactiveCaption] = Color.FromArgbSystem (255, 128, 128, 128, "InactiveCaption", KnownColor.InactiveCaption);
69                                 SystemColorsCache[(int)KnownColor.InactiveCaptionText] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveCaptionText", KnownColor.InactiveCaptionText);
70                                 SystemColorsCache[(int)KnownColor.Info] = Color.FromArgbSystem (255, 255, 255, 225, "Info", KnownColor.Info);
71                                 SystemColorsCache[(int)KnownColor.InfoText] = Color.FromArgbSystem (255, 0, 0, 0, "InfoText", KnownColor.InfoText);
72                                 SystemColorsCache[(int)KnownColor.Menu] = Color.FromArgbSystem (255, 212, 208, 200, "Menu", KnownColor.Menu);
73                                 SystemColorsCache[(int)KnownColor.MenuText] = Color.FromArgbSystem (255, 0, 0, 0, "MenuText", KnownColor.MenuText);
74                                 SystemColorsCache[(int)KnownColor.ScrollBar] = Color.FromArgbSystem (255, 212, 208, 200, "ScrollBar", KnownColor.ScrollBar);
75                                 SystemColorsCache[(int)KnownColor.Window] = Color.FromArgbSystem (255, 255, 255, 255, "Window", KnownColor.Window);
76                                 SystemColorsCache[(int)KnownColor.WindowFrame] = Color.FromArgbSystem (255, 0, 0, 0, "WindowFrame", KnownColor.WindowFrame);
77                                 SystemColorsCache[(int)KnownColor.WindowText] = Color.FromArgbSystem (255, 0, 0, 0, "WindowText", KnownColor.WindowText);
78
79 #if NET_2_0
80                                 SystemColorsCache [(int) KnownColor.ButtonFace] = Color.FromArgbSystem (255, 192, 192, 192, "ButtonFace", KnownColor.ButtonFace);
81                                 SystemColorsCache [(int) KnownColor.ButtonHighlight] = Color.FromArgbSystem (255, 255, 255, 255, "ButtonHighlight", KnownColor.ButtonHighlight);
82                                 SystemColorsCache [(int) KnownColor.ButtonShadow] = Color.FromArgbSystem (255, 128, 128, 128, "ButtonShadow", KnownColor.ButtonShadow);
83                                 SystemColorsCache [(int) KnownColor.GradientActiveCaption] = Color.FromArgbSystem (255, 16, 132, 208, "GradientActiveCaption", KnownColor.GradientActiveCaption);
84                                 SystemColorsCache [(int) KnownColor.GradientInactiveCaption] = Color.FromArgbSystem (255, 181, 181, 181, "GradientInactiveCaption", KnownColor.GradientInactiveCaption);
85                                 SystemColorsCache [(int) KnownColor.MenuBar] = Color.FromArgbSystem (255, 192, 192, 192, "MenuBar", KnownColor.MenuBar);
86                                 SystemColorsCache [(int) KnownColor.MenuHighlight] = Color.FromArgbSystem (255, 0, 0, 0, "MenuHighlight", KnownColor.MenuHighlight);
87 #endif
88                         }
89                         else {
90                                 SystemColorsCache[(int)KnownColor.ActiveBorder] = FromNativeColor (awt.SystemColor.activeCaptionBorder, "ActiveBorder", KnownColor.ActiveBorder);
91                                 SystemColorsCache[(int)KnownColor.ActiveCaption] = FromNativeColor (awt.SystemColor.activeCaption, "ActiveCaption", KnownColor.ActiveCaption);
92                                 SystemColorsCache[(int)KnownColor.ActiveCaptionText] = FromNativeColor (awt.SystemColor.activeCaptionText, "ActiveCaptionText", KnownColor.ActiveCaptionText);
93                                 //TODO: find a more close approximation
94                                 SystemColorsCache[(int)KnownColor.AppWorkspace] = FromNativeColor (awt.SystemColor.desktop, "AppWorkspace", KnownColor.AppWorkspace);
95                                 SystemColorsCache[(int)KnownColor.Control] = FromNativeColor (awt.SystemColor.control, "Control", KnownColor.Control);
96                                 SystemColorsCache[(int)KnownColor.ControlDark] = FromNativeColor (awt.SystemColor.controlShadow, "ControlDark", KnownColor.ControlDark);
97                                 SystemColorsCache[(int)KnownColor.ControlDarkDark] = FromNativeColor (awt.SystemColor.controlDkShadow, "ControlDarkDark", KnownColor.ControlDarkDark);
98                                 SystemColorsCache[(int)KnownColor.ControlLight] = FromNativeColor (awt.SystemColor.controlHighlight, "ControlLight", KnownColor.ControlLight);
99                                 SystemColorsCache[(int)KnownColor.ControlLightLight] = FromNativeColor (awt.SystemColor.controlLtHighlight, "ControlLightLight", KnownColor.ControlLightLight);
100                                 SystemColorsCache[(int)KnownColor.ControlText] = FromNativeColor (awt.SystemColor.controlText, "ControlText", KnownColor.ControlText);
101                                 SystemColorsCache[(int)KnownColor.Desktop] = FromNativeColor (awt.SystemColor.desktop, "Desktop", KnownColor.Desktop);
102                                 SystemColorsCache[(int)KnownColor.GrayText] = FromNativeColor (awt.SystemColor.textInactiveText, "GrayText", KnownColor.GrayText);
103                                 SystemColorsCache[(int)KnownColor.Highlight] = FromNativeColor (awt.SystemColor.textHighlight, "Highlight", KnownColor.Highlight);
104                                 SystemColorsCache[(int)KnownColor.HighlightText] = FromNativeColor (awt.SystemColor.textHighlightText, "HighlightText", KnownColor.HighlightText);
105                                 //TODO: find a more close approximation
106                                 SystemColorsCache[(int)KnownColor.HotTrack] = FromNativeColor (awt.SystemColor.textText, "HotTrack", KnownColor.HotTrack);
107                                 SystemColorsCache[(int)KnownColor.InactiveBorder] = FromNativeColor (awt.SystemColor.inactiveCaptionBorder, "InactiveBorder", KnownColor.InactiveBorder);
108                                 SystemColorsCache[(int)KnownColor.InactiveCaption] = FromNativeColor (awt.SystemColor.inactiveCaption, "InactiveCaption", KnownColor.InactiveCaption);
109                                 SystemColorsCache[(int)KnownColor.InactiveCaptionText] = FromNativeColor (awt.SystemColor.inactiveCaptionText, "InactiveCaptionText", KnownColor.InactiveCaptionText);
110                                 SystemColorsCache[(int)KnownColor.Info] = FromNativeColor (awt.SystemColor.info, "Info", KnownColor.Info);
111                                 SystemColorsCache[(int)KnownColor.InfoText] = FromNativeColor (awt.SystemColor.infoText, "InfoText", KnownColor.InfoText);
112                                 SystemColorsCache[(int)KnownColor.Menu] = FromNativeColor (awt.SystemColor.menu, "Menu", KnownColor.Menu);
113                                 SystemColorsCache[(int)KnownColor.MenuText] = FromNativeColor (awt.SystemColor.menuText, "MenuText", KnownColor.MenuText);
114                                 SystemColorsCache[(int)KnownColor.ScrollBar] = FromNativeColor (awt.SystemColor.scrollbar, "ScrollBar", KnownColor.ScrollBar);
115                                 SystemColorsCache[(int)KnownColor.Window] = FromNativeColor (awt.SystemColor.window, "Window", KnownColor.Window);
116                                 SystemColorsCache[(int)KnownColor.WindowFrame] = FromNativeColor (awt.SystemColor.windowBorder, "WindowFrame", KnownColor.WindowFrame);
117                                 SystemColorsCache[(int)KnownColor.WindowText] = FromNativeColor (awt.SystemColor.windowText, "WindowText", KnownColor.WindowText);
118
119 #if NET_2_0
120                                 SystemColorsCache [(int) KnownColor.ButtonFace] = FromNativeColor (awt.SystemColor.control, "ButtonFace", KnownColor.ButtonFace);
121                                 SystemColorsCache [(int) KnownColor.ButtonHighlight] = FromNativeColor (awt.SystemColor.controlHighlight, "ButtonHighlight", KnownColor.ButtonHighlight);
122                                 SystemColorsCache [(int) KnownColor.ButtonShadow] = FromNativeColor (awt.SystemColor.controlShadow, "ButtonShadow", KnownColor.ButtonShadow);
123                                 SystemColorsCache [(int) KnownColor.GradientActiveCaption] = FromNativeColor (awt.SystemColor.activeCaption, "GradientActiveCaption", KnownColor.GradientActiveCaption);
124                                 SystemColorsCache [(int) KnownColor.GradientInactiveCaption] = FromNativeColor (awt.SystemColor.inactiveCaption, "GradientInactiveCaption", KnownColor.GradientInactiveCaption);
125                                 SystemColorsCache [(int) KnownColor.MenuBar] = FromNativeColor (awt.SystemColor.menu, "MenuBar", KnownColor.MenuBar);
126                                 SystemColorsCache [(int) KnownColor.MenuHighlight] = FromNativeColor (awt.SystemColor.menu, "MenuHighlight", KnownColor.MenuHighlight);
127 #endif
128                         }
129                 }
130
131                 static private Color FromNativeColor (
132                         awt.Color awtColor, string name, KnownColor knownColor) {
133                         return Color.FromArgbSystem (awtColor.getAlpha(),
134                                 awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(),
135                                 name, knownColor);
136                 }
137
138                 static public Color ActiveBorder
139                 {       
140                         get {
141                                 return SystemColorsCache[(int)KnownColor.ActiveBorder];
142                         }
143                 }
144
145                 static public Color ActiveCaption
146                 {       
147                         get {
148                                 return SystemColorsCache[(int)KnownColor.ActiveCaption];
149                         }
150                 }
151
152                 static public Color ActiveCaptionText
153                 {       
154                         get {
155                                 return SystemColorsCache[(int)KnownColor.ActiveCaptionText];
156                         }
157                 }
158
159                 static public Color AppWorkspace
160                 {       
161                         get {
162                                 return SystemColorsCache[(int)KnownColor.AppWorkspace];
163                         }
164                 }
165
166                 static public Color Control
167                 {       
168                         get {
169                                 return SystemColorsCache[(int)KnownColor.Control];
170                         }
171                 }
172
173                 static public Color ControlDark
174                 {       
175                         get {
176                                 return SystemColorsCache[(int)KnownColor.ControlDark];
177                         }
178                 }
179
180                 static public Color ControlDarkDark
181                 {       
182                         get {
183                                 return SystemColorsCache[(int)KnownColor.ControlDarkDark];
184                         }
185                 }
186
187                 static public Color ControlLight
188                 {       
189                         get {
190                                 return SystemColorsCache[(int)KnownColor.ControlLight];
191                         }
192                 }
193
194                 static public Color ControlLightLight
195                 {       
196                         get {
197                                 return SystemColorsCache[(int)KnownColor.ControlLightLight];
198                         }
199                 }
200
201                 static public Color ControlText
202                 {       
203                         get {
204                                 return SystemColorsCache[(int)KnownColor.ControlText];
205                         }
206                 }
207
208                 static public Color Desktop
209                 {       
210                         get {
211                                 return SystemColorsCache[(int)KnownColor.Desktop];
212                         }
213                 }
214
215                 static public Color GrayText
216                 {       
217                         get {
218                                 return SystemColorsCache[(int)KnownColor.GrayText];
219                         }
220                 }
221
222                 static public Color Highlight
223                 {       
224                         get {
225                                 return SystemColorsCache[(int)KnownColor.Highlight];
226                         }
227                 }
228
229                 static public Color HighlightText
230                 {       
231                         get {
232                                 return SystemColorsCache[(int)KnownColor.HighlightText];
233                         }
234                 }
235
236                 static public Color HotTrack
237                 {       
238                         get {
239                                 return SystemColorsCache[(int)KnownColor.HotTrack];
240                         }
241                 }
242
243                 static public Color InactiveBorder
244                 {       
245                         get {
246                                 return SystemColorsCache[(int)KnownColor.InactiveBorder];
247                         }
248                 }
249
250                 static public Color InactiveCaption
251                 {       
252                         get {
253                                 return SystemColorsCache[(int)KnownColor.InactiveCaption];
254                         }
255                 }
256
257                 static public Color InactiveCaptionText
258                 {       
259                         get {
260                                 return SystemColorsCache[(int)KnownColor.InactiveCaptionText];
261                         }
262                 }
263
264                 static public Color Info
265                 {       
266                         get {
267                                 return SystemColorsCache[(int)KnownColor.Info];
268                         }
269                 }
270
271                 static public Color InfoText
272                 {       
273                         get {
274                                 return SystemColorsCache[(int)KnownColor.InfoText];
275                         }
276                 }
277
278                 static public Color Menu
279                 {       
280                         get {
281                                 return SystemColorsCache[(int)KnownColor.Menu];
282                         }
283                 }
284
285                 static public Color MenuText
286                 {       
287                         get {
288                                 return SystemColorsCache[(int)KnownColor.MenuText];
289                         }
290                 }
291
292                 static public Color ScrollBar
293                 {       
294                         get {
295                                 return SystemColorsCache[(int)KnownColor.ScrollBar];
296                         }
297                 }
298
299                 static public Color Window
300                 {       
301                         get {
302                                 return SystemColorsCache[(int)KnownColor.Window];
303                         }
304                 }
305
306                 static public Color WindowFrame
307                 {       
308                         get {
309                                 return SystemColorsCache[(int)KnownColor.WindowFrame];
310                         }
311                 }
312
313                 static public Color WindowText
314                 {       
315                         get {
316                                 return SystemColorsCache[(int)KnownColor.WindowText];
317                         }
318                 }
319
320 #if NET_2_0
321
322                 static public Color ButtonFace
323                 {       
324                         get {
325                                 return SystemColorsCache [(int) KnownColor.ButtonFace];
326                         }
327                 }
328
329                 static public Color ButtonHighlight
330                 {       
331                         get {
332                                 return SystemColorsCache [(int) KnownColor.ButtonHighlight];
333                         }
334                 }
335
336                 static public Color ButtonShadow
337                 {       
338                         get {
339                                 return SystemColorsCache [(int) KnownColor.ButtonShadow];
340                         }
341                 }
342
343                 static public Color GradientActiveCaption
344                 {       
345                         get {
346                                 return SystemColorsCache [(int) KnownColor.GradientActiveCaption];
347                         }
348                 }
349
350                 static public Color GradientInactiveCaption
351                 {       
352                         get {
353                                 return SystemColorsCache [(int) KnownColor.GradientInactiveCaption];
354                         }
355                 }
356
357                 static public Color MenuBar
358                 {       
359                         get {
360                                 return SystemColorsCache [(int) KnownColor.MenuBar];
361                         }
362                 }
363
364                 static public Color MenuHighlight
365                 {       
366                         get {
367                                 return SystemColorsCache [(int) KnownColor.MenuHighlight];
368                         }
369                 }
370 #endif
371         }
372 }