2 Copyright (C) 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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)
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.
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
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
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. */
40 package javax
.swing
.plaf
.metal
;
42 import java
.awt
.Color
;
44 import javax
.swing
.UIDefaults
;
45 import javax
.swing
.plaf
.ColorUIResource
;
46 import javax
.swing
.plaf
.FontUIResource
;
49 * The base class for themes used by the {@link MetalLookAndFeel}. A default
50 * theme ({@link DefaultMetalTheme}) is provided, or you can create and use
53 * @see MetalLookAndFeel#setCurrentTheme(MetalTheme)
55 public abstract class MetalTheme
57 private ColorUIResource BLACK
= new ColorUIResource(Color
.BLACK
);
58 private ColorUIResource WHITE
= new ColorUIResource(Color
.WHITE
);
61 * Default constructor.
69 * Returns the name of the theme.
71 * @return The name of the theme.
73 public abstract String
getName();
76 * Adds custom entries to the UI defaults table. This method is empty.
78 * @param table the table.
80 public void addCustomEntriesToTable(UIDefaults table
)
83 // This method needs to be overridden to actually do something.
84 // It is called from MetalLookAndFeel.getDefaults().
88 * Returns the accelerator foreground color. The default implementation
89 * returns the color from {@link #getPrimary1()}.
91 * @return The accelerator foreground color.
93 public ColorUIResource
getAcceleratorForeground()
99 * Returns the accelerator selected foreground color. The default
100 * implementation returns the color from {@link #getBlack()}.
102 * @return The accelerator selected foreground color.
104 public ColorUIResource
getAcceleratorSelectedForeground()
110 * Returns the control color. The default implementation returns the color
111 * from {@link #getSecondary3()}.
113 * @return The control color.
115 public ColorUIResource
getControl()
117 return getSecondary3();
121 * Returns the color used for dark shadows on controls. The default
122 * implementation returns the color from {@link #getSecondary1()}.
124 * @return The color used for dark shadows on controls.
126 public ColorUIResource
getControlDarkShadow()
128 return getSecondary1();
132 * Returns the color used for disabled controls. The default implementation
133 * returns the color from {@link #getSecondary1()}.
135 * @return The color used for disabled controls.
137 public ColorUIResource
getControlDisabled()
139 return getSecondary2();
143 * Returns the color used to draw highlights for controls. The default
144 * implementation returns the color from {@link #getWhite()}.
146 * @return The color used to draw highlights for controls.
148 public ColorUIResource
getControlHighlight()
154 * Returns the color used to display control info. The default
155 * implementation returns the color from {@link #getBlack()}.
157 * @return The color used to display control info.
159 public ColorUIResource
getControlInfo()
165 * Returns the color used to draw shadows for controls. The default
166 * implementation returns the color from {@link #getSecondary2()}.
168 * @return The color used to draw shadows for controls.
170 public ColorUIResource
getControlShadow()
172 return getSecondary2();
176 * Returns the color used for text on controls. The default implementation
177 * returns the color from {@link #getControlInfo()}.
179 * @return The color used for text on controls.
181 public ColorUIResource
getControlTextColor()
183 return getControlInfo();
187 * Returns the color used for the desktop background. The default
188 * implementation returns the color from {@link #getPrimary2()}.
190 * @return The color used for the desktop background.
192 public ColorUIResource
getDesktopColor()
194 return getPrimary2();
198 * Returns the color used to draw focus highlights. The default
199 * implementation returns the color from {@link #getPrimary2()}.
201 * @return The color used to draw focus highlights.
203 public ColorUIResource
getFocusColor()
205 return getPrimary2();
209 * Returns the color used to draw highlighted text. The default
210 * implementation returns the color from {@link #getHighlightedTextColor()}.
212 * @return The color used to draw highlighted text.
214 public ColorUIResource
getHighlightedTextColor()
216 return getControlTextColor();
220 * Returns the color used to draw text on inactive controls. The default
221 * implementation returns the color from {@link #getControlDisabled()}.
223 * @return The color used to draw text on inactive controls.
225 public ColorUIResource
getInactiveControlTextColor()
227 return getControlDisabled();
231 * Returns the color used to draw inactive system text. The default
232 * implementation returns the color from {@link #getSecondary2()}.
234 * @return The color used to draw inactive system text.
236 public ColorUIResource
getInactiveSystemTextColor()
238 return getSecondary2();
242 * Returns the background color for menu items. The default implementation
243 * returns the color from {@link #getSecondary3()}.
245 * @return The background color for menu items.
247 * @see #getMenuSelectedBackground()
249 public ColorUIResource
getMenuBackground()
251 return getSecondary3();
255 * Returns the foreground color for disabled menu items. The default
256 * implementation returns the color from {@link #getSecondary2()}.
258 * @return The foreground color for disabled menu items.
260 * @see #getMenuForeground()
262 public ColorUIResource
getMenuDisabledForeground()
264 return getSecondary2();
268 * Returns the foreground color for menu items. The default implementation
269 * returns the color from {@link #getBlack()}.
271 * @return The foreground color for menu items.
273 * @see #getMenuDisabledForeground()
274 * @see #getMenuSelectedForeground()
276 public ColorUIResource
getMenuForeground()
282 * Returns the background color for selected menu items. The default
283 * implementation returns the color from {@link #getPrimary2()}.
285 * @return The background color for selected menu items.
287 * @see #getMenuBackground()
289 public ColorUIResource
getMenuSelectedBackground()
291 return getPrimary2();
295 * Returns the foreground color for selected menu items. The default
296 * implementation returns the value from {@link #getBlack()}.
298 * @return The foreground color for selected menu items.
300 * @see #getMenuForeground()
302 public ColorUIResource
getMenuSelectedForeground()
308 * Returns the primary color for controls. The default implementation
309 * returns the color from {@link #getPrimary3()}.
311 * @return The primary color for controls.
313 public ColorUIResource
getPrimaryControl()
315 return getPrimary3();
319 * Returns the primary color for the dark shadow on controls. The default
320 * implementation returns the color from {@link #getPrimary1()}.
322 * @return The primary color for the dark shadow on controls.
324 public ColorUIResource
getPrimaryControlDarkShadow()
326 return getPrimary1();
330 * Returns the primary color for the highlight on controls. The default
331 * implementation returns the color from {@link #getWhite()}.
333 * @return The primary color for the highlight on controls.
335 public ColorUIResource
getPrimaryControlHighlight()
341 * Returns the primary color for the information on controls. The default
342 * implementation returns the color from {@link #getBlack()}.
344 * @return The primary color for the information on controls.
346 public ColorUIResource
getPrimaryControlInfo()
352 * Returns the primary color for the shadow on controls. The default
353 * implementation returns the color from {@link #getPrimary2()}.
355 * @return The primary color for the shadow on controls.
357 public ColorUIResource
getPrimaryControlShadow()
359 return getPrimary2();
363 * Returns the background color for separators. The default implementation
364 * returns the color from {@link #getWhite()}.
366 * @return The background color for separators.
368 public ColorUIResource
getSeparatorBackground()
374 * Returns the foreground color for separators. The default implementation
375 * returns the value from {@link #getPrimary1()}.
377 * @return The foreground color for separators.
379 public ColorUIResource
getSeparatorForeground()
381 return getPrimary1();
385 * Returns the color used for system text. The default implementation
386 * returns the color from {@link #getBlack()}.
388 * @return The color used for system text.
390 public ColorUIResource
getSystemTextColor()
396 * Returns the color used to highlight text. The default implementation
397 * returns the color from {@link #getPrimary3()}.
399 * @return The color used to highlight text.
401 public ColorUIResource
getTextHighlightColor()
403 return getPrimary3();
407 * Returns the color used to display user text. The default implementation
408 * returns the color from {@link #getBlack()}.
410 * @return The color used to display user text.
412 public ColorUIResource
getUserTextColor()
418 * Returns the window background color. The default implementation returns
419 * the color from {@link #getWhite()}.
421 * @return The window background color.
423 public ColorUIResource
getWindowBackground()
429 * Returns the window title background color. The default implementation
430 * returns the color from {@link #getPrimary3()}.
432 * @return The window title background color.
434 public ColorUIResource
getWindowTitleBackground()
436 return getPrimary3();
440 * Returns the window title foreground color. The default implementation
441 * returns the color from {@link #getBlack()}.
443 * @return The window title foreground color.
445 public ColorUIResource
getWindowTitleForeground()
451 * Returns the background color for an inactive window title. The default
452 * implementation returns the color from {@link #getSecondary3()}.
454 * @return The background color for an inactive window title.
456 public ColorUIResource
getWindowTitleInactiveBackground()
458 return getSecondary3();
462 * Returns the foreground color for an inactive window title. The default
463 * implementation returns the color from {@link #getBlack()}.
465 * @return The foreground color for an inactive window title.
467 public ColorUIResource
getWindowTitleInactiveForeground()
473 * Returns the color used for black.
475 * @return The color used for black.
477 protected ColorUIResource
getBlack()
483 * Returns the color used for white.
485 * @return The color used for white.
487 protected ColorUIResource
getWhite()
493 * Returns the first primary color for this theme.
495 * @return The first primary color.
497 protected abstract ColorUIResource
getPrimary1();
500 * Returns the second primary color for this theme.
502 * @return The second primary color.
504 protected abstract ColorUIResource
getPrimary2();
507 * Returns the third primary color for this theme.
509 * @return The third primary color.
511 protected abstract ColorUIResource
getPrimary3();
514 * Returns the first secondary color for this theme.
516 * @return The first secondary color.
518 protected abstract ColorUIResource
getSecondary1();
521 * Returns the second secondary color for this theme.
523 * @return The second secondary color.
525 protected abstract ColorUIResource
getSecondary2();
528 * Returns the third secondary color for this theme.
530 * @return The third secondary color.
532 protected abstract ColorUIResource
getSecondary3();
535 * Returns the font used for text on controls.
537 * @return The font used for text on controls.
539 public abstract FontUIResource
getControlTextFont();
542 * Returns the font used for text in menus.
544 * @return The font used for text in menus.
546 public abstract FontUIResource
getMenuTextFont();
549 * Returns the font used for sub text.
551 * @return The font used for sub text.
553 public abstract FontUIResource
getSubTextFont();
556 * Returns the font used for system text.
558 * @return The font used for system text.
560 public abstract FontUIResource
getSystemTextFont();
563 * Returns the font used for user text.
565 * @return The font used for user text.
567 public abstract FontUIResource
getUserTextFont();
570 * Returns the font used for window titles.
572 * @return The font used for window titles.
574 public abstract FontUIResource
getWindowTitleFont();