1. /*
  2. * @(#)MetalTheme.java 1.23 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.swing.plaf.metal;
  8. import javax.swing.plaf.*;
  9. import javax.swing.*;
  10. /**
  11. * This interface acts as a generic way to describe the colors
  12. * used by Metal. Classes which implement this interface can
  13. * be used to swap the colors in a Metal application.
  14. *
  15. * @version 1.23 01/23/03
  16. * @author Steve Wilson
  17. */
  18. public abstract class MetalTheme {
  19. // Contants identifying the various Fonts that are Theme can support
  20. static final int CONTROL_TEXT_FONT = 0;
  21. static final int SYSTEM_TEXT_FONT = 1;
  22. static final int USER_TEXT_FONT = 2;
  23. static final int MENU_TEXT_FONT = 3;
  24. static final int WINDOW_TITLE_FONT = 4;
  25. static final int SUB_TEXT_FONT = 5;
  26. private static ColorUIResource white = new ColorUIResource( 255, 255, 255 );
  27. private static ColorUIResource black = new ColorUIResource( 0, 0, 0 );
  28. public abstract String getName();
  29. protected abstract ColorUIResource getPrimary1(); // these are blue in Metal Default Theme
  30. protected abstract ColorUIResource getPrimary2();
  31. protected abstract ColorUIResource getPrimary3();
  32. protected abstract ColorUIResource getSecondary1(); // these are gray in Metal Default Theme
  33. protected abstract ColorUIResource getSecondary2();
  34. protected abstract ColorUIResource getSecondary3();
  35. public abstract FontUIResource getControlTextFont();
  36. public abstract FontUIResource getSystemTextFont();
  37. public abstract FontUIResource getUserTextFont();
  38. public abstract FontUIResource getMenuTextFont();
  39. public abstract FontUIResource getWindowTitleFont();
  40. public abstract FontUIResource getSubTextFont();
  41. protected ColorUIResource getWhite() { return white; }
  42. protected ColorUIResource getBlack() { return black; }
  43. public ColorUIResource getFocusColor() { return getPrimary2(); }
  44. public ColorUIResource getDesktopColor() { return getPrimary2(); }
  45. public ColorUIResource getControl() { return getSecondary3(); }
  46. public ColorUIResource getControlShadow() { return getSecondary2(); }
  47. public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
  48. public ColorUIResource getControlInfo() { return getBlack(); }
  49. public ColorUIResource getControlHighlight() { return getWhite(); }
  50. public ColorUIResource getControlDisabled() { return getSecondary2(); }
  51. public ColorUIResource getPrimaryControl() { return getPrimary3(); }
  52. public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
  53. public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
  54. public ColorUIResource getPrimaryControlInfo() { return getBlack(); }
  55. public ColorUIResource getPrimaryControlHighlight() { return getWhite(); }
  56. /**
  57. * Returns the color used, by default, for the text in labels
  58. * and titled borders.
  59. */
  60. public ColorUIResource getSystemTextColor() { return getBlack(); }
  61. public ColorUIResource getControlTextColor() { return getControlInfo(); }
  62. public ColorUIResource getInactiveControlTextColor() { return getControlDisabled(); }
  63. public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
  64. public ColorUIResource getUserTextColor() { return getBlack(); }
  65. public ColorUIResource getTextHighlightColor() { return getPrimary3(); }
  66. public ColorUIResource getHighlightedTextColor() { return getControlTextColor(); }
  67. public ColorUIResource getWindowBackground() { return getWhite(); }
  68. public ColorUIResource getWindowTitleBackground() { return getPrimary3(); }
  69. public ColorUIResource getWindowTitleForeground() { return getBlack(); }
  70. public ColorUIResource getWindowTitleInactiveBackground() { return getSecondary3(); }
  71. public ColorUIResource getWindowTitleInactiveForeground() { return getBlack(); }
  72. public ColorUIResource getMenuBackground() { return getSecondary3(); }
  73. public ColorUIResource getMenuForeground() { return getBlack(); }
  74. public ColorUIResource getMenuSelectedBackground() { return getPrimary2(); }
  75. public ColorUIResource getMenuSelectedForeground() { return getBlack(); }
  76. public ColorUIResource getMenuDisabledForeground() { return getSecondary2(); }
  77. public ColorUIResource getSeparatorBackground() { return getWhite(); }
  78. public ColorUIResource getSeparatorForeground() { return getPrimary1(); }
  79. public ColorUIResource getAcceleratorForeground() { return getPrimary1(); }
  80. public ColorUIResource getAcceleratorSelectedForeground() { return getBlack(); }
  81. public void addCustomEntriesToTable(UIDefaults table) {}
  82. /**
  83. * This is invoked when a MetalLookAndFeel is installed and about to
  84. * start using this theme. When we can add API this should be nuked
  85. * in favor of DefaultMetalTheme overriding addCustomEntriesToTable.
  86. */
  87. void install() {
  88. }
  89. /**
  90. * Returns true if this is a theme provided by the core platform.
  91. */
  92. boolean isSystemTheme() {
  93. return false;
  94. }
  95. }