Added TARGET_JVM implementation of Icon.cs and SystemColors.cs
[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                         SystemColorsCache = new Color[27]; //enough for all system color indices
44
45                         if (Graphics.IsHeadless) {
46                                 SystemColorsCache[(int)KnownColor.ActiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "ActiveBorder", KnownColor.ActiveBorder);
47                                 SystemColorsCache[(int)KnownColor.ActiveCaption] = Color.FromArgbSystem (255, 10, 36, 106, "ActiveCaption", KnownColor.ActiveCaption);
48                                 SystemColorsCache[(int)KnownColor.ActiveCaptionText] = Color.FromArgbSystem (255, 255, 255, 255, "ActiveCaptionText", KnownColor.ActiveCaptionText);
49                                 //TODO: find a more close approximation
50                                 SystemColorsCache[(int)KnownColor.AppWorkspace] = Color.FromArgbSystem (255, 128, 128, 128, "AppWorkspace", KnownColor.AppWorkspace);
51                                 SystemColorsCache[(int)KnownColor.Control] = Color.FromArgbSystem (255, 212, 208, 200, "Control", KnownColor.Control);
52                                 SystemColorsCache[(int)KnownColor.ControlDark] = Color.FromArgbSystem (255, 128, 128, 128, "ControlDark", KnownColor.ControlDark);
53                                 SystemColorsCache[(int)KnownColor.ControlDarkDark] = Color.FromArgbSystem (255, 64, 64, 64, "ControlDarkDark", KnownColor.ControlDarkDark);
54                                 SystemColorsCache[(int)KnownColor.ControlLight] = Color.FromArgbSystem (255, 212, 208, 200, "ControlLight", KnownColor.ControlLight);
55                                 SystemColorsCache[(int)KnownColor.ControlLightLight] = Color.FromArgbSystem (255, 255, 255, 255, "ControlLightLight", KnownColor.ControlLightLight);
56                                 SystemColorsCache[(int)KnownColor.ControlText] = Color.FromArgbSystem (255, 0, 0, 0, "ControlText", KnownColor.ControlText);
57                                 SystemColorsCache[(int)KnownColor.Desktop] = Color.FromArgbSystem (255, 58, 110, 165, "Desktop", KnownColor.Desktop);
58                                 SystemColorsCache[(int)KnownColor.GrayText] = Color.FromArgbSystem (255, 128, 128, 128, "GrayText", KnownColor.GrayText);
59                                 SystemColorsCache[(int)KnownColor.Highlight] = Color.FromArgbSystem (255, 10, 36, 106, "Highlight", KnownColor.Highlight);
60                                 SystemColorsCache[(int)KnownColor.HighlightText] = Color.FromArgbSystem (255, 255, 255, 255, "HighlightText", KnownColor.HighlightText);
61                                 //TODO: find a more close approximation
62                                 SystemColorsCache[(int)KnownColor.HotTrack] = Color.FromArgbSystem (255, 0, 0, 128, "HotTrack", KnownColor.HotTrack);
63                                 SystemColorsCache[(int)KnownColor.InactiveBorder] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveBorder", KnownColor.InactiveBorder);
64                                 SystemColorsCache[(int)KnownColor.InactiveCaption] = Color.FromArgbSystem (255, 128, 128, 128, "InactiveCaption", KnownColor.InactiveCaption);
65                                 SystemColorsCache[(int)KnownColor.InactiveCaptionText] = Color.FromArgbSystem (255, 212, 208, 200, "InactiveCaptionText", KnownColor.InactiveCaptionText);
66                                 SystemColorsCache[(int)KnownColor.Info] = Color.FromArgbSystem (255, 255, 255, 225, "Info", KnownColor.Info);
67                                 SystemColorsCache[(int)KnownColor.InfoText] = Color.FromArgbSystem (255, 0, 0, 0, "InfoText", KnownColor.InfoText);
68                                 SystemColorsCache[(int)KnownColor.Menu] = Color.FromArgbSystem (255, 212, 208, 200, "Menu", KnownColor.Menu);
69                                 SystemColorsCache[(int)KnownColor.MenuText] = Color.FromArgbSystem (255, 0, 0, 0, "MenuText", KnownColor.MenuText);
70                                 SystemColorsCache[(int)KnownColor.ScrollBar] = Color.FromArgbSystem (255, 212, 208, 200, "ScrollBar", KnownColor.ScrollBar);
71                                 SystemColorsCache[(int)KnownColor.Window] = Color.FromArgbSystem (255, 255, 255, 255, "Window", KnownColor.Window);
72                                 SystemColorsCache[(int)KnownColor.WindowFrame] = Color.FromArgbSystem (255, 0, 0, 0, "WindowFrame", KnownColor.WindowFrame);
73                                 SystemColorsCache[(int)KnownColor.WindowText] = Color.FromArgbSystem (255, 0, 0, 0, "WindowText", KnownColor.WindowText);
74                         }
75                         else {
76                                 SystemColorsCache[(int)KnownColor.ActiveBorder] = FromNativeColor (awt.SystemColor.activeCaptionBorder, "ActiveBorder", KnownColor.ActiveBorder);
77                                 SystemColorsCache[(int)KnownColor.ActiveCaption] = FromNativeColor (awt.SystemColor.activeCaption, "ActiveCaption", KnownColor.ActiveCaption);
78                                 SystemColorsCache[(int)KnownColor.ActiveCaptionText] = FromNativeColor (awt.SystemColor.activeCaptionText, "ActiveCaptionText", KnownColor.ActiveCaptionText);
79                                 //TODO: find a more close approximation
80                                 SystemColorsCache[(int)KnownColor.AppWorkspace] = FromNativeColor (awt.SystemColor.desktop, "AppWorkspace", KnownColor.AppWorkspace);
81                                 SystemColorsCache[(int)KnownColor.Control] = FromNativeColor (awt.SystemColor.control, "Control", KnownColor.Control);
82                                 SystemColorsCache[(int)KnownColor.ControlDark] = FromNativeColor (awt.SystemColor.controlShadow, "ControlDark", KnownColor.ControlDark);
83                                 SystemColorsCache[(int)KnownColor.ControlDarkDark] = FromNativeColor (awt.SystemColor.controlDkShadow, "ControlDarkDark", KnownColor.ControlDarkDark);
84                                 SystemColorsCache[(int)KnownColor.ControlLight] = FromNativeColor (awt.SystemColor.controlHighlight, "ControlLight", KnownColor.ControlLight);
85                                 SystemColorsCache[(int)KnownColor.ControlLightLight] = FromNativeColor (awt.SystemColor.controlLtHighlight, "ControlLightLight", KnownColor.ControlLightLight);
86                                 SystemColorsCache[(int)KnownColor.ControlText] = FromNativeColor (awt.SystemColor.controlText, "ControlText", KnownColor.ControlText);
87                                 SystemColorsCache[(int)KnownColor.Desktop] = FromNativeColor (awt.SystemColor.desktop, "Desktop", KnownColor.Desktop);
88                                 SystemColorsCache[(int)KnownColor.GrayText] = FromNativeColor (awt.SystemColor.textInactiveText, "GrayText", KnownColor.GrayText);
89                                 SystemColorsCache[(int)KnownColor.Highlight] = FromNativeColor (awt.SystemColor.textHighlight, "Highlight", KnownColor.Highlight);
90                                 SystemColorsCache[(int)KnownColor.HighlightText] = FromNativeColor (awt.SystemColor.textHighlightText, "HighlightText", KnownColor.HighlightText);
91                                 //TODO: find a more close approximation
92                                 SystemColorsCache[(int)KnownColor.HotTrack] = FromNativeColor (awt.SystemColor.textText, "HotTrack", KnownColor.HotTrack);
93                                 SystemColorsCache[(int)KnownColor.InactiveBorder] = FromNativeColor (awt.SystemColor.inactiveCaptionBorder, "InactiveBorder", KnownColor.InactiveBorder);
94                                 SystemColorsCache[(int)KnownColor.InactiveCaption] = FromNativeColor (awt.SystemColor.inactiveCaption, "InactiveCaption", KnownColor.InactiveCaption);
95                                 SystemColorsCache[(int)KnownColor.InactiveCaptionText] = FromNativeColor (awt.SystemColor.inactiveCaptionText, "InactiveCaptionText", KnownColor.InactiveCaptionText);
96                                 SystemColorsCache[(int)KnownColor.Info] = FromNativeColor (awt.SystemColor.info, "Info", KnownColor.Info);
97                                 SystemColorsCache[(int)KnownColor.InfoText] = FromNativeColor (awt.SystemColor.infoText, "InfoText", KnownColor.InfoText);
98                                 SystemColorsCache[(int)KnownColor.Menu] = FromNativeColor (awt.SystemColor.menu, "Menu", KnownColor.Menu);
99                                 SystemColorsCache[(int)KnownColor.MenuText] = FromNativeColor (awt.SystemColor.menuText, "MenuText", KnownColor.MenuText);
100                                 SystemColorsCache[(int)KnownColor.ScrollBar] = FromNativeColor (awt.SystemColor.scrollbar, "ScrollBar", KnownColor.ScrollBar);
101                                 SystemColorsCache[(int)KnownColor.Window] = FromNativeColor (awt.SystemColor.window, "Window", KnownColor.Window);
102                                 SystemColorsCache[(int)KnownColor.WindowFrame] = FromNativeColor (awt.SystemColor.windowBorder, "WindowFrame", KnownColor.WindowFrame);
103                                 SystemColorsCache[(int)KnownColor.WindowText] = FromNativeColor (awt.SystemColor.windowText, "WindowText", KnownColor.WindowText);
104                         }
105                 }
106
107                 static private Color FromNativeColor (
108                         awt.Color awtColor, string name, KnownColor knownColor) {
109                         return Color.FromArgbSystem (awtColor.getAlpha(),
110                                 awtColor.getRed(), awtColor.getGreen(), awtColor.getBlue(),
111                                 name, knownColor);
112                 }
113
114                 static public Color ActiveBorder
115                 {       
116                         get {
117                                 return SystemColorsCache[(int)KnownColor.ActiveBorder];
118                         }
119                 }
120
121                 static public Color ActiveCaption
122                 {       
123                         get {
124                                 return SystemColorsCache[(int)KnownColor.ActiveCaption];
125                         }
126                 }
127
128                 static public Color ActiveCaptionText
129                 {       
130                         get {
131                                 return SystemColorsCache[(int)KnownColor.ActiveCaptionText];
132                         }
133                 }
134
135                 static public Color AppWorkspace
136                 {       
137                         get {
138                                 return SystemColorsCache[(int)KnownColor.AppWorkspace];
139                         }
140                 }
141
142                 static public Color Control
143                 {       
144                         get {
145                                 return SystemColorsCache[(int)KnownColor.Control];
146                         }
147                 }
148
149                 static public Color ControlDark
150                 {       
151                         get {
152                                 return SystemColorsCache[(int)KnownColor.ControlDark];
153                         }
154                 }
155
156                 static public Color ControlDarkDark
157                 {       
158                         get {
159                                 return SystemColorsCache[(int)KnownColor.ControlDarkDark];
160                         }
161                 }
162
163                 static public Color ControlLight
164                 {       
165                         get {
166                                 return SystemColorsCache[(int)KnownColor.ControlLight];
167                         }
168                 }
169
170                 static public Color ControlLightLight
171                 {       
172                         get {
173                                 return SystemColorsCache[(int)KnownColor.ControlLightLight];
174                         }
175                 }
176
177                 static public Color ControlText
178                 {       
179                         get {
180                                 return SystemColorsCache[(int)KnownColor.ControlText];
181                         }
182                 }
183
184                 static public Color Desktop
185                 {       
186                         get {
187                                 return SystemColorsCache[(int)KnownColor.Desktop];
188                         }
189                 }
190
191                 static public Color GrayText
192                 {       
193                         get {
194                                 return SystemColorsCache[(int)KnownColor.GrayText];
195                         }
196                 }
197
198                 static public Color Highlight
199                 {       
200                         get {
201                                 return SystemColorsCache[(int)KnownColor.Highlight];
202                         }
203                 }
204
205                 static public Color HighlightText
206                 {       
207                         get {
208                                 return SystemColorsCache[(int)KnownColor.HighlightText];
209                         }
210                 }
211
212                 static public Color HotTrack
213                 {       
214                         get {
215                                 return SystemColorsCache[(int)KnownColor.HotTrack];
216                         }
217                 }
218
219                 static public Color InactiveBorder
220                 {       
221                         get {
222                                 return SystemColorsCache[(int)KnownColor.InactiveBorder];
223                         }
224                 }
225
226                 static public Color InactiveCaption
227                 {       
228                         get {
229                                 return SystemColorsCache[(int)KnownColor.InactiveCaption];
230                         }
231                 }
232
233                 static public Color InactiveCaptionText
234                 {       
235                         get {
236                                 return SystemColorsCache[(int)KnownColor.InactiveCaptionText];
237                         }
238                 }
239
240                 static public Color Info
241                 {       
242                         get {
243                                 return SystemColorsCache[(int)KnownColor.Info];
244                         }
245                 }
246
247                 static public Color InfoText
248                 {       
249                         get {
250                                 return SystemColorsCache[(int)KnownColor.InfoText];
251                         }
252                 }
253
254                 static public Color Menu
255                 {       
256                         get {
257                                 return SystemColorsCache[(int)KnownColor.Menu];
258                         }
259                 }
260
261                 static public Color MenuText
262                 {       
263                         get {
264                                 return SystemColorsCache[(int)KnownColor.MenuText];
265                         }
266                 }
267
268                 static public Color ScrollBar
269                 {       
270                         get {
271                                 return SystemColorsCache[(int)KnownColor.ScrollBar];
272                         }
273                 }
274
275                 static public Color Window
276                 {       
277                         get {
278                                 return SystemColorsCache[(int)KnownColor.Window];
279                         }
280                 }
281
282                 static public Color WindowFrame
283                 {       
284                         get {
285                                 return SystemColorsCache[(int)KnownColor.WindowFrame];
286                         }
287                 }
288
289                 static public Color WindowText
290                 {       
291                         get {
292                                 return SystemColorsCache[(int)KnownColor.WindowText];
293                         }
294                 }
295         }
296 }