src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java

Print this page

        

*** 42,59 **** --- 42,61 ---- import java.awt.*; import java.awt.image.*; import java.security.AccessController; import java.util.*; + import java.util.concurrent.atomic.AtomicBoolean; import javax.swing.*; import javax.swing.border.*; import javax.swing.plaf.*; import javax.swing.text.JTextComponent; import sun.awt.image.SunWritableRaster; import sun.awt.windows.ThemeReader; + import sun.awt.windows.WToolkit; import sun.security.action.GetPropertyAction; import sun.swing.CachedPainter; import static com.sun.java.swing.plaf.windows.TMSchema.*;
*** 70,79 **** --- 72,83 ---- // Singleton instance of SkinPainter private static SkinPainter skinPainter = new SkinPainter(); private static Boolean themeActive = null; + private static final AtomicBoolean xpstyleEnabled = WToolkit.getWToolkit().getXPStyleEnabled(); + private HashMap<String, Border> borderMap; private HashMap<String, Color> colorMap; private boolean flatMenus;
*** 94,110 **** * * @return the singleton instance of this class or null if XP styles * are not active or if this is not Windows XP */ static synchronized XPStyle getXP() { ! if (themeActive == null) { ! Toolkit toolkit = Toolkit.getDefaultToolkit(); ! themeActive = ! (Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive"); ! if (themeActive == null) { ! themeActive = Boolean.FALSE; } if (themeActive.booleanValue()) { GetPropertyAction propertyAction = new GetPropertyAction("swing.noxp"); if (AccessController.doPrivileged(propertyAction) == null && ThemeReader.isThemed() && --- 98,113 ---- * * @return the singleton instance of this class or null if XP styles * are not active or if this is not Windows XP */ static synchronized XPStyle getXP() { ! if (themeActive != null && themeActive.booleanValue() != xpstyleEnabled.get()) { ! // JDK-8039383: theme changed, schedule updateAllUIs() ! DesktopProperty.scheduleUpdateUI(); } + if (themeActive == null) { + themeActive = Boolean.valueOf(xpstyleEnabled.get()); if (themeActive.booleanValue()) { GetPropertyAction propertyAction = new GetPropertyAction("swing.noxp"); if (AccessController.doPrivileged(propertyAction) == null && ThemeReader.isThemed() &&
*** 178,190 **** * * This is currently only used by WindowsProgressBarUI and the value * should probably be cached there instead of here. */ Dimension getDimension(Component c, Part part, State state, Prop prop) { ! return ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); } /** Get a named <code>Point</code> (e.g. a location or an offset) value * from the current style * --- 181,194 ---- * * This is currently only used by WindowsProgressBarUI and the value * should probably be cached there instead of here. */ Dimension getDimension(Component c, Part part, State state, Prop prop) { ! Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); + return (d != null) ? d : new Dimension(); } /** Get a named <code>Point</code> (e.g. a location or an offset) value * from the current style *
*** 197,211 **** */ Point getPoint(Component c, Part part, State state, Prop prop) { Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); ! if (d != null) { ! return new Point(d.width, d.height); ! } else { ! return null; ! } } /** Get a named <code>Insets</code> value from the current style * * @param key a <code>String</code> --- 201,211 ---- */ Point getPoint(Component c, Part part, State state, Prop prop) { Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); ! return (d != null) ? new Point(d.width, d.height) : new Point(); } /** Get a named <code>Insets</code> value from the current style * * @param key a <code>String</code>
*** 215,227 **** * This is currently only used to create borders and by * WindowsInternalFrameTitlePane for painting title foregound. * The return value is already cached in those places. */ Insets getMargin(Component c, Part part, State state, Prop prop) { ! return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); } /** Get a named <code>Color</code> value from the current style * --- 215,228 ---- * This is currently only used to create borders and by * WindowsInternalFrameTitlePane for painting title foregound. * The return value is already cached in those places. */ Insets getMargin(Component c, Part part, State state, Prop prop) { ! Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } /** Get a named <code>Color</code> value from the current style *
*** 507,537 **** * bounding rectangles. */ int boundingWidth = 100; int boundingHeight = 100; ! return ThemeReader.getThemeBackgroundContentMargins( part.getControlName(null), part.getValue(), 0, boundingWidth, boundingHeight); } private int getWidth(State state) { if (size == null) { size = getPartSize(part, state); } ! return size.width; } int getWidth() { return getWidth((state != null) ? state : State.NORMAL); } private int getHeight(State state) { if (size == null) { size = getPartSize(part, state); } ! return size.height; } int getHeight() { return getHeight((state != null) ? state : State.NORMAL); } --- 508,539 ---- * bounding rectangles. */ int boundingWidth = 100; int boundingHeight = 100; ! Insets insets = ThemeReader.getThemeBackgroundContentMargins( part.getControlName(null), part.getValue(), 0, boundingWidth, boundingHeight); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } private int getWidth(State state) { if (size == null) { size = getPartSize(part, state); } ! return (size != null) ? size.width : 0; } int getWidth() { return getWidth((state != null) ? state : State.NORMAL); } private int getHeight(State state) { if (size == null) { size = getPartSize(part, state); } ! return (size != null) ? size.height : 0; } int getHeight() { return getHeight((state != null) ? state : State.NORMAL); }