OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libjava/] [classpath/] [java/] [awt/] [SystemColor.java] - Blame information for rev 771

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 771 jeremybenn
/* SystemColor.java -- access dynamic system color values
2
   Copyright (C) 1999, 2002, 2004, 2005  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., 51 Franklin Street, Fifth Floor, Boston, MA
19
02110-1301 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
import java.awt.geom.AffineTransform;
42
import java.awt.geom.Rectangle2D;
43
import java.awt.image.ColorModel;
44
import java.io.Serializable;
45
 
46
/**
47
 * This class contains the various "system colors" in use by the native
48
 * windowing system. The <code>getRGB()</code> method is dynamic on systems
49
 * which support dynamic system color changes, and most methods in the
50
 * superclass are written to use this dynamic value when reporting colors.
51
 * However, the <code>equals()</code> method is not dynamic, and does not
52
 * track the actual color of instances in this class. This means that equals
53
 * may give surprising results; you are better off relying on getRGB.
54
 *
55
 * @author Aaron M. Renn (arenn@urbanophile.com)
56
 * @author Eric Blake (ebb9@email.byu.edu)
57
 * @since 1.1
58
 * @status updated to 1.4
59
 */
60
public final class SystemColor extends Color implements Serializable
61
{
62
  // Implementation note: To be serial compatible with JDK, this class must
63
  // violate the semantic meaning of super.value to be one of the
64
  // NUM_COLORS constants instead of the actual RGB value. Hence there are
65
  // a lot of ugly workarounds in Color and in this class. I would have
66
  // designed it MUCH differently, making a separate id field in this class.
67
 
68
  /**
69
   * Compatible with JDK 1.1+.
70
   */
71
  private static final long serialVersionUID = 4503142729533789064L;
72
 
73
  /**
74
   * Array index of the desktop color.  Used by
75
   * {@link Toolkit#loadSystemColors(int[])}.
76
   *
77
   * @see #desktop
78
   */
79
  public static final int DESKTOP = 0;
80
 
81
  /**
82
   * Array index of the active caption color.  Used by
83
   * {@link Toolkit#loadSystemColors(int[])}.
84
   *
85
   * @see #activeCaption
86
   */
87
  public static final int ACTIVE_CAPTION = 1;
88
 
89
  /**
90
   * Array index of the active caption text color.  Used by
91
   * {@link Toolkit#loadSystemColors(int[])}.
92
   *
93
   * @see #activeCaptionText
94
   */
95
  public static final int ACTIVE_CAPTION_TEXT = 2;
96
 
97
  /**
98
   * Array index of the active caption border color.  Used by
99
   * {@link Toolkit#loadSystemColors(int[])}.
100
   *
101
   * @see #activeCaptionBorder
102
   */
103
  public static final int ACTIVE_CAPTION_BORDER = 3;
104
 
105
  /**
106
   * Array index of the inactive caption color.  Used by
107
   * {@link Toolkit#loadSystemColors(int[])}.
108
   *
109
   * @see #inactiveCaption
110
   */
111
  public static final int INACTIVE_CAPTION = 4;
112
 
113
  /**
114
   * Array index of the inactive caption text color.  Used by
115
   * {@link Toolkit#loadSystemColors(int[])}.
116
   *
117
   * @see #inactiveCaptionText
118
   */
119
  public static final int INACTIVE_CAPTION_TEXT = 5;
120
 
121
  /**
122
   * Array index of the inactive caption border color.  Used by
123
   * {@link Toolkit#loadSystemColors(int[])}.
124
   *
125
   * @see #inactiveCaptionBorder
126
   */
127
  public static final int INACTIVE_CAPTION_BORDER = 6;
128
 
129
  /**
130
   * Array index of the window background color.  Used by
131
   * {@link Toolkit#loadSystemColors(int[])}.
132
   *
133
   * @see #window
134
   */
135
  public static final int WINDOW = 7;
136
 
137
  /**
138
   * Array index of the window border color.  Used by
139
   * {@link Toolkit#loadSystemColors(int[])}.
140
   *
141
   * @see #windowBorder
142
   */
143
  public static final int WINDOW_BORDER = 8;
144
 
145
  /**
146
   * Array index of the window text color.  Used by
147
   * {@link Toolkit#loadSystemColors(int[])}.
148
   *
149
   * @see #windowText
150
   */
151
  public static final int WINDOW_TEXT = 9;
152
 
153
  /**
154
   * Array index of the menu background color.  Used by
155
   * {@link Toolkit#loadSystemColors(int[])}.
156
   *
157
   * @see #menu
158
   */
159
  public static final int MENU = 10;
160
 
161
  /**
162
   * Array index of the menu text color.  Used by
163
   * {@link Toolkit#loadSystemColors(int[])}.
164
   *
165
   * @see #menuText
166
   */
167
  public static final int MENU_TEXT = 11;
168
 
169
  /**
170
   * Array index of the text background color.  Used by
171
   * {@link Toolkit#loadSystemColors(int[])}.
172
   *
173
   * @see #text
174
   */
175
  public static final int TEXT = 12;
176
 
177
  /**
178
   * Array index of the text foreground color.  Used by
179
   * {@link Toolkit#loadSystemColors(int[])}.
180
   *
181
   * @see #textText
182
  */
183
  public static final int TEXT_TEXT = 13;
184
 
185
  /**
186
   * Array index of the highlighted text background color.  Used by
187
   * {@link Toolkit#loadSystemColors(int[])}.
188
   *
189
   * @see #textHighlight
190
   */
191
  public static final int TEXT_HIGHLIGHT = 14;
192
 
193
  /**
194
   * Array index of the highlighted text foreground color.  Used by
195
   * {@link Toolkit#loadSystemColors(int[])}.
196
   *
197
   * @see #textHighlightText
198
   */
199
  public static final int TEXT_HIGHLIGHT_TEXT = 15;
200
 
201
  /**
202
   * Array index of the inactive text foreground color.  Used by
203
   * {@link Toolkit#loadSystemColors(int[])}.
204
   *
205
   * @see #textInactiveText
206
   */
207
  public static final int TEXT_INACTIVE_TEXT = 16;
208
 
209
  /**
210
   * Array index of the control background color.  Used by
211
   * {@link Toolkit#loadSystemColors(int[])}.
212
   *
213
   * @see #control
214
   */
215
  public static final int CONTROL = 17;
216
 
217
  /**
218
   * Array index of the control text color.  Used by
219
   * {@link Toolkit#loadSystemColors(int[])}.
220
   *
221
   * @see #controlText
222
   */
223
  public static final int CONTROL_TEXT = 18;
224
 
225
  /**
226
   * Array index of the highlighted control background color.  Used by
227
   * {@link Toolkit#loadSystemColors(int[])}.
228
   *
229
   * @see #controlHighlight
230
   */
231
  public static final int CONTROL_HIGHLIGHT = 19;
232
 
233
  /**
234
   * Array index of the lightly highlighted control background color.  Used by
235
   * {@link Toolkit#loadSystemColors(int[])}.
236
   *
237
   * @see #controlLtHighlight
238
   */
239
  public static final int CONTROL_LT_HIGHLIGHT = 20;
240
 
241
  /**
242
   * Array index of the shadowed control background color.  Used by
243
   * {@link Toolkit#loadSystemColors(int[])}.
244
   *
245
   * @see #controlShadow
246
   */
247
  public static final int CONTROL_SHADOW = 21;
248
 
249
  /**
250
   * Array index of the darkly shadowed control background color.  Used by
251
   * {@link Toolkit#loadSystemColors(int[])}.
252
   *
253
   * @see #controlDkShadow
254
   */
255
  public static final int CONTROL_DK_SHADOW = 22;
256
 
257
  /**
258
   * Array index of the scrollbar background color.  Used by
259
   * {@link Toolkit#loadSystemColors(int[])}.
260
   *
261
   * @see #scrollbar
262
   */
263
  public static final int SCROLLBAR = 23;
264
 
265
  /**
266
   * Array index of the info background color.  Used by
267
   * {@link Toolkit#loadSystemColors(int[])}.
268
   *
269
   * @see #info
270
   */
271
  public static final int INFO = 24;
272
 
273
  /**
274
   * Array index of the info text color.  Used by
275
   * {@link Toolkit#loadSystemColors(int[])}.
276
   *
277
   * @see #infoText
278
   */
279
  public static final int INFO_TEXT = 25;
280
 
281
  /**
282
   * The number of system colors. Used by
283
   * {@link Toolkit#loadSystemColors(int[])}.
284
   */
285
  public static final int NUM_COLORS = 26;
286
 
287
  /**
288
   * The internal array used to dynamically update <code>getRGB()</code>.
289
   */
290
  private static final int[] colors = new int[NUM_COLORS];
291
 
292
  /** The desktop color. */
293
  public static final SystemColor desktop
294
    = new SystemColor(DESKTOP);
295
 
296
  /** The active caption background color. */
297
  public static final SystemColor activeCaption
298
    = new SystemColor(ACTIVE_CAPTION);
299
 
300
  /** The active caption text color. */
301
  public static final SystemColor activeCaptionText
302
    = new SystemColor(ACTIVE_CAPTION_TEXT);
303
 
304
  /** The active caption border color. */
305
  public static final SystemColor activeCaptionBorder
306
    = new SystemColor(ACTIVE_CAPTION_BORDER);
307
 
308
  /** The inactive caption background color. */
309
  public static final SystemColor inactiveCaption
310
    = new SystemColor(INACTIVE_CAPTION);
311
 
312
  /** The inactive caption text color. */
313
  public static final SystemColor inactiveCaptionText
314
    = new SystemColor(INACTIVE_CAPTION_TEXT);
315
 
316
  /** The inactive caption border color. */
317
  public static final SystemColor inactiveCaptionBorder
318
    = new SystemColor(INACTIVE_CAPTION_BORDER);
319
 
320
  /** The window background color. */
321
  public static final SystemColor window
322
    = new SystemColor(WINDOW);
323
 
324
  /** The window border color. */
325
  public static final SystemColor windowBorder
326
    = new SystemColor(WINDOW_BORDER);
327
 
328
  /** The window text color. */
329
  public static final SystemColor windowText
330
    = new SystemColor(WINDOW_TEXT);
331
 
332
  /** The menu background color. */
333
  public static final SystemColor menu
334
    = new SystemColor(MENU);
335
 
336
  /** The menu text color. */
337
  public static final SystemColor menuText
338
    = new SystemColor(MENU_TEXT);
339
 
340
  /** The text background color. */
341
  public static final SystemColor text
342
    = new SystemColor(TEXT);
343
 
344
  /** The text foreground color. */
345
  public static final SystemColor textText
346
    = new SystemColor(TEXT_TEXT);
347
 
348
  /** The highlighted text background color. */
349
  public static final SystemColor textHighlight
350
    = new SystemColor(TEXT_HIGHLIGHT);
351
 
352
  /** The highlighted text foreground color. */
353
  public static final SystemColor textHighlightText
354
    = new SystemColor(TEXT_HIGHLIGHT_TEXT);
355
 
356
  /** The inactive text color. */
357
  public static final SystemColor textInactiveText
358
    = new SystemColor(TEXT_INACTIVE_TEXT);
359
 
360
  /** The control background color. */
361
  public static final SystemColor control
362
    = new SystemColor(CONTROL);
363
 
364
  /** The control text color. */
365
  public static final SystemColor controlText
366
    = new SystemColor(CONTROL_TEXT);
367
 
368
  /** The control highlight color. */
369
  public static final SystemColor controlHighlight
370
    = new SystemColor(CONTROL_HIGHLIGHT);
371
 
372
  /** The control light highlight color. */
373
  public static final SystemColor controlLtHighlight
374
    = new SystemColor(CONTROL_LT_HIGHLIGHT);
375
 
376
  /** The control shadow color. */
377
  public static final SystemColor controlShadow
378
    = new SystemColor(CONTROL_SHADOW);
379
 
380
  /** The control dark shadow color. */
381
  public static final SystemColor controlDkShadow
382
    = new SystemColor(CONTROL_DK_SHADOW);
383
 
384
  /** The scrollbar color. */
385
  public static final SystemColor scrollbar
386
    = new SystemColor(SCROLLBAR);
387
 
388
  /** The info text background color. */
389
  public static final SystemColor info
390
    = new SystemColor(INFO);
391
 
392
  /** The info text foreground color. */
393
  public static final SystemColor infoText
394
    = new SystemColor(INFO_TEXT);
395
 
396
  /**
397
   * Construct a system color which is dynamically updated.
398
   *
399
   * @param id the color id
400
   */
401
  private SystemColor(int id)
402
  {
403
    // Note: See Color#Color(int, boolean) to explain why we use this
404
    // particular constructor.
405
    super(id, true);
406
  }
407
 
408
  /**
409
   * Returns the RGB value for this color, in the sRGB color space. The blue
410
   * value will be in bits 0-7, green in 8-15, red in 6-23, and the alpha
411
   * value (bits 24-31) is 0xff. This is dynamically updated, so it may not
412
   * match the results of <code>getRed()</code>, <code>getGreen()</code>, or
413
   * <code>getBlue()</code>.
414
   *
415
   * @return the current RGB value
416
   */
417
  public int getRGB()
418
  {
419
    Toolkit.getDefaultToolkit().loadSystemColors(colors);
420
    return colors[value] | ALPHA_MASK;
421
  }
422
 
423
  /**
424
   * Returns a paint context, used for filling areas of a raster scan with
425
   * the current value of this system color. Since the system colors may be
426
   * dynamically updated, the returned value may not always be the same; but
427
   * as the system color is solid, the context does not need any of the
428
   * passed parameters to do its job.
429
   *
430
   * @param cm the requested color model
431
   * @param deviceBounds the bounding box in device coordinates, ignored
432
   * @param userBounds the bounding box in user coordinates, ignored
433
   * @param xform the bounds transformation, ignored
434
   * @param hints any rendering hints, ignored
435
   * @return a context for painting this solid color
436
   */
437
  public PaintContext createContext(ColorModel cm, Rectangle deviceBounds,
438
                                    Rectangle2D userBounds,
439
                                    AffineTransform xform,
440
                                    RenderingHints hints)
441
  {
442
    Toolkit.getDefaultToolkit().loadSystemColors(colors);
443
    int color = colors[value] | ALPHA_MASK;
444
    if (context == null || color != context.color || !context.getColorModel().equals(cm))
445
      context = new ColorPaintContext(cm,color);
446
    return context;
447
  }
448
 
449
  /**
450
   * Returns a string describing this color. This is in the format
451
   * "java.awt.SystemColor[i=" + index + ']', where index is one of the
452
   * integer constants of this class. Unfortunately, this description
453
   * does not describe the current value of the color; for that you should
454
   * use <code>new Color(syscolor.getRGB()).toString()</code>.
455
   *
456
   * @return a string describing this color
457
   */
458
  public String toString()
459
  {
460
    return "java.awt.SystemColor[i=" + value + ']';
461
  }
462
} // class SystemColor

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.