0N/A/*
2362N/A * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing.plaf.metal;
0N/A
0N/Aimport javax.swing.plaf.*;
0N/Aimport javax.swing.*;
0N/A
0N/A/**
0N/A * {@code MetalTheme} provides the color palette and fonts used by
0N/A * the Java Look and Feel.
0N/A * <p>
0N/A * {@code MetalTheme} is abstract, see {@code DefaultMetalTheme} and
0N/A * {@code OceanTheme} for concrete implementations.
0N/A * <p>
0N/A * {@code MetalLookAndFeel} maintains the current theme that the
0N/A * the {@code ComponentUI} implementations for metal use. Refer to
0N/A * {@link MetalLookAndFeel#setCurrentTheme
0N/A * MetalLookAndFeel.setCurrentTheme(MetalTheme)} for details on changing
0N/A * the current theme.
0N/A * <p>
0N/A * {@code MetalTheme} provides a number of public methods for getting
0N/A * colors. These methods are implemented in terms of a
0N/A * handful of protected abstract methods. A subclass need only override
0N/A * the protected abstract methods ({@code getPrimary1},
0N/A * {@code getPrimary2}, {@code getPrimary3}, {@code getSecondary1},
0N/A * {@code getSecondary2}, and {@code getSecondary3}); although a subclass
0N/A * may override the other public methods for more control over the set of
0N/A * colors that are used.
0N/A * <p>
0N/A * Concrete implementations of {@code MetalTheme} must return {@code non-null}
0N/A * values from all methods. While the behavior of returning {@code null} is
0N/A * not specified, returning {@code null} will result in incorrect behavior.
0N/A * <p>
0N/A * It is strongly recommended that subclasses return completely opaque colors.
0N/A * To do otherwise may result in rendering problems, such as visual garbage.
0N/A *
0N/A * @see DefaultMetalTheme
0N/A * @see OceanTheme
0N/A * @see MetalLookAndFeel#setCurrentTheme
0N/A *
0N/A * @author Steve Wilson
0N/A */
0N/Apublic abstract class MetalTheme {
0N/A
0N/A // Contants identifying the various Fonts that are Theme can support
0N/A static final int CONTROL_TEXT_FONT = 0;
0N/A static final int SYSTEM_TEXT_FONT = 1;
0N/A static final int USER_TEXT_FONT = 2;
0N/A static final int MENU_TEXT_FONT = 3;
0N/A static final int WINDOW_TITLE_FONT = 4;
0N/A static final int SUB_TEXT_FONT = 5;
0N/A
0N/A static ColorUIResource white = new ColorUIResource( 255, 255, 255 );
0N/A private static ColorUIResource black = new ColorUIResource( 0, 0, 0 );
0N/A
0N/A /**
0N/A * Returns the name of this theme.
0N/A *
0N/A * @return the name of this theme
0N/A */
0N/A public abstract String getName();
0N/A
0N/A /**
0N/A * Returns the primary 1 color.
0N/A *
0N/A * @return the primary 1 color
0N/A */
0N/A protected abstract ColorUIResource getPrimary1(); // these are blue in Metal Default Theme
0N/A
0N/A /**
0N/A * Returns the primary 2 color.
0N/A *
0N/A * @return the primary 2 color
0N/A */
0N/A protected abstract ColorUIResource getPrimary2();
0N/A
0N/A /**
0N/A * Returns the primary 3 color.
0N/A *
0N/A * @return the primary 3 color
0N/A */
0N/A protected abstract ColorUIResource getPrimary3();
0N/A
0N/A /**
0N/A * Returns the secondary 1 color.
0N/A *
0N/A * @return the secondary 1 color
0N/A */
0N/A protected abstract ColorUIResource getSecondary1(); // these are gray in Metal Default Theme
0N/A
0N/A /**
0N/A * Returns the secondary 2 color.
0N/A *
0N/A * @return the secondary 2 color
0N/A */
0N/A protected abstract ColorUIResource getSecondary2();
0N/A
0N/A /**
0N/A * Returns the secondary 3 color.
0N/A *
0N/A * @return the secondary 3 color
0N/A */
0N/A protected abstract ColorUIResource getSecondary3();
0N/A
0N/A /**
0N/A * Returns the control text font.
0N/A *
0N/A * @return the control text font
0N/A */
0N/A public abstract FontUIResource getControlTextFont();
0N/A
0N/A /**
0N/A * Returns the system text font.
0N/A *
0N/A * @return the system text font
0N/A */
0N/A public abstract FontUIResource getSystemTextFont();
0N/A
0N/A /**
0N/A * Returns the user text font.
0N/A *
0N/A * @return the user text font
0N/A */
0N/A public abstract FontUIResource getUserTextFont();
0N/A
0N/A /**
0N/A * Returns the menu text font.
0N/A *
0N/A * @return the menu text font
0N/A */
0N/A public abstract FontUIResource getMenuTextFont();
0N/A
0N/A /**
0N/A * Returns the window title font.
0N/A *
0N/A * @return the window title font
0N/A */
0N/A public abstract FontUIResource getWindowTitleFont();
0N/A
0N/A /**
0N/A * Returns the sub-text font.
0N/A *
0N/A * @return the sub-text font
0N/A */
0N/A public abstract FontUIResource getSubTextFont();
0N/A
0N/A /**
0N/A * Returns the white color. This returns opaque white
0N/A * ({@code 0xFFFFFFFF}).
0N/A *
0N/A * @return the white color
0N/A */
0N/A protected ColorUIResource getWhite() { return white; }
0N/A
0N/A /**
0N/A * Returns the black color. This returns opaque black
0N/A * ({@code 0xFF000000}).
0N/A *
0N/A * @return the black color
0N/A */
0N/A protected ColorUIResource getBlack() { return black; }
0N/A
0N/A /**
0N/A * Returns the focus color. This returns the value of
0N/A * {@code getPrimary2()}.
0N/A *
0N/A * @return the focus color
0N/A */
0N/A public ColorUIResource getFocusColor() { return getPrimary2(); }
0N/A
0N/A /**
0N/A * Returns the desktop color. This returns the value of
0N/A * {@code getPrimary2()}.
0N/A *
0N/A * @return the desktop color
0N/A */
0N/A public ColorUIResource getDesktopColor() { return getPrimary2(); }
0N/A
0N/A /**
0N/A * Returns the control color. This returns the value of
0N/A * {@code getSecondary3()}.
0N/A *
0N/A * @return the control color
0N/A */
0N/A public ColorUIResource getControl() { return getSecondary3(); }
0N/A
0N/A /**
0N/A * Returns the control shadow color. This returns
0N/A * the value of {@code getSecondary2()}.
0N/A *
0N/A * @return the control shadow color
0N/A */
0N/A public ColorUIResource getControlShadow() { return getSecondary2(); }
0N/A
0N/A /**
0N/A * Returns the control dark shadow color. This returns
0N/A * the value of {@code getSecondary1()}.
0N/A *
0N/A * @return the control dark shadow color
0N/A */
0N/A public ColorUIResource getControlDarkShadow() { return getSecondary1(); }
0N/A
0N/A /**
0N/A * Returns the control info color. This returns
0N/A * the value of {@code getBlack()}.
0N/A *
0N/A * @return the control info color
0N/A */
0N/A public ColorUIResource getControlInfo() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the control highlight color. This returns
0N/A * the value of {@code getWhite()}.
0N/A *
0N/A * @return the control highlight color
0N/A */
0N/A public ColorUIResource getControlHighlight() { return getWhite(); }
0N/A
0N/A /**
0N/A * Returns the control disabled color. This returns
0N/A * the value of {@code getSecondary2()}.
0N/A *
0N/A * @return the control disabled color
0N/A */
0N/A public ColorUIResource getControlDisabled() { return getSecondary2(); }
0N/A
0N/A /**
0N/A * Returns the primary control color. This returns
0N/A * the value of {@code getPrimary3()}.
0N/A *
0N/A * @return the primary control color
0N/A */
0N/A public ColorUIResource getPrimaryControl() { return getPrimary3(); }
0N/A
0N/A /**
0N/A * Returns the primary control shadow color. This returns
0N/A * the value of {@code getPrimary2()}.
0N/A *
0N/A * @return the primary control shadow color
0N/A */
0N/A public ColorUIResource getPrimaryControlShadow() { return getPrimary2(); }
0N/A /**
0N/A * Returns the primary control dark shadow color. This
0N/A * returns the value of {@code getPrimary1()}.
0N/A *
0N/A * @return the primary control dark shadow color
0N/A */
0N/A public ColorUIResource getPrimaryControlDarkShadow() { return getPrimary1(); }
0N/A
0N/A /**
0N/A * Returns the primary control info color. This
0N/A * returns the value of {@code getBlack()}.
0N/A *
0N/A * @return the primary control info color
0N/A */
0N/A public ColorUIResource getPrimaryControlInfo() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the primary control highlight color. This
0N/A * returns the value of {@code getWhite()}.
0N/A *
0N/A * @return the primary control highlight color
0N/A */
0N/A public ColorUIResource getPrimaryControlHighlight() { return getWhite(); }
0N/A
0N/A /**
0N/A * Returns the system text color. This returns the value of
0N/A * {@code getBlack()}.
0N/A *
0N/A * @return the system text color
0N/A */
0N/A public ColorUIResource getSystemTextColor() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the control text color. This returns the value of
0N/A * {@code getControlInfo()}.
0N/A *
0N/A * @return the control text color
0N/A */
0N/A public ColorUIResource getControlTextColor() { return getControlInfo(); }
0N/A
0N/A /**
0N/A * Returns the inactive control text color. This returns the value of
0N/A * {@code getControlDisabled()}.
0N/A *
0N/A * @return the inactive control text color
0N/A */
0N/A public ColorUIResource getInactiveControlTextColor() { return getControlDisabled(); }
0N/A
0N/A /**
0N/A * Returns the inactive system text color. This returns the value of
0N/A * {@code getSecondary2()}.
0N/A *
0N/A * @return the inactive system text color
0N/A */
0N/A public ColorUIResource getInactiveSystemTextColor() { return getSecondary2(); }
0N/A
0N/A /**
0N/A * Returns the user text color. This returns the value of
0N/A * {@code getBlack()}.
0N/A *
0N/A * @return the user text color
0N/A */
0N/A public ColorUIResource getUserTextColor() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the text highlight color. This returns the value of
0N/A * {@code getPrimary3()}.
0N/A *
0N/A * @return the text highlight color
0N/A */
0N/A public ColorUIResource getTextHighlightColor() { return getPrimary3(); }
0N/A
0N/A /**
0N/A * Returns the highlighted text color. This returns the value of
0N/A * {@code getControlTextColor()}.
0N/A *
0N/A * @return the highlighted text color
0N/A */
0N/A public ColorUIResource getHighlightedTextColor() { return getControlTextColor(); }
0N/A
0N/A /**
0N/A * Returns the window background color. This returns the value of
0N/A * {@code getWhite()}.
0N/A *
0N/A * @return the window background color
0N/A */
0N/A public ColorUIResource getWindowBackground() { return getWhite(); }
0N/A
0N/A /**
0N/A * Returns the window title background color. This returns the value of
0N/A * {@code getPrimary3()}.
0N/A *
0N/A * @return the window title background color
0N/A */
0N/A public ColorUIResource getWindowTitleBackground() { return getPrimary3(); }
0N/A
0N/A /**
0N/A * Returns the window title foreground color. This returns the value of
0N/A * {@code getBlack()}.
0N/A *
0N/A * @return the window title foreground color
0N/A */
0N/A public ColorUIResource getWindowTitleForeground() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the window title inactive background color. This
0N/A * returns the value of {@code getSecondary3()}.
0N/A *
0N/A * @return the window title inactive background color
0N/A */
0N/A public ColorUIResource getWindowTitleInactiveBackground() { return getSecondary3(); }
0N/A
0N/A /**
0N/A * Returns the window title inactive foreground color. This
0N/A * returns the value of {@code getBlack()}.
0N/A *
0N/A * @return the window title inactive foreground color
0N/A */
0N/A public ColorUIResource getWindowTitleInactiveForeground() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the menu background color. This
0N/A * returns the value of {@code getSecondary3()}.
0N/A *
0N/A * @return the menu background color
0N/A */
0N/A public ColorUIResource getMenuBackground() { return getSecondary3(); }
0N/A
0N/A /**
0N/A * Returns the menu foreground color. This
0N/A * returns the value of {@code getBlack()}.
0N/A *
0N/A * @return the menu foreground color
0N/A */
0N/A public ColorUIResource getMenuForeground() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the menu selected background color. This
0N/A * returns the value of {@code getPrimary2()}.
0N/A *
0N/A * @return the menu selected background color
0N/A */
0N/A public ColorUIResource getMenuSelectedBackground() { return getPrimary2(); }
0N/A
0N/A /**
0N/A * Returns the menu selected foreground color. This
0N/A * returns the value of {@code getBlack()}.
0N/A *
0N/A * @return the menu selected foreground color
0N/A */
0N/A public ColorUIResource getMenuSelectedForeground() { return getBlack(); }
0N/A
0N/A /**
0N/A * Returns the menu disabled foreground color. This
0N/A * returns the value of {@code getSecondary2()}.
0N/A *
0N/A * @return the menu disabled foreground color
0N/A */
0N/A public ColorUIResource getMenuDisabledForeground() { return getSecondary2(); }
0N/A
0N/A /**
0N/A * Returns the separator background color. This
0N/A * returns the value of {@code getWhite()}.
0N/A *
0N/A * @return the separator background color
0N/A */
0N/A public ColorUIResource getSeparatorBackground() { return getWhite(); }
0N/A
0N/A /**
0N/A * Returns the separator foreground color. This
0N/A * returns the value of {@code getPrimary1()}.
0N/A *
0N/A * @return the separator foreground color
0N/A */
0N/A public ColorUIResource getSeparatorForeground() { return getPrimary1(); }
0N/A
0N/A /**
0N/A * Returns the accelerator foreground color. This
0N/A * returns the value of {@code getPrimary1()}.
0N/A *
0N/A * @return the accelerator foreground color
0N/A */
0N/A public ColorUIResource getAcceleratorForeground() { return getPrimary1(); }
0N/A
0N/A /**
0N/A * Returns the accelerator selected foreground color. This
0N/A * returns the value of {@code getBlack()}.
0N/A *
0N/A * @return the accelerator selected foreground color
0N/A */
0N/A public ColorUIResource getAcceleratorSelectedForeground() { return getBlack(); }
0N/A
0N/A /**
0N/A * Adds values specific to this theme to the defaults table. This method
0N/A * is invoked when the look and feel defaults are obtained from
0N/A * {@code MetalLookAndFeel}.
0N/A * <p>
0N/A * This implementation does nothing; it is provided for subclasses
0N/A * that wish to customize the defaults table.
0N/A *
0N/A * @param table the {@code UIDefaults} to add the values to
0N/A *
0N/A * @see MetalLookAndFeel#getDefaults
0N/A */
0N/A public void addCustomEntriesToTable(UIDefaults table) {}
0N/A
0N/A /**
0N/A * This is invoked when a MetalLookAndFeel is installed and about to
0N/A * start using this theme. When we can add API this should be nuked
0N/A * in favor of DefaultMetalTheme overriding addCustomEntriesToTable.
0N/A */
0N/A void install() {
0N/A }
0N/A
0N/A /**
0N/A * Returns true if this is a theme provided by the core platform.
0N/A */
0N/A boolean isSystemTheme() {
0N/A return false;
0N/A }
0N/A}