XPStylepublic class XPStyle extends Object Implements Windows XP Styles for the Windows Look and Feel. |
Fields Summary |
---|
private static XPStyle | xp | private static SkinPainter | skinPainter | private static Boolean | themeActive | private HashMap | borderMap | private HashMap | colorMap | private boolean | flatMenus |
Constructors Summary |
---|
private XPStyle()
flatMenus = getSysBoolean(Prop.FLATMENUS);
colorMap = new HashMap<String, Color>();
borderMap = new HashMap<String, Border>();
// Note: All further access to the maps must be synchronized
|
Methods Summary |
---|
private boolean | getBoolean(java.awt.Component c, Part part, State state, Prop prop)
return ThemeReader.getBoolean(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
| synchronized javax.swing.border.Border | getBorder(java.awt.Component c, Part part)Get a named Border value from the current style
if (part == Part.MENU) {
// Special case because XP has no skin for menus
if (flatMenus) {
// TODO: The classic border uses this color, but we should
// create a new UI property called "PopupMenu.borderColor"
// instead.
return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"),
1);
} else {
return null; // Will cause L&F to use classic border
}
}
Skin skin = new Skin(c, part, null);
Border border = borderMap.get(skin.string);
if (border == null) {
String bgType = getTypeEnumName(c, part, null, Prop.BGTYPE);
if ("borderfill".equalsIgnoreCase(bgType)) {
int thickness = getInt(c, part, null, Prop.BORDERSIZE, 1);
Color color = getColor(skin, Prop.BORDERCOLOR, Color.black);
border = new XPFillBorder(color, thickness);
if (part == Part.CP_COMBOBOX) {
border = new XPStatefulFillBorder(color, thickness, part, Prop.BORDERCOLOR);
}
} else if ("imagefile".equalsIgnoreCase(bgType)) {
Insets m = getMargin(c, part, null, Prop.SIZINGMARGINS);
if (m != null) {
if (getBoolean(c, part, null, Prop.BORDERONLY)) {
border = new XPImageBorder(c, part);
} else if (part == Part.CP_COMBOBOX) {
border = new EmptyBorder(1, 1, 1, 1);
} else {
if(part == Part.TP_BUTTON) {
border = new XPEmptyBorder(new Insets(3,3,3,3));
} else {
border = new XPEmptyBorder(m);
}
}
}
}
if (border != null) {
borderMap.put(skin.string, border);
}
}
return border;
| synchronized java.awt.Color | getColor(com.sun.java.swing.plaf.windows.XPStyle$Skin skin, Prop prop, java.awt.Color fallback)Get a named Color value from the current style
String key = skin.toString() + "." + prop.name();
Part part = skin.part;
Color color = colorMap.get(key);
if (color == null) {
color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
State.getValue(part, skin.state),
prop.getValue());
if (color != null) {
color = new ColorUIResource(color);
colorMap.put(key, color);
}
}
return (color != null) ? color : fallback;
| java.awt.Color | getColor(java.awt.Component c, Part part, State state, Prop prop, java.awt.Color fallback)
return getColor(new Skin(c, part, state), prop, fallback);
| java.awt.Dimension | getDimension(java.awt.Component c, Part part, State state, Prop prop)Get a named Dimension value from the current style
return ThemeReader.getPosition(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
| int | getInt(java.awt.Component c, Part part, State state, Prop prop, int fallback)Get a named int value from the current style
return ThemeReader.getInt(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
| java.awt.Insets | getMargin(java.awt.Component c, Part part, State state, Prop prop)Get a named Insets value from the current style
return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
| static java.awt.Dimension | getPartSize(Part part, State state)
return ThemeReader.getPartSize(part.getControlName(null), part.getValue(),
State.getValue(part, state));
| java.awt.Point | getPoint(java.awt.Component c, Part part, State state, Prop prop)Get a named Point (e.g. a location or an offset) value
from the current style
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;
}
| synchronized com.sun.java.swing.plaf.windows.XPStyle$Skin | getSkin(java.awt.Component c, Part part)Get a Skin object from the current style
for a named part (component type)
assert isSkinDefined(c, part) : "part " + part + " is not defined";
return new Skin(c, part, null);
| java.lang.String | getString(java.awt.Component c, Part part, State state, Prop prop)Get a named String value from the current style
return getTypeEnumName(c, part, state, prop);
| private static boolean | getSysBoolean(Prop prop)
// We can use any widget name here, I guess.
return ThemeReader.getSysBoolean("window", prop.getValue());
| long | getThemeTransitionDuration(java.awt.Component c, Part part, State stateFrom, State stateTo, Prop prop)
return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
part.getValue(),
State.getValue(part, stateFrom),
State.getValue(part, stateTo),
(prop != null) ? prop.getValue() : 0);
| TypeEnum | getTypeEnum(java.awt.Component c, Part part, State state, Prop prop)
int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
return TypeEnum.getTypeEnum(prop, enumValue);
| private static java.lang.String | getTypeEnumName(java.awt.Component c, Part part, State state, Prop prop)
int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
State.getValue(part, state),
prop.getValue());
if (enumValue == -1) {
return null;
}
return TypeEnum.getTypeEnum(prop, enumValue).getName();
| static synchronized com.sun.java.swing.plaf.windows.XPStyle | getXP()Get the singleton instance of this class
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() &&
!(UIManager.getLookAndFeel()
instanceof WindowsClassicLookAndFeel)) {
xp = new XPStyle();
}
}
}
return xp;
| static synchronized void | invalidateStyle()Static method for clearing the hashmap and loading the
current XP style and theme
invalidateStyle();
xp = null;
themeActive = null;
skinPainter.flush();
| boolean | isSkinDefined(java.awt.Component c, Part part)
return (part.getValue() == 0)
|| ThemeReader.isThemePartDefined(
part.getControlName(c), part.getValue(), 0);
| static boolean | isVista()
XPStyle xp = XPStyle.getXP();
return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
|
|