| 1 |
/* |
| 2 |
* @(#)Office2007WindowsUtils.java 7/7/2009 |
| 3 |
* |
| 4 |
* Copyright 2002 - 2009 JIDE Software Inc. All rights reserved. |
| 5 |
*/ |
| 6 |
|
| 7 |
package com.jidesoft.plaf.office2007; |
| 8 |
|
| 9 |
import com.jidesoft.icons.IconsFactory; |
| 10 |
import com.jidesoft.icons.MenuCheckIcon; |
| 11 |
import com.jidesoft.plaf.ExtWindowsDesktopProperty; |
| 12 |
import com.jidesoft.plaf.LookAndFeelFactory; |
| 13 |
import com.jidesoft.plaf.UIDefaultsLookup; |
| 14 |
import com.jidesoft.plaf.WindowsDesktopProperty; |
| 15 |
import com.jidesoft.plaf.basic.BasicPainter; |
| 16 |
import com.jidesoft.plaf.basic.Painter; |
| 17 |
import com.jidesoft.plaf.basic.ThemePainter; |
| 18 |
import com.jidesoft.plaf.office2003.Office2003WindowsUtils; |
| 19 |
import com.jidesoft.plaf.vsnet.ConvertListener; |
| 20 |
import com.jidesoft.plaf.vsnet.VsnetWindowsUtils; |
| 21 |
import com.jidesoft.swing.JideSwingUtilities; |
| 22 |
import com.jidesoft.swing.JideTabbedPane; |
| 23 |
import com.jidesoft.utils.ColorUtils; |
| 24 |
|
| 25 |
import javax.swing.*; |
| 26 |
import javax.swing.plaf.BorderUIResource; |
| 27 |
import javax.swing.plaf.ColorUIResource; |
| 28 |
import javax.swing.plaf.InsetsUIResource; |
| 29 |
import java.awt.*; |
| 30 |
|
| 31 |
/** |
| 32 |
* WindowsLookAndFeel with Office2007 extension |
| 33 |
*/ |
| 34 |
public class Office2007WindowsUtils extends VsnetWindowsUtils { |
| 35 |
|
| 36 |
/** |
| 37 |
* Initializes class defaults. |
| 38 |
* |
| 39 |
* @param table |
| 40 |
* @param withMenu |
| 41 |
*/ |
| 42 |
public static void initClassDefaults(UIDefaults table, boolean withMenu) { |
| 43 |
Office2003WindowsUtils.initClassDefaults(table, withMenu); |
| 44 |
|
| 45 |
int products = LookAndFeelFactory.getProductsUsed(); |
| 46 |
|
| 47 |
table.put("JideTabbedPaneUI", "com.jidesoft.plaf.office2007.Office2007JideTabbedPaneUI"); |
| 48 |
|
| 49 |
if ((products & PRODUCT_DOCK) != 0) { |
| 50 |
table.put("SidePaneUI", "com.jidesoft.plaf.office2007.Office2007SidePaneUI"); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Initializes class defaults. |
| 56 |
* |
| 57 |
* @param table |
| 58 |
*/ |
| 59 |
public static void initClassDefaults(UIDefaults table) { |
| 60 |
initClassDefaults(table, true); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Initializes components defaults. |
| 65 |
* |
| 66 |
* @param table |
| 67 |
*/ |
| 68 |
public static void initComponentDefaults(UIDefaults table) { |
| 69 |
Toolkit toolkit = Toolkit.getDefaultToolkit(); |
| 70 |
|
| 71 |
WindowsDesktopProperty defaultTextColor = new WindowsDesktopProperty("win.button.textColor", table.get("controlText"), toolkit); |
| 72 |
|
| 73 |
WindowsDesktopProperty defaultBackgroundColor = new WindowsDesktopProperty("win.3d.backgroundColor", table.get("control"), toolkit); |
| 74 |
|
| 75 |
WindowsDesktopProperty defaultLightColor = new WindowsDesktopProperty("win.3d.lightColor", table.get("controlHighlight"), toolkit); |
| 76 |
WindowsDesktopProperty defaultHighlightColor = new WindowsDesktopProperty("win.3d.highlightColor", table.get("controlLtHighlight"), toolkit); |
| 77 |
WindowsDesktopProperty defaultShadowColor = new WindowsDesktopProperty("win.3d.shadowColor", table.get("controlShadow"), toolkit); |
| 78 |
WindowsDesktopProperty defaultDarkShadowColor = new WindowsDesktopProperty("win.3d.darkShadowColor", table.get("controlDkShadow"), toolkit); |
| 79 |
|
| 80 |
Color defaultFormBackground = new ColorUIResource(0xBFDBFF); |
| 81 |
|
| 82 |
Object toolbarFont = JideSwingUtilities.getMenuFont(toolkit, table); |
| 83 |
Object boldFont = JideSwingUtilities.getBoldFont(toolkit, table); |
| 84 |
|
| 85 |
Painter gripperPainter = new Painter() { |
| 86 |
public void paint(JComponent c, Graphics g, Rectangle rect, int orientation, int state) { |
| 87 |
Object p = UIDefaultsLookup.get("Theme.painter"); |
| 88 |
if (p instanceof ThemePainter) { |
| 89 |
((ThemePainter) p).paintGripper(c, g, rect, orientation, state); |
| 90 |
} |
| 91 |
else { |
| 92 |
BasicPainter.getInstance().paintGripper(c, g, rect, orientation, state); |
| 93 |
} |
| 94 |
} |
| 95 |
}; |
| 96 |
|
| 97 |
Object uiDefaults[] = new Object[]{ |
| 98 |
"MenuItem.checkIcon", new MenuCheckIcon(IconsFactory.getImageIcon(Office2007Painter.class, "icons/menu_checkbox.png")), |
| 99 |
"MenuItem.shadowColor", new ColorUIResource(0xE9EEEE), |
| 100 |
|
| 101 |
"PopupMenuSeparator.foreground", new ColorUIResource(0xC5C5C5), |
| 102 |
|
| 103 |
"JideTabbedPane.gripperPainter", gripperPainter, |
| 104 |
"JideSplitPaneDivider.gripperPainter", gripperPainter, |
| 105 |
// "Gallery.downIcon", IconsFactory.getImageIcon(Office2007Painter.class, "icons/gallery_down_button.png"), |
| 106 |
// "Gallery.downIconR", IconsFactory.getImageIcon(Office2007Painter.class, "icons/gallery_down_button_rollover.png"), |
| 107 |
|
| 108 |
"JideTabbedPane.defaultTabShape", JideTabbedPane.SHAPE_OFFICE2003, |
| 109 |
"JideTabbedPane.defaultTabColorTheme", JideTabbedPane.COLOR_THEME_OFFICE2003, |
| 110 |
"JideTabbedPane.contentBorderInsets", new InsetsUIResource(3, 3, 3, 3), |
| 111 |
"JideTabbedPane.background", defaultFormBackground, |
| 112 |
|
| 113 |
"JideButton.margin.vertical", new InsetsUIResource(2, 5, 1, 5), |
| 114 |
"JideButton.margin", new InsetsUIResource(3, 3, 3, 4), |
| 115 |
"JideButton.paintDefaultBorder", false, |
| 116 |
|
| 117 |
"JideSplitButton.margin.vertical", new InsetsUIResource(2, 5, 1, 5), |
| 118 |
"JideSplitButton.margin", new InsetsUIResource(3, 3, 3, 4), |
| 119 |
"JideSplitButton.nonActiveRolloverAlpha", 40, |
| 120 |
"JideSplitButton.textIconGap", 4, |
| 121 |
// "JideSplitButton.foreground", new Color(0x3e6aaa), |
| 122 |
// "JideButton.foreground", new Color(0x3e6aaa), |
| 123 |
// "JideLabel.foreground", new Color(0x3e6aaa), |
| 124 |
"JideLabel.background", table.get("Label.background"), |
| 125 |
"JideLabel.font", table.get("Label.font"), |
| 126 |
|
| 127 |
"Gripper.painter", gripperPainter, |
| 128 |
"Gripper.foreground", new ColorUIResource(0x6593cf), |
| 129 |
"Gripper.light", new ColorUIResource(0xFFFFFF), |
| 130 |
}; |
| 131 |
table.putDefaults(uiDefaults); |
| 132 |
|
| 133 |
int products = LookAndFeelFactory.getProductsUsed(); |
| 134 |
|
| 135 |
if ((products & PRODUCT_COMPONENTS) != 0) { |
| 136 |
ImageIcon collapsiblePaneImage = IconsFactory.getImageIcon(Office2007WindowsUtils.class, "icons/collapsible_pane_vista.gif"); // 12 x 12 x 2 |
| 137 |
final int collapsiblePaneSize = 12; |
| 138 |
|
| 139 |
uiDefaults = new Object[]{ |
| 140 |
"StatusBar.childrenOpaque", Boolean.FALSE, |
| 141 |
"StatusBar.border", BorderFactory.createEmptyBorder(2, 0, 2, 0), |
| 142 |
"MemoryStatusBarItem.fillColor", new ColorUIResource(0xfeba4f), |
| 143 |
|
| 144 |
"CollapsiblePane.downIcon", IconsFactory.getIcon(null, collapsiblePaneImage, 0, 0, collapsiblePaneSize, collapsiblePaneSize), |
| 145 |
"CollapsiblePane.upIcon", IconsFactory.getIcon(null, collapsiblePaneImage, 0, collapsiblePaneSize, collapsiblePaneSize, collapsiblePaneSize), |
| 146 |
"CollapsiblePanes.backgroundLt", new ColorUIResource(0xbfdbff), |
| 147 |
"CollapsiblePanes.backgroundDk", new ColorUIResource(0xbfdbff), |
| 148 |
}; |
| 149 |
table.putDefaults(uiDefaults); |
| 150 |
} |
| 151 |
|
| 152 |
if ((products & PRODUCT_DOCK) != 0) { |
| 153 |
ImageIcon titleButtonImage = IconsFactory.getImageIcon(Office2007WindowsUtils.class, "icons/title_buttons_office2007.gif"); // 10 x 10 x 8 |
| 154 |
final int titleButtonSize = 10; |
| 155 |
|
| 156 |
uiDefaults = new Object[]{ |
| 157 |
"ContentContainer.background", defaultFormBackground, |
| 158 |
"SidePane.background", defaultFormBackground, |
| 159 |
|
| 160 |
"DockableFrame.activeTitleBackground", new ColorUIResource(0xC0D9F0), |
| 161 |
|
| 162 |
"DockableFrameTitlePane.gripperPainter", gripperPainter, |
| 163 |
|
| 164 |
"DockableFrameTitlePane.hideIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 0, titleButtonSize, titleButtonSize), |
| 165 |
"DockableFrameTitlePane.unfloatIcon", IconsFactory.getIcon(null, titleButtonImage, 0, titleButtonSize, titleButtonSize, titleButtonSize), |
| 166 |
"DockableFrameTitlePane.floatIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 2 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 167 |
"DockableFrameTitlePane.autohideIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 3 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 168 |
"DockableFrameTitlePane.stopAutohideIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 4 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 169 |
"DockableFrameTitlePane.hideAutohideIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 5 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 170 |
"DockableFrameTitlePane.maximizeIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 6 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 171 |
"DockableFrameTitlePane.restoreIcon", IconsFactory.getIcon(null, titleButtonImage, 0, 7 * titleButtonSize, titleButtonSize, titleButtonSize), |
| 172 |
|
| 173 |
"DockableFrameTitlePane.backgroundLt", new ColorUIResource(ColorUtils.getDerivedColor(new Color(0xBFDBFF), .55f)), |
| 174 |
"DockableFrameTitlePane.backgroundDk", new ColorUIResource(ColorUtils.getDerivedColor(new Color(0xBFDBFF), .45f)), |
| 175 |
"DockableFrameTitlePane.activeBackgroundLt", new ColorUIResource(ColorUtils.getDerivedColor(new Color(0xFAD8A0), .55f)), |
| 176 |
"DockableFrameTitlePane.activeBackgroundDk", new ColorUIResource(ColorUtils.getDerivedColor(new Color(0xFAD8A0), .45f)), |
| 177 |
|
| 178 |
"DockableFrameTitlePane.margin", new InsetsUIResource(1, 6, 0, 6), // gap |
| 179 |
|
| 180 |
"DockableFrameTitlePane.buttonGap", 2, // gap between buttons |
| 181 |
}; |
| 182 |
table.putDefaults(uiDefaults); |
| 183 |
} |
| 184 |
if ((products & PRODUCT_ACTION) != 0) { |
| 185 |
uiDefaults = new Object[]{ |
| 186 |
"Chevron.alwaysVisible", Boolean.TRUE, |
| 187 |
}; |
| 188 |
table.putDefaults(uiDefaults); |
| 189 |
} |
| 190 |
|
| 191 |
if ((products & PRODUCT_GRIDS) != 0) { |
| 192 |
uiDefaults = new Object[]{ |
| 193 |
}; |
| 194 |
table.putDefaults(uiDefaults); |
| 195 |
} |
| 196 |
|
| 197 |
UIDefaultsLookup.put(table, "Theme.painter", Office2007Painter.getInstance()); |
| 198 |
|
| 199 |
// since it used BasicPainter, make sure it is after Theme.Painter is set first. |
| 200 |
Object popupMenuBorder = new ExtWindowsDesktopProperty(new String[]{"null"}, new Object[]{((ThemePainter) UIDefaultsLookup.get("Theme.painter")).getMenuItemBorderColor()}, toolkit, new ConvertListener() { |
| 201 |
public Object convert(Object[] obj) { |
| 202 |
return new BorderUIResource(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder((Color) obj[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); |
| 203 |
} |
| 204 |
}); |
| 205 |
table.put("PopupMenu.border", popupMenuBorder); |
| 206 |
} |
| 207 |
} |