use of com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory in project jdk8u_jdk by JetBrains.
the class WindowsLookAndFeel method initVistaComponentDefaults.
private void initVistaComponentDefaults(UIDefaults table) {
if (!isOnVista()) {
return;
}
/* START handling menus for Vista */
String[] menuClasses = { "MenuItem", "Menu", "CheckBoxMenuItem", "RadioButtonMenuItem" };
Object[] menuDefaults = new Object[menuClasses.length * 2];
/* all the menus need to be non opaque. */
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".opaque";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(Boolean.FALSE, oldValue);
}
table.putDefaults(menuDefaults);
/*
* acceleratorSelectionForeground color is the same as
* acceleratorForeground
*/
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".acceleratorSelectionForeground";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(table.getColor(menuClasses[i] + ".acceleratorForeground"), oldValue);
}
table.putDefaults(menuDefaults);
/* they have the same MenuItemCheckIconFactory */
VistaMenuItemCheckIconFactory menuItemCheckIconFactory = WindowsIconFactory.getMenuItemCheckIconFactory();
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".checkIconFactory";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(menuItemCheckIconFactory, oldValue);
}
table.putDefaults(menuDefaults);
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".checkIcon";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]), oldValue);
}
table.putDefaults(menuDefaults);
/* height can be even */
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".evenHeight";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue);
}
table.putDefaults(menuDefaults);
/* no margins */
InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0);
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".margin";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(insets, oldValue);
}
table.putDefaults(menuDefaults);
/* set checkIcon offset */
Integer checkIconOffsetInteger = Integer.valueOf(0);
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".checkIconOffset";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(checkIconOffsetInteger, oldValue);
}
table.putDefaults(menuDefaults);
/* set width of the gap after check icon */
Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter() + WindowsPopupMenuUI.getGutterWidth() + WindowsPopupMenuUI.getSpanAfterGutter();
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".afterCheckIconGap";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(afterCheckIconGap, oldValue);
}
table.putDefaults(menuDefaults);
/* text is started after this position */
Object minimumTextOffset = new UIDefaults.ActiveValue() {
public Object createValue(UIDefaults table) {
return VistaMenuItemCheckIconFactory.getIconWidth() + WindowsPopupMenuUI.getSpanBeforeGutter() + WindowsPopupMenuUI.getGutterWidth() + WindowsPopupMenuUI.getSpanAfterGutter();
}
};
for (int i = 0, j = 0; i < menuClasses.length; i++) {
String key = menuClasses[i] + ".minimumTextOffset";
Object oldValue = table.get(key);
menuDefaults[j++] = key;
menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue);
}
table.putDefaults(menuDefaults);
/*
* JPopupMenu has a bit of free space around menu items
*/
String POPUP_MENU_BORDER = "PopupMenu.border";
Object popupMenuBorder = new XPBorderValue(Part.MENU, new SwingLazyValue("javax.swing.plaf.basic.BasicBorders", "getInternalFrameBorder"), BorderFactory.createEmptyBorder(2, 2, 2, 2));
table.put(POPUP_MENU_BORDER, popupMenuBorder);
/* END handling menus for Vista */
/* START table handling for Vista */
table.put("Table.ascendingSortIcon", new XPValue(new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN), new SwingLazyValue("sun.swing.plaf.windows.ClassicSortArrowIcon", null, new Object[] { Boolean.TRUE })));
table.put("Table.descendingSortIcon", new XPValue(new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP), new SwingLazyValue("sun.swing.plaf.windows.ClassicSortArrowIcon", null, new Object[] { Boolean.FALSE })));
/* END table handling for Vista */
}
Aggregations