001: /**
002: * @(#)Office2003WindowsUtils.java
003: *
004: * Copyright 2002 - 2004 JIDE Software. All rights reserved.
005: */package com.jidesoft.plaf.office2003;
006:
007: import com.jidesoft.icons.IconsFactory;
008: import com.jidesoft.plaf.ExtWindowsDesktopProperty;
009: import com.jidesoft.plaf.LookAndFeelFactory;
010: import com.jidesoft.plaf.UIDefaultsLookup;
011: import com.jidesoft.plaf.WindowsDesktopProperty;
012: import com.jidesoft.plaf.basic.BasicPainter;
013: import com.jidesoft.plaf.basic.Painter;
014: import com.jidesoft.plaf.vsnet.ConvertListener;
015: import com.jidesoft.plaf.vsnet.HeaderCellBorder;
016: import com.jidesoft.plaf.vsnet.ResizeFrameBorder;
017: import com.jidesoft.plaf.vsnet.VsnetWindowsUtils;
018: import com.jidesoft.plaf.xerto.SlidingFrameBorder;
019: import com.jidesoft.plaf.xerto.StatusBarBorder;
020: import com.jidesoft.swing.JideSwingUtilities;
021: import com.jidesoft.swing.JideTabbedPane;
022: import com.jidesoft.utils.SecurityUtils;
023:
024: import javax.swing.*;
025: import javax.swing.plaf.BorderUIResource;
026: import javax.swing.plaf.InsetsUIResource;
027: import java.awt.*;
028:
029: /**
030: * WindowsLookAndFeel with Office2003 extension
031: */
032: public class Office2003WindowsUtils extends VsnetWindowsUtils {
033:
034: /**
035: * Initializes class defaults.
036: *
037: * @param table
038: * @param withMenu
039: */
040: public static void initClassDefaults(UIDefaults table,
041: boolean withMenu) {
042: if (withMenu) {
043: VsnetWindowsUtils.initClassDefaultsWithMenu(table);
044: table
045: .put("PopupMenuSeparatorUI",
046: "com.jidesoft.plaf.office2003.Office2003PopupMenuSeparatorUI");
047: } else {
048: VsnetWindowsUtils.initClassDefaults(table);
049: }
050:
051: int products = LookAndFeelFactory.getProductsUsed();
052:
053: table
054: .put("JideTabbedPaneUI",
055: "com.jidesoft.plaf.office2003.Office2003JideTabbedPaneUI");
056: table.put("HeaderBoxUI",
057: "com.jidesoft.plaf.office2003.Office2003HeaderBoxUI");
058: table.put("RangeSliderUI",
059: "com.jidesoft.plaf.office2003.Office2003RangeSliderUI");
060: table.put("GripperUI",
061: "com.jidesoft.plaf.office2003.Office2003GripperUI");
062:
063: if ((products & PRODUCT_DOCK) != 0) {
064: table
065: .put("SidePaneUI",
066: "com.jidesoft.plaf.office2003.Office2003SidePaneUI");
067: }
068:
069: if ((products & PRODUCT_COMPONENTS) != 0) {
070: table
071: .put("CollapsiblePaneUI",
072: "com.jidesoft.plaf.office2003.Office2003CollapsiblePaneUI");
073: table
074: .put("StatusBarSeparatorUI",
075: "com.jidesoft.plaf.office2003.Office2003StatusBarSeparatorUI");
076: }
077:
078: if ((products & PRODUCT_ACTION) != 0) {
079: table
080: .put("CommandBarUI",
081: "com.jidesoft.plaf.office2003.Office2003CommandBarUI");
082: table
083: .put("CommandBarSeparatorUI",
084: "com.jidesoft.plaf.office2003.Office2003CommandBarSeparatorUI");
085: table
086: .put("CommandBarTitleBarUI",
087: "com.jidesoft.plaf.office2003.Office2003CommandBarTitleBarUI");
088: }
089: }
090:
091: /**
092: * Initializes class defaults.
093: *
094: * @param table
095: */
096: public static void initClassDefaults(UIDefaults table) {
097: initClassDefaults(table, true);
098: }
099:
100: /**
101: * Initializes components defaults.
102: *
103: * @param table
104: */
105: public static void initComponentDefaults(UIDefaults table) {
106: Toolkit toolkit = Toolkit.getDefaultToolkit();
107:
108: WindowsDesktopProperty defaultTextColor = new WindowsDesktopProperty(
109: "win.button.textColor", table.get("controlText"),
110: toolkit);
111:
112: WindowsDesktopProperty defaultBackgroundColor = new WindowsDesktopProperty(
113: "win.3d.backgroundColor", table.get("control"), toolkit);
114:
115: WindowsDesktopProperty defaultLightColor = new WindowsDesktopProperty(
116: "win.3d.lightColor", table.get("controlHighlight"),
117: toolkit);
118: WindowsDesktopProperty defaultHighlightColor = new WindowsDesktopProperty(
119: "win.3d.highlightColor", table
120: .get("controlLtHighlight"), toolkit);
121: WindowsDesktopProperty defaultShadowColor = new WindowsDesktopProperty(
122: "win.3d.shadowColor", table.get("controlShadow"),
123: toolkit);
124: WindowsDesktopProperty defaultDarkShadowColor = new WindowsDesktopProperty(
125: "win.3d.darkShadowColor", table.get("controlDkShadow"),
126: toolkit);
127:
128: Object toolbarFont = JideSwingUtilities.getMenuFont(toolkit,
129: table);
130: Object boldFont = JideSwingUtilities
131: .getBoldFont(toolkit, table);
132:
133: Painter gripperPainter = new Painter() {
134: public void paint(JComponent c, Graphics g, Rectangle rect,
135: int orientation, int state) {
136: Office2003Painter.getInstance().paintGripper(c, g,
137: rect, orientation, state);
138: }
139: };
140:
141: ImageIcon sliderHorizontalImage = IconsFactory.getImageIcon(
142: Office2003WindowsUtils.class,
143: "icons/slider_horizontal.gif");
144: ImageIcon sliderVerticalalImage = IconsFactory.getImageIcon(
145: Office2003WindowsUtils.class,
146: "icons/slider_vertical.gif");
147:
148: Object uiDefaults[] = new Object[] {
149: "JideTabbedPane.defaultTabShape",
150: JideTabbedPane.SHAPE_OFFICE2003,
151: "JideTabbedPane.defaultTabColorTheme",
152: JideTabbedPane.COLOR_THEME_OFFICE2003,
153: "JideTabbedPane.contentBorderInsets",
154: new InsetsUIResource(3, 3, 3, 3),
155:
156: "JideTabbedPane.gripperPainter",
157: gripperPainter,
158: "JideTabbedPane.alwaysShowLineBorder",
159: Boolean.FALSE,
160: "JideTabbedPane.showFocusIndicator",
161: Boolean.TRUE,
162:
163: "JideSplitPaneDivider.gripperPainter",
164: gripperPainter,
165:
166: "Gripper.size",
167: 8,
168: "Gripper.painter",
169: gripperPainter,
170: "Icon.floating",
171: Boolean.FALSE,
172:
173: "RangeSlider.lowerIcon",
174: IconsFactory.getIcon(null, sliderHorizontalImage, 0, 0,
175: 9, 10),
176: "RangeSlider.upperIcon",
177: IconsFactory.getIcon(null, sliderHorizontalImage, 0,
178: 10, 9, 10),
179: "RangeSlider.middleIcon",
180: IconsFactory.getIcon(null, sliderHorizontalImage, 0,
181: 20, 9, 7),
182: "RangeSlider.lowerRIcon",
183: IconsFactory.getIcon(null, sliderHorizontalImage, 9, 0,
184: 9, 10),
185: "RangeSlider.upperRIcon",
186: IconsFactory.getIcon(null, sliderHorizontalImage, 9,
187: 10, 9, 10),
188: "RangeSlider.middleRIcon",
189: IconsFactory.getIcon(null, sliderHorizontalImage, 9,
190: 20, 9, 7),
191:
192: "RangeSlider.lowerVIcon",
193: IconsFactory.getIcon(null, sliderVerticalalImage, 0, 0,
194: 10, 9),
195: "RangeSlider.upperVIcon",
196: IconsFactory.getIcon(null, sliderVerticalalImage, 10,
197: 0, 10, 9),
198: "RangeSlider.middleVIcon",
199: IconsFactory.getIcon(null, sliderVerticalalImage, 20,
200: 0, 7, 9),
201: "RangeSlider.lowerVRIcon",
202: IconsFactory.getIcon(null, sliderVerticalalImage, 0, 9,
203: 10, 9),
204: "RangeSlider.upperVRIcon",
205: IconsFactory.getIcon(null, sliderVerticalalImage, 10,
206: 9, 10, 9),
207: "RangeSlider.middleVRIcon",
208: IconsFactory.getIcon(null, sliderVerticalalImage, 20,
209: 9, 7, 9),
210:
211: "JideScrollPane.border",
212: table.getBorder("ScrollPane.border"),
213:
214: "Menu.margin",
215: new InsetsUIResource(2, 7, 3, 7),
216:
217: "Menu.submenuPopupOffsetX",
218: 1,
219: "Menu.submenuPopupOffsetY",
220: 0,
221: "MenuBar.border",
222: new BorderUIResource(BorderFactory.createEmptyBorder(1,
223: 2, 1, 2)),
224:
225: "PopupMenu.background", new UIDefaults.ActiveValue() {
226: public Object createValue(UIDefaults table) {
227: return Office2003Painter.getInstance()
228: .getMenuItemBackground();
229: }
230: }, };
231: table.putDefaults(uiDefaults);
232:
233: int products = LookAndFeelFactory.getProductsUsed();
234:
235: if ((products & PRODUCT_DOCK) != 0) {
236: boolean useShadowBorder = "true".equals(SecurityUtils
237: .getProperty("jide.shadeSlidingBorder", "false"));
238:
239: Object slidingEastFrameBorder = new ExtWindowsDesktopProperty(
240: new String[] { "win.3d.lightColor",
241: "win.3d.highlightColor",
242: "win.3d.shadowColor",
243: "win.3d.darkShadowColor" }, new Object[] {
244: table.get("control"),
245: table.get("controlLtHighlight"),
246: table.get("controlShadow"),
247: table.get("controlDkShadow") }, toolkit,
248: new ConvertListener() {
249: public Object convert(Object[] obj) {
250: return new SlidingFrameBorder(
251: (Color) obj[0],
252: (Color) obj[1],
253: (Color) obj[2],
254: (Color) obj[3],
255: new Insets(
256: 1,
257: SlidingFrameBorder.SHADOW_SIZE + 5,
258: 1, 1));
259: }
260: });
261:
262: Object slidingWestFrameBorder = new ExtWindowsDesktopProperty(
263: new String[] { "win.3d.lightColor",
264: "win.3d.highlightColor",
265: "win.3d.shadowColor",
266: "win.3d.darkShadowColor" }, new Object[] {
267: table.get("control"),
268: table.get("controlLtHighlight"),
269: table.get("controlShadow"),
270: table.get("controlDkShadow") }, toolkit,
271: new ConvertListener() {
272: public Object convert(Object[] obj) {
273: return new SlidingFrameBorder(
274: (Color) obj[0],
275: (Color) obj[1],
276: (Color) obj[2],
277: (Color) obj[3],
278: new Insets(
279: 1,
280: 1,
281: 1,
282: SlidingFrameBorder.SHADOW_SIZE + 5));
283: }
284: });
285:
286: Object slidingNorthFrameBorder = new ExtWindowsDesktopProperty(
287: new String[] { "win.3d.lightColor",
288: "win.3d.highlightColor",
289: "win.3d.shadowColor",
290: "win.3d.darkShadowColor" }, new Object[] {
291: table.get("control"),
292: table.get("controlLtHighlight"),
293: table.get("controlShadow"),
294: table.get("controlDkShadow") }, toolkit,
295: new ConvertListener() {
296: public Object convert(Object[] obj) {
297: return new SlidingFrameBorder(
298: (Color) obj[0],
299: (Color) obj[1],
300: (Color) obj[2],
301: (Color) obj[3],
302: new Insets(
303: 1,
304: 1,
305: SlidingFrameBorder.SHADOW_SIZE + 5,
306: 1));
307: }
308: });
309:
310: Object slidingSouthFrameBorder = new ExtWindowsDesktopProperty(
311: new String[] { "win.3d.lightColor",
312: "win.3d.highlightColor",
313: "win.3d.shadowColor",
314: "win.3d.darkShadowColor" }, new Object[] {
315: table.get("control"),
316: table.get("controlLtHighlight"),
317: table.get("controlShadow"),
318: table.get("controlDkShadow") }, toolkit,
319: new ConvertListener() {
320: public Object convert(Object[] obj) {
321: return new SlidingFrameBorder(
322: (Color) obj[0],
323: (Color) obj[1],
324: (Color) obj[2],
325: (Color) obj[3],
326: new Insets(
327: SlidingFrameBorder.SHADOW_SIZE + 5,
328: 1, 1, 1));
329: }
330: });
331:
332: Object slidingEastFrameBorder2 = new ExtWindowsDesktopProperty(
333: new String[] { "win.3d.lightColor",
334: "win.3d.highlightColor",
335: "win.3d.shadowColor",
336: "win.3d.darkShadowColor" }, new Object[] {
337: table.get("control"),
338: table.get("controlLtHighlight"),
339: table.get("controlShadow"),
340: table.get("controlDkShadow") }, toolkit,
341: new ConvertListener() {
342: public Object convert(Object[] obj) {
343: return new ResizeFrameBorder(
344: (Color) obj[0], (Color) obj[1],
345: (Color) obj[2], (Color) obj[3],
346: new Insets(0, 4, 0, 0));
347: }
348: });
349:
350: Object slidingWestFrameBorder2 = new ExtWindowsDesktopProperty(
351: new String[] { "win.3d.lightColor",
352: "win.3d.highlightColor",
353: "win.3d.shadowColor",
354: "win.3d.darkShadowColor" }, new Object[] {
355: table.get("control"),
356: table.get("controlLtHighlight"),
357: table.get("controlShadow"),
358: table.get("controlDkShadow") }, toolkit,
359: new ConvertListener() {
360: public Object convert(Object[] obj) {
361: return new ResizeFrameBorder(
362: (Color) obj[0], (Color) obj[1],
363: (Color) obj[2], (Color) obj[3],
364: new Insets(0, 0, 0, 4));
365: }
366: });
367:
368: Object slidingNorthFrameBorder2 = new ExtWindowsDesktopProperty(
369: new String[] { "win.3d.lightColor",
370: "win.3d.highlightColor",
371: "win.3d.shadowColor",
372: "win.3d.darkShadowColor" }, new Object[] {
373: table.get("control"),
374: table.get("controlLtHighlight"),
375: table.get("controlShadow"),
376: table.get("controlDkShadow") }, toolkit,
377: new ConvertListener() {
378: public Object convert(Object[] obj) {
379: return new ResizeFrameBorder(
380: (Color) obj[0], (Color) obj[1],
381: (Color) obj[2], (Color) obj[3],
382: new Insets(0, 0, 4, 0));
383: }
384: });
385:
386: Object slidingSouthFrameBorder2 = new ExtWindowsDesktopProperty(
387: new String[] { "win.3d.lightColor",
388: "win.3d.highlightColor",
389: "win.3d.shadowColor",
390: "win.3d.darkShadowColor" }, new Object[] {
391: table.get("control"),
392: table.get("controlLtHighlight"),
393: table.get("controlShadow"),
394: table.get("controlDkShadow") }, toolkit,
395: new ConvertListener() {
396: public Object convert(Object[] obj) {
397: return new ResizeFrameBorder(
398: (Color) obj[0], (Color) obj[1],
399: (Color) obj[2], (Color) obj[3],
400: new Insets(4, 0, 0, 0));
401: }
402: });
403:
404: uiDefaults = new Object[] {
405: // dock
406: "SidePane.foreground",
407: defaultTextColor,
408: "SidePane.lineColor",
409: new UIDefaults.ActiveValue() {
410: public Object createValue(UIDefaults table) {
411: return Office2003Painter.getInstance()
412: .getControlShadow();
413: }
414: },
415: "StatusBarItem.border",
416: new BorderUIResource(BorderFactory
417: .createEmptyBorder(0, 1, 0, 1)),
418: "StatusBar.border",
419: new StatusBarBorder(),
420:
421: "DockableFrame.titleBorder",
422: new BorderUIResource(BorderFactory
423: .createEmptyBorder(0, 0, 0, 0)),
424: "DockableFrameTitlePane.use3dButtons",
425: Boolean.FALSE,
426: "DockableFrameTitlePane.gripperPainter",
427: gripperPainter,
428: "DockableFrameTitlePane.margin",
429: new InsetsUIResource(2, 6, 2, 6), // gap
430:
431: "DockableFrame.activeTitleForeground",
432: UIDefaultsLookup
433: .getColor("DockableFrame.inactiveTitleForeground"),
434:
435: "DockableFrame.slidingEastBorder",
436: useShadowBorder ? slidingEastFrameBorder
437: : slidingEastFrameBorder2,
438: "DockableFrame.slidingWestBorder",
439: useShadowBorder ? slidingWestFrameBorder
440: : slidingWestFrameBorder2,
441: "DockableFrame.slidingNorthBorder",
442: useShadowBorder ? slidingNorthFrameBorder
443: : slidingNorthFrameBorder2,
444: "DockableFrame.slidingSouthBorder",
445: useShadowBorder ? slidingSouthFrameBorder
446: : slidingSouthFrameBorder2,
447:
448: "FrameContainer.contentBorderInsets",
449: new InsetsUIResource(3, 3, 3, 3), };
450: table.putDefaults(uiDefaults);
451: }
452: if ((products & PRODUCT_ACTION) != 0) {
453: Object floatingBorder = new ExtWindowsDesktopProperty(
454: new String[] { "win.3d.titleBarColor" },
455: new Object[] { table.get("controlShadow") },
456: toolkit, new ConvertListener() {
457: public Object convert(Object[] obj) {
458: return new BorderUIResource(
459: BorderFactory
460: .createCompoundBorder(
461: BorderFactory
462: .createLineBorder(
463: (Color) obj[0],
464: 2),
465: BorderFactory
466: .createEmptyBorder(
467: 1,
468: 1,
469: 1,
470: 1)));
471: }
472: });
473:
474: uiDefaults = new Object[] {
475: // action
476: "CommandBar.font",
477: toolbarFont,
478: "CommandBar.background",
479: defaultBackgroundColor,
480: "CommandBar.foreground",
481: defaultTextColor,
482: "CommandBar.shadow",
483: defaultShadowColor,
484: "CommandBar.darkShadow",
485: defaultDarkShadowColor,
486: "CommandBar.light",
487: defaultLightColor,
488: "CommandBar.highlight",
489: defaultHighlightColor,
490: "CommandBar.border",
491: new BorderUIResource(BorderFactory
492: .createEmptyBorder(1, 2, 2, 0)),
493: "CommandBar.borderVert",
494: new BorderUIResource(BorderFactory
495: .createEmptyBorder(2, 1, 0, 2)),
496: "CommandBar.borderFloating",
497: new BorderUIResource(BorderFactory
498: .createCompoundBorder(BorderFactory
499: .createLineBorder(table
500: .getColor("activeCaption"),
501: 2), BorderFactory
502: .createEmptyBorder(1, 1, 1, 1))),
503: "CommandBar.floatingBorder", floatingBorder,
504: "CommandBar.separatorSize", 5,
505: "CommandBar.titleBarSize", 17,
506: "CommandBar.titleBarButtonGap", 1,
507: "CommandBar.titleBarBackground",
508: table.getColor("activeCaption"),
509: "CommandBar.titleBarForeground",
510: table.getColor("activeCaptionText"),
511: "CommandBar.titleBarFont", boldFont,
512:
513: "Chevron.size", 13, "Chevron.alwaysVisible",
514: Boolean.TRUE, };
515: table.putDefaults(uiDefaults);
516: }
517:
518: if ((products & PRODUCT_GRIDS) != 0) {
519: uiDefaults = new Object[] { "AbstractComboBox.useJButton",
520: Boolean.FALSE, "NestedTableHeader.cellBorder",
521: new HeaderCellBorder(), };
522: table.putDefaults(uiDefaults);
523: }
524:
525: table.put("Theme.painter", Office2003Painter.getInstance());
526:
527: // since it used BasicPainter, make sure it is after Theme.Painter is set first.
528: Object popupMenuBorder = new ExtWindowsDesktopProperty(
529: new String[] { "null" },
530: new Object[] { ((BasicPainter) table
531: .get("Theme.painter")).getMenuItemBorderColor() },
532: toolkit, new ConvertListener() {
533: public Object convert(Object[] obj) {
534: return new BorderUIResource(
535: BorderFactory
536: .createCompoundBorder(
537: BorderFactory
538: .createLineBorder((Color) obj[0]),
539: BorderFactory
540: .createEmptyBorder(
541: 1, 1,
542: 1, 1)));
543: }
544: });
545: table.put("PopupMenu.border", popupMenuBorder);
546: }
547: }
|