src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java
Print this page
*** 113,123 ****
xp = new XPStyle();
}
}
}
! return xp;
}
static boolean isVista() {
XPStyle xp = XPStyle.getXP();
return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
--- 113,123 ----
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
*
--- 178,191 ----
*
* 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>
--- 198,208 ----
*/
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
*
--- 212,225 ----
* 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);
}
--- 505,536 ----
* 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 ****
--- 583,595 ----
* @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 ****
--- 611,623 ----
* @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
*
*** 627,636 ****
--- 632,644 ----
* @param borderFill should test if the component uses a border fill
and skip painting if it is
*/
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
boolean borderFill) {
+ if (XPStyle.getXP() == null) {
+ return;
+ }
if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
state, Prop.BGTYPE))) {
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));
--- 690,700 ----
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) {
--- 715,734 ----
}
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) {