OSDN Git Service

2002-04-07 Adam King <aking@dreammechanics.com>
[pf3gnuchains/gcc-fork.git] / libjava / java / awt / SystemColor.java
1 /* SystemColor.java -- Class to access system color values.
2    Copyright (C) 1999 Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38
39 package java.awt;
40
41 /**
42   * This class contains the various "system colors" in use by the
43   * native windowing system.
44   *
45   * @author Aaron M. Renn (arenn@urbanophile.com)
46   */
47 public final class SystemColor extends Color implements java.io.Serializable
48 {
49
50 /*
51  * Static Variables
52  */
53
54 /**
55   * Array index of the desktop color.  Used by 
56   * <code>Toolkit.loadSystemColors()</code>.
57   */
58 public static final int DESKTOP = 0;
59
60 /**
61   * Array index of the active caption color.  Used by 
62   * <code>Toolkit.loadSystemColors()</code>.
63   */
64 public static final int ACTIVE_CAPTION = 1;
65
66 /**
67   * Array index of the active caption text color.  Used by 
68   * <code>Toolkit.loadSystemColors()</code>.
69   */
70 public static final int ACTIVE_CAPTION_TEXT = 2;
71
72 /**
73   * Array index of the active caption border color.  Used by 
74   * <code>Toolkit.loadSystemColors()</code>.
75   */
76 public static final int ACTIVE_CAPTION_BORDER = 3;
77
78 /**
79   * Array index of the inactive caption color.  Used by 
80   * <code>Toolkit.loadSystemColors()</code>.
81   */
82 public static final int INACTIVE_CAPTION = 4;
83
84 /**
85   * Array index of the inactive caption text color.  Used by 
86   * <code>Toolkit.loadSystemColors()</code>.
87   */
88 public static final int INACTIVE_CAPTION_TEXT = 5;
89
90 /**
91   * Array index of the inactive caption border color.  Used by 
92   * <code>Toolkit.loadSystemColors()</code>.
93   */
94 public static final int INACTIVE_CAPTION_BORDER = 6;
95
96 /**
97   * Array index of the window background color.  Used by 
98   * <code>Toolkit.loadSystemColors()</code>.
99   */
100 public static final int WINDOW = 7;
101
102 /**
103   * Array index of the window border color.  Used by 
104   * <code>Toolkit.loadSystemColors()</code>.
105   */
106 public static final int WINDOW_BORDER = 8;
107
108 /**
109   * Array index of the window text color.  Used by 
110   * <code>Toolkit.loadSystemColors()</code>.
111   */
112 public static final int WINDOW_TEXT = 9;
113
114 /**
115   * Array index of the menu background color.  Used by 
116   * <code>Toolkit.loadSystemColors()</code>.
117   */
118 public static final int MENU = 10;
119
120 /**
121   * Array index of the menu text color.  Used by 
122   * <code>Toolkit.loadSystemColors()</code>.
123   */
124 public static final int MENU_TEXT = 11;
125
126 /**
127   * Array index of the text background color.  Used by 
128   * <code>Toolkit.loadSystemColors()</code>.
129   */
130 public static final int TEXT = 12;
131
132 /**
133   * Array index of the text foreground color.  Used by 
134   * <code>Toolkit.loadSystemColors()</code>.
135   */
136 public static final int TEXT_TEXT = 13;
137
138 /**
139   * Array index of the highlighted text background color.  Used by 
140   * <code>Toolkit.loadSystemColors()</code>.
141   */
142 public static final int TEXT_HIGHLIGHT = 14;
143
144 /**
145   * Array index of the highlighted text foreground color.  Used by 
146   * <code>Toolkit.loadSystemColors()</code>.
147   */
148 public static final int TEXT_HIGHLIGHT_TEXT = 15;
149
150 /**
151   * Array index of the inactive text foreground color.  Used by 
152   * <code>Toolkit.loadSystemColors()</code>.
153   */
154 public static final int TEXT_INACTIVE_TEXT = 16;
155
156 /**
157   * Array index of the control background color.  Used by 
158   * <code>Toolkit.loadSystemColors()</code>.
159   */
160 public static final int CONTROL = 17;
161
162 /**
163   * Array index of the control text color.  Used by 
164   * <code>Toolkit.loadSystemColors()</code>.
165   */
166 public static final int CONTROL_TEXT = 18;
167
168 /**
169   * Array index of the highlighted control background color.  Used by 
170   * <code>Toolkit.loadSystemColors()</code>.
171   */
172 public static final int CONTROL_HIGHLIGHT = 19;
173
174 /**
175   * Array index of the lightly highlighted control background color.  Used by 
176   * <code>Toolkit.loadSystemColors()</code>.
177   */
178 public static final int CONTROL_LT_HIGHLIGHT = 20;
179
180 /**
181   * Array index of the shadowed control background color.  Used by 
182   * <code>Toolkit.loadSystemColors()</code>.
183   */
184 public static final int CONTROL_SHADOW = 21;
185
186 /**
187   * Array index of the darkly shadowed control background color.  Used by 
188   * <code>Toolkit.loadSystemColors()</code>.
189   */
190 public static final int CONTROL_DK_SHADOW = 22;
191
192 /**
193   * Array index of the scrollbar background color.  Used by 
194   * <code>Toolkit.loadSystemColors()</code>.
195   */
196 public static final int SCROLLBAR = 23;
197
198 /**
199   * Array index of the info background color.  Used by 
200   * <code>Toolkit.loadSystemColors()</code>.
201   */
202 public static final int INFO = 24;
203
204 /**
205   * Array index of the info text color.  Used by 
206   * <code>Toolkit.loadSystemColors()</code>.
207   */
208 public static final int INFO_TEXT = 25;
209
210 /**
211   * The number of system colors. Used by
212   * <code>Toolkit.loadSystemColors()</code>.
213   */
214 public static final int NUM_COLORS = 26;
215
216 /**
217   * The desktop color.
218   */
219 public static final SystemColor desktop;
220
221 /**
222   * The active caption background color.
223   */
224 public static final SystemColor activeCaption;
225
226 /**
227   * The active caption text color.
228   */
229 public static final SystemColor activeCaptionText;
230
231 /**
232   * The active caption border color.
233   */
234 public static final SystemColor activeCaptionBorder;
235
236 /**
237   * The inactive caption background color.
238   */
239 public static final SystemColor inactiveCaption;
240
241 /**
242   * The inactive caption text color.
243   */
244 public static final SystemColor inactiveCaptionText;
245
246 /**
247   * The inactive caption border color.
248   */
249 public static final SystemColor inactiveCaptionBorder;
250
251 /**
252   * The window background color.
253   */
254 public static final SystemColor window;
255
256 /**
257   * The window border color.
258   */
259 public static final SystemColor windowBorder;
260
261 /**
262   * The window text color.
263   */
264 public static final SystemColor windowText;
265
266 /**
267   * The menu background color.
268   */
269 public static final SystemColor menu;
270
271 /**
272   * The menu text color.
273   */
274 public static final SystemColor menuText;
275
276 /**
277   * The text background color.
278   */
279 public static final SystemColor text;
280
281 /**
282   * The text foreground color.
283   */
284 public static final SystemColor textText;
285
286 /**
287   * The highlighted text background color.
288   */
289 public static final SystemColor textHighlight;
290
291 /**
292   * The highlighted text foreground color.
293   */
294 public static final SystemColor textHighlightText;
295
296 /**
297   * The inactive text color.
298   */
299 public static final SystemColor textInactiveText;
300
301 /**
302   * The control background color.
303   */
304 public static final SystemColor control;
305
306 /**
307   * The control text color.
308   */
309 public static final SystemColor controlText;
310
311 /**
312   * The control highlight color.
313   */
314 public static final SystemColor controlHighlight;
315
316 /**
317   * The control light highlight color.
318   */
319 public static final SystemColor controlLtHighlight; 
320
321 /**
322   * The control shadow color.
323   */
324 public static final SystemColor controlShadow;
325
326 /**
327   * The control dark shadow color.
328   */
329 public static final SystemColor controlDkShadow;
330
331 /**
332   * The scrollbar color.
333   */
334 public static final SystemColor scrollbar;
335
336 /**
337   * The info text background color.
338   */
339 public static final SystemColor info;
340
341 /**
342   * The info text foreground color.
343   */
344 public static final SystemColor infoText;
345
346 // Serialization version constant
347 private static final long serialVersionUID = 4503142729533789064L;
348
349 static
350 {
351   int[] sys_color_rgbs = new int[NUM_COLORS];
352   Toolkit.getDefaultToolkit().loadSystemColors(sys_color_rgbs);
353
354   desktop = new SystemColor(sys_color_rgbs[DESKTOP]);
355   activeCaption= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION]);
356   activeCaptionText= new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_TEXT]);
357   activeCaptionBorder = new SystemColor(sys_color_rgbs[ACTIVE_CAPTION_BORDER]);
358   inactiveCaption = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION]);
359   inactiveCaptionText = new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_TEXT]);
360   inactiveCaptionBorder = 
361     new SystemColor(sys_color_rgbs[INACTIVE_CAPTION_BORDER]);
362   window = new SystemColor(sys_color_rgbs[WINDOW]);
363   windowBorder = new SystemColor(sys_color_rgbs[WINDOW_BORDER]);
364   windowText = new SystemColor(sys_color_rgbs[WINDOW_TEXT]);
365   menu = new SystemColor(sys_color_rgbs[MENU]);
366   menuText = new SystemColor(sys_color_rgbs[MENU_TEXT]);
367   text = new SystemColor(sys_color_rgbs[TEXT]);
368   textText = new SystemColor(sys_color_rgbs[TEXT_TEXT]);
369   textHighlight = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT]);
370   textHighlightText = new SystemColor(sys_color_rgbs[TEXT_HIGHLIGHT_TEXT]);
371   textInactiveText = new SystemColor(sys_color_rgbs[TEXT_INACTIVE_TEXT]);
372   control = new SystemColor(sys_color_rgbs[CONTROL]);
373   controlText = new SystemColor(sys_color_rgbs[CONTROL_TEXT]);
374   controlHighlight = new SystemColor(sys_color_rgbs[CONTROL_HIGHLIGHT]);
375   controlLtHighlight = new SystemColor(sys_color_rgbs[CONTROL_LT_HIGHLIGHT]);
376   controlShadow = new SystemColor(sys_color_rgbs[CONTROL_SHADOW]);
377   controlDkShadow = new SystemColor(sys_color_rgbs[CONTROL_DK_SHADOW]);
378   scrollbar = new SystemColor(sys_color_rgbs[SCROLLBAR]);
379   info = new SystemColor(sys_color_rgbs[INFO]);
380   infoText = new SystemColor(sys_color_rgbs[INFO_TEXT]);
381 }
382
383 /*************************************************************************/
384
385 /*
386  * Constructors
387  */
388
389 private
390 SystemColor(int rgb)
391 {
392   super(rgb);
393 }
394
395 /*************************************************************************/
396
397 /*
398  * Instance Methods
399  */
400
401 /**
402   * Returns the RGB value for this color as an <code>int</code>.  The first
403   * byte is the blue value, the second the green value, the third the
404   * red value and the fourth is set to 0xFF.
405   *
406   * @return The RGB value.
407   */
408 public int
409 getRGB()
410 {
411   // Override only to be spec consistent.
412   return(super.getRGB());
413 }
414
415 /*************************************************************************/
416
417 /**
418   * Returns a string describing this color.
419   *
420   * @return A string describing this color.
421   */
422 public String
423 toString()
424 {
425   return("SystemColor(R=" + getRed() + ",G=" + getGreen() + ",B=" +
426          getBlue() + ")");
427 }
428
429 } // class SystemColor 
430