src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java
Print this page
*** 50,59 ****
--- 50,60 ----
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.*;
*** 97,107 ****
*/
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 =
--- 98,108 ----
*/
static synchronized XPStyle getXP() {
if (themeActive == null) {
Toolkit toolkit = Toolkit.getDefaultToolkit();
themeActive =
! (Boolean)toolkit.getDesktopProperty(WToolkit.XPSTYLE_THEME_ACTIVE);
if (themeActive == null) {
themeActive = Boolean.FALSE;
}
if (themeActive.booleanValue()) {
GetPropertyAction propertyAction =
*** 113,123 ****
xp = new XPStyle();
}
}
}
! return xp;
}
static boolean isVista() {
XPStyle xp = XPStyle.getXP();
return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
--- 114,124 ----
xp = new XPStyle();
}
}
}
! return ThemeReader.isXPStyleEnabled() ? xp : null;
}
static boolean isVista() {
XPStyle xp = XPStyle.getXP();
return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
*** 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
*
--- 179,192 ----
*
* 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>
--- 199,209 ----
*/
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
*
--- 213,226 ----
* 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);
}
--- 506,537 ----
* 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);
}
*** 584,593 ****
--- 584,596 ----
* @param dh the height of the area to fill, may cause
* the image to be stretched or tiled
* @param state which state to paint
*/
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
if (ThemeReader.isGetThemeTransitionDurationDefined()
&& component instanceof JComponent
&& SwingUtilities.getAncestorOfClass(CellRendererPane.class,
component) == null) {
AnimationController.paintSkin((JComponent) component, this,
*** 609,618 ****
--- 612,624 ----
* @param dh the height of the area to fill, may cause
* the image to be stretched or tiled
* @param state which state to paint
*/
void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
}
/** Paint a skin at a defined position and size
*
*** 628,638 ****
and skip painting if it is
*/
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
boolean borderFill) {
if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
! state, Prop.BGTYPE))) {
return;
}
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
}
}
--- 634,644 ----
and skip painting if it is
*/
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
boolean borderFill) {
if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
! state, Prop.BGTYPE)) && XPStyle.getXP() == null) {
return;
}
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
}
}
*** 682,692 ****
static class GlyphButton extends JButton {
private Skin skin;
public GlyphButton(Component parent, Part part) {
XPStyle xp = getXP();
! skin = xp.getSkin(parent, part);
setBorder(null);
setContentAreaFilled(false);
setMinimumSize(new Dimension(5, 5));
setPreferredSize(new Dimension(16, 16));
setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
--- 688,698 ----
static class GlyphButton extends JButton {
private Skin skin;
public GlyphButton(Component parent, Part part) {
XPStyle xp = getXP();
! skin = xp != null ? xp.getSkin(parent, part) : null;
setBorder(null);
setContentAreaFilled(false);
setMinimumSize(new Dimension(5, 5));
setPreferredSize(new Dimension(16, 16));
setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
*** 707,723 ****
}
return state;
}
public void paintComponent(Graphics g) {
Dimension d = getSize();
skin.paintSkin(g, 0, 0, d.width, d.height, getState());
}
public void setPart(Component parent, Part part) {
XPStyle xp = getXP();
! skin = xp.getSkin(parent, part);
revalidate();
repaint();
}
protected void paintBorder(Graphics g) {
--- 713,732 ----
}
return state;
}
public void paintComponent(Graphics g) {
+ if (XPStyle.getXP() == null || skin == null) {
+ return;
+ }
Dimension d = getSize();
skin.paintSkin(g, 0, 0, d.width, d.height, getState());
}
public void setPart(Component parent, Part part) {
XPStyle xp = getXP();
! skin = xp != null ? xp.getSkin(parent, part) : null;
revalidate();
repaint();
}
protected void paintBorder(Graphics g) {