1 /*
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 /*
27 * <p>These classes are designed to be used while the
28 * corresponding <code>LookAndFeel</code> class has been installed
29 * (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
30 * Using them while a different <code>LookAndFeel</code> is installed
31 * may produce unexpected results, including exceptions.
32 * Additionally, changing the <code>LookAndFeel</code>
33 * maintained by the <code>UIManager</code> without updating the
34 * corresponding <code>ComponentUI</code> of any
35 * <code>JComponent</code>s may also produce unexpected results,
36 * such as the wrong colors showing up, and is generally not
37 * encouraged.
38 *
39 */
40
41 package com.sun.java.swing.plaf.windows;
42
43 import java.awt.*;
44 import java.awt.image.BufferedImage;
45 import java.awt.image.ImageFilter;
46 import java.awt.image.ImageProducer;
47 import java.awt.image.FilteredImageSource;
48 import java.awt.image.RGBImageFilter;
49
50 import javax.swing.plaf.*;
51 import javax.swing.*;
52 import javax.swing.plaf.basic.*;
53 import javax.swing.border.*;
54 import javax.swing.text.DefaultEditorKit;
55 import static javax.swing.UIDefaults.LazyValue;
56
57 import java.awt.Font;
58 import java.awt.Color;
59 import java.awt.event.ActionEvent;
60
61 import java.security.AccessController;
62
63 import sun.awt.SunToolkit;
64 import sun.awt.OSInfo;
65 import sun.awt.shell.ShellFolder;
66 import sun.font.FontUtilities;
67 import sun.security.action.GetPropertyAction;
68
69 import sun.swing.DefaultLayoutStyle;
70 import sun.swing.ImageIconUIResource;
71 import sun.swing.icon.SortArrowIcon;
72 import sun.swing.SwingUtilities2;
73 import sun.swing.StringUIClientPropertyKey;
74 import sun.swing.plaf.windows.ClassicSortArrowIcon;
75
76 import static com.sun.java.swing.plaf.windows.TMSchema.*;
77 import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
78
79 import com.sun.java.swing.plaf.windows.WindowsIconFactory.VistaMenuItemCheckIconFactory;
80
81 /**
82 * Implements the Windows95/98/NT/2000 Look and Feel.
83 * UI classes not implemented specifically for Windows will
84 * default to those implemented in Basic.
85 * <p>
86 * <strong>Warning:</strong>
87 * Serialized objects of this class will not be compatible with
88 * future Swing releases. The current serialization support is appropriate
89 * for short term storage or RMI between applications running the same
90 * version of Swing. A future release of Swing will provide support for
91 * long term persistence.
92 *
93 * @author unattributed
94 */
95 @SuppressWarnings("serial") // Superclass is not serializable across versions
96 public class WindowsLookAndFeel extends BasicLookAndFeel
97 {
98 /**
99 * A client property that can be used with any JComponent that will end up
100 * calling the LookAndFeel.getDisabledIcon method. This client property,
101 * when set to Boolean.TRUE, will cause getDisabledIcon to use an
102 * alternate algorithm for creating disabled icons to produce icons
103 * that appear similar to the native Windows file chooser
104 */
105 static final Object HI_RES_DISABLED_ICON_CLIENT_KEY =
106 new StringUIClientPropertyKey(
107 "WindowsLookAndFeel.generateHiResDisabledIcon");
108
109 private boolean updatePending = false;
110
111 private boolean useSystemFontSettings = true;
112 private boolean useSystemFontSizeSettings;
113
114 // These properties are not used directly, but are kept as
115 // private members to avoid being GC'd.
116 private DesktopProperty themeActive, dllName, colorName, sizeName;
117 private DesktopProperty aaSettings;
118
119 private transient LayoutStyle style;
120
121 /**
122 * Base dialog units along the horizontal axis.
123 */
124 private int baseUnitX;
125
126 /**
127 * Base dialog units along the vertical axis.
128 */
129 private int baseUnitY;
130
131 public String getName() {
132 return "Windows";
133 }
134
135 public String getDescription() {
136 return "The Microsoft Windows Look and Feel";
137 }
138
139 public String getID() {
140 return "Windows";
141 }
142
143 public boolean isNativeLookAndFeel() {
144 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS;
145 }
146
147 public boolean isSupportedLookAndFeel() {
148 return isNativeLookAndFeel();
149 }
150
151 public void initialize() {
152 super.initialize();
153
154 // Set the flag which determines which version of Windows should
155 // be rendered. This flag only need to be set once.
156 // if version <= 4.0 then the classic LAF should be loaded.
157 if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
158 isClassicWindows = true;
159 } else {
160 isClassicWindows = false;
161 XPStyle.invalidateStyle();
162 }
163
164 // Using the fonts set by the user can potentially cause
165 // performance and compatibility issues, so allow this feature
166 // to be switched off either at runtime or programmatically
167 //
168 String systemFonts = java.security.AccessController.doPrivileged(
169 new GetPropertyAction("swing.useSystemFontSettings"));
170 useSystemFontSettings = (systemFonts == null ||
171 Boolean.valueOf(systemFonts).booleanValue());
172
173 if (useSystemFontSettings) {
174 Object value = UIManager.get("Application.useSystemFontSettings");
175
176 useSystemFontSettings = (value == null ||
177 Boolean.TRUE.equals(value));
178 }
179 KeyboardFocusManager.getCurrentKeyboardFocusManager().
180 addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
181
182 }
183
184 /**
185 * Initialize the uiClassID to BasicComponentUI mapping.
186 * The JComponent classes define their own uiClassID constants
187 * (see AbstractComponent.getUIClassID). This table must
188 * map those constants to a BasicComponentUI class of the
189 * appropriate type.
190 *
191 * @see BasicLookAndFeel#getDefaults
192 */
193 protected void initClassDefaults(UIDefaults table)
194 {
195 super.initClassDefaults(table);
196
197 final String windowsPackageName = "com.sun.java.swing.plaf.windows.";
198
199 Object[] uiDefaults = {
200 "ButtonUI", windowsPackageName + "WindowsButtonUI",
201 "CheckBoxUI", windowsPackageName + "WindowsCheckBoxUI",
202 "CheckBoxMenuItemUI", windowsPackageName + "WindowsCheckBoxMenuItemUI",
203 "LabelUI", windowsPackageName + "WindowsLabelUI",
204 "RadioButtonUI", windowsPackageName + "WindowsRadioButtonUI",
205 "RadioButtonMenuItemUI", windowsPackageName + "WindowsRadioButtonMenuItemUI",
206 "ToggleButtonUI", windowsPackageName + "WindowsToggleButtonUI",
207 "ProgressBarUI", windowsPackageName + "WindowsProgressBarUI",
208 "SliderUI", windowsPackageName + "WindowsSliderUI",
209 "SeparatorUI", windowsPackageName + "WindowsSeparatorUI",
210 "SplitPaneUI", windowsPackageName + "WindowsSplitPaneUI",
211 "SpinnerUI", windowsPackageName + "WindowsSpinnerUI",
212 "TabbedPaneUI", windowsPackageName + "WindowsTabbedPaneUI",
213 "TextAreaUI", windowsPackageName + "WindowsTextAreaUI",
214 "TextFieldUI", windowsPackageName + "WindowsTextFieldUI",
215 "PasswordFieldUI", windowsPackageName + "WindowsPasswordFieldUI",
216 "TextPaneUI", windowsPackageName + "WindowsTextPaneUI",
217 "EditorPaneUI", windowsPackageName + "WindowsEditorPaneUI",
218 "TreeUI", windowsPackageName + "WindowsTreeUI",
219 "ToolBarUI", windowsPackageName + "WindowsToolBarUI",
220 "ToolBarSeparatorUI", windowsPackageName + "WindowsToolBarSeparatorUI",
221 "ComboBoxUI", windowsPackageName + "WindowsComboBoxUI",
222 "TableHeaderUI", windowsPackageName + "WindowsTableHeaderUI",
223 "InternalFrameUI", windowsPackageName + "WindowsInternalFrameUI",
224 "DesktopPaneUI", windowsPackageName + "WindowsDesktopPaneUI",
225 "DesktopIconUI", windowsPackageName + "WindowsDesktopIconUI",
226 "FileChooserUI", windowsPackageName + "WindowsFileChooserUI",
227 "MenuUI", windowsPackageName + "WindowsMenuUI",
228 "MenuItemUI", windowsPackageName + "WindowsMenuItemUI",
229 "MenuBarUI", windowsPackageName + "WindowsMenuBarUI",
230 "PopupMenuUI", windowsPackageName + "WindowsPopupMenuUI",
231 "PopupMenuSeparatorUI", windowsPackageName + "WindowsPopupMenuSeparatorUI",
232 "ScrollBarUI", windowsPackageName + "WindowsScrollBarUI",
233 "RootPaneUI", windowsPackageName + "WindowsRootPaneUI"
234 };
235
236 table.putDefaults(uiDefaults);
237 }
238
239 /**
240 * Load the SystemColors into the defaults table. The keys
241 * for SystemColor defaults are the same as the names of
242 * the public fields in SystemColor. If the table is being
243 * created on a native Windows platform we use the SystemColor
244 * values, otherwise we create color objects whose values match
245 * the defaults Windows95 colors.
246 */
247 protected void initSystemColorDefaults(UIDefaults table)
248 {
249 String[] defaultSystemColors = {
250 "desktop", "#005C5C", /* Color of the desktop background */
251 "activeCaption", "#000080", /* Color for captions (title bars) when they are active. */
252 "activeCaptionText", "#FFFFFF", /* Text color for text in captions (title bars). */
253 "activeCaptionBorder", "#C0C0C0", /* Border color for caption (title bar) window borders. */
254 "inactiveCaption", "#808080", /* Color for captions (title bars) when not active. */
255 "inactiveCaptionText", "#C0C0C0", /* Text color for text in inactive captions (title bars). */
256 "inactiveCaptionBorder", "#C0C0C0", /* Border color for inactive caption (title bar) window borders. */
257 "window", "#FFFFFF", /* Default color for the interior of windows */
258 "windowBorder", "#000000", /* ??? */
259 "windowText", "#000000", /* ??? */
260 "menu", "#C0C0C0", /* Background color for menus */
261 "menuPressedItemB", "#000080", /* LightShadow of menubutton highlight */
262 "menuPressedItemF", "#FFFFFF", /* Default color for foreground "text" in menu item */
263 "menuText", "#000000", /* Text color for menus */
264 "text", "#C0C0C0", /* Text background color */
265 "textText", "#000000", /* Text foreground color */
266 "textHighlight", "#000080", /* Text background color when selected */
267 "textHighlightText", "#FFFFFF", /* Text color when selected */
268 "textInactiveText", "#808080", /* Text color when disabled */
269 "control", "#C0C0C0", /* Default color for controls (buttons, sliders, etc) */
270 "controlText", "#000000", /* Default color for text in controls */
271 "controlHighlight", "#C0C0C0",
272
273 /*"controlHighlight", "#E0E0E0",*/ /* Specular highlight (opposite of the shadow) */
274 "controlLtHighlight", "#FFFFFF", /* Highlight color for controls */
275 "controlShadow", "#808080", /* Shadow color for controls */
276 "controlDkShadow", "#000000", /* Dark shadow color for controls */
277 "scrollbar", "#E0E0E0", /* Scrollbar background (usually the "track") */
278 "info", "#FFFFE1", /* ??? */
279 "infoText", "#000000" /* ??? */
280 };
281
282 loadSystemColors(table, defaultSystemColors, isNativeLookAndFeel());
283 }
284
285 /**
286 * Initialize the defaults table with the name of the ResourceBundle
287 * used for getting localized defaults.
288 */
289 private void initResourceBundle(UIDefaults table) {
290 table.addResourceBundle( "com.sun.java.swing.plaf.windows.resources.windows" );
291 }
292
293 // XXX - there are probably a lot of redundant values that could be removed.
294 // ie. Take a look at RadioButtonBorder, etc...
295 protected void initComponentDefaults(UIDefaults table)
296 {
297 super.initComponentDefaults( table );
298
299 initResourceBundle(table);
300
301 // *** Shared Fonts
302 LazyValue dialogPlain12 = t -> new FontUIResource(Font.DIALOG, Font.PLAIN, 12);
303
304 LazyValue sansSerifPlain12 = t -> new FontUIResource(Font.SANS_SERIF, Font.PLAIN, 12);
305 LazyValue monospacedPlain12 = t -> new FontUIResource(Font.MONOSPACED, Font.PLAIN, 12);
306 LazyValue dialogBold12 = t -> new FontUIResource(Font.DIALOG, Font.BOLD, 12);
307
308 // *** Colors
309 // XXX - some of these doens't seem to be used
310 ColorUIResource red = new ColorUIResource(Color.red);
311 ColorUIResource black = new ColorUIResource(Color.black);
312 ColorUIResource white = new ColorUIResource(Color.white);
313 ColorUIResource gray = new ColorUIResource(Color.gray);
314 ColorUIResource darkGray = new ColorUIResource(Color.darkGray);
315 ColorUIResource scrollBarTrackHighlight = darkGray;
316
317 // Set the flag which determines which version of Windows should
318 // be rendered. This flag only need to be set once.
319 // if version <= 4.0 then the classic LAF should be loaded.
320 isClassicWindows = OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0;
321
322 // *** Tree
323 Object treeExpandedIcon = WindowsTreeUI.ExpandedIcon.createExpandedIcon();
324
325 Object treeCollapsedIcon = WindowsTreeUI.CollapsedIcon.createCollapsedIcon();
326
327
328 // *** Text
329 Object fieldInputMap = new UIDefaults.LazyInputMap(new Object[] {
330 "control C", DefaultEditorKit.copyAction,
331 "control V", DefaultEditorKit.pasteAction,
332 "control X", DefaultEditorKit.cutAction,
333 "COPY", DefaultEditorKit.copyAction,
334 "PASTE", DefaultEditorKit.pasteAction,
335 "CUT", DefaultEditorKit.cutAction,
336 "control INSERT", DefaultEditorKit.copyAction,
337 "shift INSERT", DefaultEditorKit.pasteAction,
338 "shift DELETE", DefaultEditorKit.cutAction,
339 "control A", DefaultEditorKit.selectAllAction,
340 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
341 "shift LEFT", DefaultEditorKit.selectionBackwardAction,
342 "shift RIGHT", DefaultEditorKit.selectionForwardAction,
343 "control LEFT", DefaultEditorKit.previousWordAction,
344 "control RIGHT", DefaultEditorKit.nextWordAction,
345 "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
346 "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
347 "HOME", DefaultEditorKit.beginLineAction,
348 "END", DefaultEditorKit.endLineAction,
349 "shift HOME", DefaultEditorKit.selectionBeginLineAction,
350 "shift END", DefaultEditorKit.selectionEndLineAction,
351 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
352 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
353 "ctrl H", DefaultEditorKit.deletePrevCharAction,
354 "DELETE", DefaultEditorKit.deleteNextCharAction,
355 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
356 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
357 "RIGHT", DefaultEditorKit.forwardAction,
358 "LEFT", DefaultEditorKit.backwardAction,
359 "KP_RIGHT", DefaultEditorKit.forwardAction,
360 "KP_LEFT", DefaultEditorKit.backwardAction,
361 "ENTER", JTextField.notifyAction,
362 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
363 });
364
365 Object passwordInputMap = new UIDefaults.LazyInputMap(new Object[] {
366 "control C", DefaultEditorKit.copyAction,
367 "control V", DefaultEditorKit.pasteAction,
368 "control X", DefaultEditorKit.cutAction,
369 "COPY", DefaultEditorKit.copyAction,
370 "PASTE", DefaultEditorKit.pasteAction,
371 "CUT", DefaultEditorKit.cutAction,
372 "control INSERT", DefaultEditorKit.copyAction,
373 "shift INSERT", DefaultEditorKit.pasteAction,
374 "shift DELETE", DefaultEditorKit.cutAction,
375 "control A", DefaultEditorKit.selectAllAction,
376 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
377 "shift LEFT", DefaultEditorKit.selectionBackwardAction,
378 "shift RIGHT", DefaultEditorKit.selectionForwardAction,
379 "control LEFT", DefaultEditorKit.beginLineAction,
380 "control RIGHT", DefaultEditorKit.endLineAction,
381 "control shift LEFT", DefaultEditorKit.selectionBeginLineAction,
382 "control shift RIGHT", DefaultEditorKit.selectionEndLineAction,
383 "HOME", DefaultEditorKit.beginLineAction,
384 "END", DefaultEditorKit.endLineAction,
385 "shift HOME", DefaultEditorKit.selectionBeginLineAction,
386 "shift END", DefaultEditorKit.selectionEndLineAction,
387 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
388 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
389 "ctrl H", DefaultEditorKit.deletePrevCharAction,
390 "DELETE", DefaultEditorKit.deleteNextCharAction,
391 "RIGHT", DefaultEditorKit.forwardAction,
392 "LEFT", DefaultEditorKit.backwardAction,
393 "KP_RIGHT", DefaultEditorKit.forwardAction,
394 "KP_LEFT", DefaultEditorKit.backwardAction,
395 "ENTER", JTextField.notifyAction,
396 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
397 });
398
399 Object multilineInputMap = new UIDefaults.LazyInputMap(new Object[] {
400 "control C", DefaultEditorKit.copyAction,
401 "control V", DefaultEditorKit.pasteAction,
402 "control X", DefaultEditorKit.cutAction,
403 "COPY", DefaultEditorKit.copyAction,
404 "PASTE", DefaultEditorKit.pasteAction,
405 "CUT", DefaultEditorKit.cutAction,
406 "control INSERT", DefaultEditorKit.copyAction,
407 "shift INSERT", DefaultEditorKit.pasteAction,
408 "shift DELETE", DefaultEditorKit.cutAction,
409 "shift LEFT", DefaultEditorKit.selectionBackwardAction,
410 "shift RIGHT", DefaultEditorKit.selectionForwardAction,
411 "control LEFT", DefaultEditorKit.previousWordAction,
412 "control RIGHT", DefaultEditorKit.nextWordAction,
413 "control shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
414 "control shift RIGHT", DefaultEditorKit.selectionNextWordAction,
415 "control A", DefaultEditorKit.selectAllAction,
416 "control BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
417 "HOME", DefaultEditorKit.beginLineAction,
418 "END", DefaultEditorKit.endLineAction,
419 "shift HOME", DefaultEditorKit.selectionBeginLineAction,
420 "shift END", DefaultEditorKit.selectionEndLineAction,
421 "control HOME", DefaultEditorKit.beginAction,
422 "control END", DefaultEditorKit.endAction,
423 "control shift HOME", DefaultEditorKit.selectionBeginAction,
424 "control shift END", DefaultEditorKit.selectionEndAction,
425 "UP", DefaultEditorKit.upAction,
426 "DOWN", DefaultEditorKit.downAction,
427 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
428 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
429 "ctrl H", DefaultEditorKit.deletePrevCharAction,
430 "DELETE", DefaultEditorKit.deleteNextCharAction,
431 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
432 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
433 "RIGHT", DefaultEditorKit.forwardAction,
434 "LEFT", DefaultEditorKit.backwardAction,
435 "KP_RIGHT", DefaultEditorKit.forwardAction,
436 "KP_LEFT", DefaultEditorKit.backwardAction,
437 "PAGE_UP", DefaultEditorKit.pageUpAction,
438 "PAGE_DOWN", DefaultEditorKit.pageDownAction,
439 "shift PAGE_UP", "selection-page-up",
440 "shift PAGE_DOWN", "selection-page-down",
441 "ctrl shift PAGE_UP", "selection-page-left",
442 "ctrl shift PAGE_DOWN", "selection-page-right",
443 "shift UP", DefaultEditorKit.selectionUpAction,
444 "shift DOWN", DefaultEditorKit.selectionDownAction,
445 "ENTER", DefaultEditorKit.insertBreakAction,
446 "TAB", DefaultEditorKit.insertTabAction,
447 "control T", "next-link-action",
448 "control shift T", "previous-link-action",
449 "control SPACE", "activate-link-action",
450 "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
451 });
452
453 Object menuItemAcceleratorDelimiter = "+";
454
455 Object ControlBackgroundColor = new DesktopProperty(
456 "win.3d.backgroundColor",
457 table.get("control"));
458 Object ControlLightColor = new DesktopProperty(
459 "win.3d.lightColor",
460 table.get("controlHighlight"));
461 Object ControlHighlightColor = new DesktopProperty(
462 "win.3d.highlightColor",
463 table.get("controlLtHighlight"));
464 Object ControlShadowColor = new DesktopProperty(
465 "win.3d.shadowColor",
466 table.get("controlShadow"));
467 Object ControlDarkShadowColor = new DesktopProperty(
468 "win.3d.darkShadowColor",
469 table.get("controlDkShadow"));
470 Object ControlTextColor = new DesktopProperty(
471 "win.button.textColor",
472 table.get("controlText"));
473 Object MenuBackgroundColor = new DesktopProperty(
474 "win.menu.backgroundColor",
475 table.get("menu"));
476 Object MenuBarBackgroundColor = new DesktopProperty(
477 "win.menubar.backgroundColor",
478 table.get("menu"));
479 Object MenuTextColor = new DesktopProperty(
480 "win.menu.textColor",
481 table.get("menuText"));
482 Object SelectionBackgroundColor = new DesktopProperty(
483 "win.item.highlightColor",
484 table.get("textHighlight"));
485 Object SelectionTextColor = new DesktopProperty(
486 "win.item.highlightTextColor",
487 table.get("textHighlightText"));
488 Object WindowBackgroundColor = new DesktopProperty(
489 "win.frame.backgroundColor",
490 table.get("window"));
491 Object WindowTextColor = new DesktopProperty(
492 "win.frame.textColor",
493 table.get("windowText"));
494 Object WindowBorderWidth = new DesktopProperty(
495 "win.frame.sizingBorderWidth",
496 Integer.valueOf(1));
497 Object TitlePaneHeight = new DesktopProperty(
498 "win.frame.captionHeight",
499 Integer.valueOf(18));
500 Object TitleButtonWidth = new DesktopProperty(
501 "win.frame.captionButtonWidth",
502 Integer.valueOf(16));
503 Object TitleButtonHeight = new DesktopProperty(
504 "win.frame.captionButtonHeight",
505 Integer.valueOf(16));
506 Object InactiveTextColor = new DesktopProperty(
507 "win.text.grayedTextColor",
508 table.get("textInactiveText"));
509 Object ScrollbarBackgroundColor = new DesktopProperty(
510 "win.scrollbar.backgroundColor",
511 table.get("scrollbar"));
512 Object buttonFocusColor = new FocusColorProperty();
513
514 Object TextBackground = new XPColorValue(Part.EP_EDIT, null, Prop.FILLCOLOR,
515 WindowBackgroundColor);
516 //The following four lines were commented out as part of bug 4991597
517 //This code *is* correct, however it differs from WindowsXP and is, apparently
518 //a Windows XP bug. Until Windows fixes this bug, we shall also exhibit the same
519 //behavior
520 //Object ReadOnlyTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.READONLY, Prop.FILLCOLOR,
521 // ControlBackgroundColor);
522 //Object DisabledTextBackground = new XPColorValue(Part.EP_EDITTEXT, State.DISABLED, Prop.FILLCOLOR,
523 // ControlBackgroundColor);
524 Object ReadOnlyTextBackground = ControlBackgroundColor;
525 Object DisabledTextBackground = ControlBackgroundColor;
526
527 Object MenuFont = dialogPlain12;
528 Object FixedControlFont = monospacedPlain12;
529 Object ControlFont = dialogPlain12;
530 Object MessageFont = dialogPlain12;
531 Object WindowFont = dialogBold12;
532 Object ToolTipFont = sansSerifPlain12;
533 Object IconFont = ControlFont;
534
535 Object scrollBarWidth = new DesktopProperty("win.scrollbar.width", Integer.valueOf(16));
536
537 Object menuBarHeight = new DesktopProperty("win.menu.height", null);
538
539 Object hotTrackingOn = new DesktopProperty("win.item.hotTrackingOn", true);
540
541 Object showMnemonics = new DesktopProperty("win.menu.keyboardCuesOn", Boolean.TRUE);
542
543 if (useSystemFontSettings) {
544 MenuFont = getDesktopFontValue("win.menu.font", MenuFont);
545 FixedControlFont = getDesktopFontValue("win.ansiFixed.font", FixedControlFont);
546 ControlFont = getDesktopFontValue("win.defaultGUI.font", ControlFont);
547 MessageFont = getDesktopFontValue("win.messagebox.font", MessageFont);
548 WindowFont = getDesktopFontValue("win.frame.captionFont", WindowFont);
549 IconFont = getDesktopFontValue("win.icon.font", IconFont);
550 ToolTipFont = getDesktopFontValue("win.tooltip.font", ToolTipFont);
551
552 /* Put the desktop AA settings in the defaults.
553 * JComponent.setUI() retrieves this and makes it available
554 * as a client property on the JComponent. Use the same key name
555 * for both client property and UIDefaults.
556 * Also need to set up listeners for changes in these settings.
557 */
558 SwingUtilities2.putAATextInfo(true, table);
559 this.aaSettings =
560 new FontDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
561 }
562 if (useSystemFontSizeSettings) {
563 MenuFont = new WindowsFontSizeProperty("win.menu.font.height", Font.DIALOG, Font.PLAIN, 12);
564 FixedControlFont = new WindowsFontSizeProperty("win.ansiFixed.font.height", Font.MONOSPACED,
565 Font.PLAIN, 12);
566 ControlFont = new WindowsFontSizeProperty("win.defaultGUI.font.height", Font.DIALOG, Font.PLAIN, 12);
567 MessageFont = new WindowsFontSizeProperty("win.messagebox.font.height", Font.DIALOG, Font.PLAIN, 12);
568 WindowFont = new WindowsFontSizeProperty("win.frame.captionFont.height", Font.DIALOG, Font.BOLD, 12);
569 ToolTipFont = new WindowsFontSizeProperty("win.tooltip.font.height", Font.SANS_SERIF, Font.PLAIN, 12);
570 IconFont = new WindowsFontSizeProperty("win.icon.font.height", Font.DIALOG, Font.PLAIN, 12);
571 }
572
573
574 if (!(this instanceof WindowsClassicLookAndFeel) &&
575 (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
576 OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) >= 0) &&
577 AccessController.doPrivileged(new GetPropertyAction("swing.noxp")) == null) {
578
579 // These desktop properties are not used directly, but are needed to
580 // trigger realoading of UI's.
581 this.themeActive = new TriggerDesktopProperty("win.xpstyle.themeActive");
582 this.dllName = new TriggerDesktopProperty("win.xpstyle.dllName");
583 this.colorName = new TriggerDesktopProperty("win.xpstyle.colorName");
584 this.sizeName = new TriggerDesktopProperty("win.xpstyle.sizeName");
585 }
586
587
588 Object[] defaults = {
589 // *** Auditory Feedback
590 // this key defines which of the various cues to render
591 // Overridden from BasicL&F. This L&F should play all sounds
592 // all the time. The infrastructure decides what to play.
593 // This is disabled until sound bugs can be resolved.
594 "AuditoryCues.playList", null, // table.get("AuditoryCues.cueList"),
595
596 "Application.useSystemFontSettings", Boolean.valueOf(useSystemFontSettings),
597
598 "TextField.focusInputMap", fieldInputMap,
599 "PasswordField.focusInputMap", passwordInputMap,
600 "TextArea.focusInputMap", multilineInputMap,
601 "TextPane.focusInputMap", multilineInputMap,
602 "EditorPane.focusInputMap", multilineInputMap,
603
604 // Buttons
605 "Button.font", ControlFont,
606 "Button.background", ControlBackgroundColor,
607 // Button.foreground, Button.shadow, Button.darkShadow,
608 // Button.disabledForground, and Button.disabledShadow are only
609 // used for Windows Classic. Windows XP will use colors
610 // from the current visual style.
611 "Button.foreground", ControlTextColor,
612 "Button.shadow", ControlShadowColor,
613 "Button.darkShadow", ControlDarkShadowColor,
614 "Button.light", ControlLightColor,
615 "Button.highlight", ControlHighlightColor,
616 "Button.disabledForeground", InactiveTextColor,
617 "Button.disabledShadow", ControlHighlightColor,
618 "Button.focus", buttonFocusColor,
619 "Button.dashedRectGapX", new XPValue(Integer.valueOf(3), Integer.valueOf(5)),
620 "Button.dashedRectGapY", new XPValue(Integer.valueOf(3), Integer.valueOf(4)),
621 "Button.dashedRectGapWidth", new XPValue(Integer.valueOf(6), Integer.valueOf(10)),
622 "Button.dashedRectGapHeight", new XPValue(Integer.valueOf(6), Integer.valueOf(8)),
623 "Button.textShiftOffset", new XPValue(Integer.valueOf(0),
624 Integer.valueOf(1)),
625 // W2K keyboard navigation hidding.
626 "Button.showMnemonics", showMnemonics,
627 "Button.focusInputMap",
628 new UIDefaults.LazyInputMap(new Object[] {
629 "SPACE", "pressed",
630 "released SPACE", "released"
631 }),
632
633 "Caret.width",
634 new DesktopProperty("win.caret.width", null),
635
636 "CheckBox.font", ControlFont,
637 "CheckBox.interiorBackground", WindowBackgroundColor,
638 "CheckBox.background", ControlBackgroundColor,
639 "CheckBox.foreground", WindowTextColor,
640 "CheckBox.shadow", ControlShadowColor,
641 "CheckBox.darkShadow", ControlDarkShadowColor,
642 "CheckBox.light", ControlLightColor,
643 "CheckBox.highlight", ControlHighlightColor,
644 "CheckBox.focus", buttonFocusColor,
645 "CheckBox.focusInputMap",
646 new UIDefaults.LazyInputMap(new Object[] {
647 "SPACE", "pressed",
648 "released SPACE", "released"
649 }),
650 // margin is 2 all the way around, BasicBorders.RadioButtonBorder
651 // (checkbox uses RadioButtonBorder) is 2 all the way around too.
652 "CheckBox.totalInsets", new Insets(4, 4, 4, 4),
653
654 "CheckBoxMenuItem.font", MenuFont,
655 "CheckBoxMenuItem.background", MenuBackgroundColor,
656 "CheckBoxMenuItem.foreground", MenuTextColor,
657 "CheckBoxMenuItem.selectionForeground", SelectionTextColor,
658 "CheckBoxMenuItem.selectionBackground", SelectionBackgroundColor,
659 "CheckBoxMenuItem.acceleratorForeground", MenuTextColor,
660 "CheckBoxMenuItem.acceleratorSelectionForeground", SelectionTextColor,
661 "CheckBoxMenuItem.commandSound", "win.sound.menuCommand",
662
663 "ComboBox.font", ControlFont,
664 "ComboBox.background", WindowBackgroundColor,
665 "ComboBox.foreground", WindowTextColor,
666 "ComboBox.buttonBackground", ControlBackgroundColor,
667 "ComboBox.buttonShadow", ControlShadowColor,
668 "ComboBox.buttonDarkShadow", ControlDarkShadowColor,
669 "ComboBox.buttonHighlight", ControlHighlightColor,
670 "ComboBox.selectionBackground", SelectionBackgroundColor,
671 "ComboBox.selectionForeground", SelectionTextColor,
672 "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,2,1,1),
673 new EmptyBorder(1,4,1,4)),
674 "ComboBox.disabledBackground",
675 new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
676 Prop.FILLCOLOR, DisabledTextBackground),
677 "ComboBox.disabledForeground",
678 new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
679 Prop.TEXTCOLOR, InactiveTextColor),
680 "ComboBox.ancestorInputMap", new UIDefaults.LazyInputMap(new Object[] {
681 "ESCAPE", "hidePopup",
682 "PAGE_UP", "pageUpPassThrough",
683 "PAGE_DOWN", "pageDownPassThrough",
684 "HOME", "homePassThrough",
685 "END", "endPassThrough",
686 "DOWN", "selectNext2",
687 "KP_DOWN", "selectNext2",
688 "UP", "selectPrevious2",
689 "KP_UP", "selectPrevious2",
690 "ENTER", "enterPressed",
691 "F4", "togglePopup",
692 "alt DOWN", "togglePopup",
693 "alt KP_DOWN", "togglePopup",
694 "alt UP", "togglePopup",
695 "alt KP_UP", "togglePopup"
696 }),
697
698 // DeskTop.
699 "Desktop.background", new DesktopProperty(
700 "win.mdi.backgroundColor",
701 table.get("desktop")),
702 "Desktop.ancestorInputMap",
703 new UIDefaults.LazyInputMap(new Object[] {
704 "ctrl F5", "restore",
705 "ctrl F4", "close",
706 "ctrl F7", "move",
707 "ctrl F8", "resize",
708 "RIGHT", "right",
709 "KP_RIGHT", "right",
710 "LEFT", "left",
711 "KP_LEFT", "left",
712 "UP", "up",
713 "KP_UP", "up",
714 "DOWN", "down",
715 "KP_DOWN", "down",
716 "ESCAPE", "escape",
717 "ctrl F9", "minimize",
718 "ctrl F10", "maximize",
719 "ctrl F6", "selectNextFrame",
720 "ctrl TAB", "selectNextFrame",
721 "ctrl alt F6", "selectNextFrame",
722 "shift ctrl alt F6", "selectPreviousFrame",
723 "ctrl F12", "navigateNext",
724 "shift ctrl F12", "navigatePrevious"
725 }),
726
727 // DesktopIcon
728 "DesktopIcon.width", Integer.valueOf(160),
729
730 "EditorPane.font", ControlFont,
731 "EditorPane.background", WindowBackgroundColor,
732 "EditorPane.foreground", WindowTextColor,
733 "EditorPane.selectionBackground", SelectionBackgroundColor,
734 "EditorPane.selectionForeground", SelectionTextColor,
735 "EditorPane.caretForeground", WindowTextColor,
736 "EditorPane.inactiveForeground", InactiveTextColor,
737 "EditorPane.inactiveBackground", WindowBackgroundColor,
738 "EditorPane.disabledBackground", DisabledTextBackground,
739
740 "FileChooser.homeFolderIcon", new LazyWindowsIcon(null,
741 "icons/HomeFolder.gif"),
742 "FileChooser.listFont", IconFont,
743 "FileChooser.listViewBackground", new XPColorValue(Part.LVP_LISTVIEW, null, Prop.FILLCOLOR,
744 WindowBackgroundColor),
745 "FileChooser.listViewBorder", new XPBorderValue(Part.LVP_LISTVIEW,
746 (LazyValue) t -> BorderUIResource.getLoweredBevelBorderUIResource()),
747 "FileChooser.listViewIcon", new LazyWindowsIcon("fileChooserIcon ListView",
748 "icons/ListView.gif"),
749 "FileChooser.listViewWindowsStyle", Boolean.TRUE,
750 "FileChooser.detailsViewIcon", new LazyWindowsIcon("fileChooserIcon DetailsView",
751 "icons/DetailsView.gif"),
752 "FileChooser.viewMenuIcon", new LazyWindowsIcon("fileChooserIcon ViewMenu",
753 "icons/ListView.gif"),
754 "FileChooser.upFolderIcon", new LazyWindowsIcon("fileChooserIcon UpFolder",
755 "icons/UpFolder.gif"),
756 "FileChooser.newFolderIcon", new LazyWindowsIcon("fileChooserIcon NewFolder",
757 "icons/NewFolder.gif"),
758 "FileChooser.useSystemExtensionHiding", Boolean.TRUE,
759
760 "FileChooser.usesSingleFilePane", Boolean.TRUE,
761 "FileChooser.noPlacesBar", new DesktopProperty("win.comdlg.noPlacesBar",
762 Boolean.FALSE),
763 "FileChooser.ancestorInputMap",
764 new UIDefaults.LazyInputMap(new Object[] {
765 "ESCAPE", "cancelSelection",
766 "F2", "editFileName",
767 "F5", "refresh",
768 "BACK_SPACE", "Go Up"
769 }),
770
771 "FileView.directoryIcon", SwingUtilities2.makeIcon(getClass(),
772 WindowsLookAndFeel.class,
773 "icons/Directory.gif"),
774 "FileView.fileIcon", SwingUtilities2.makeIcon(getClass(),
775 WindowsLookAndFeel.class,
776 "icons/File.gif"),
777 "FileView.computerIcon", SwingUtilities2.makeIcon(getClass(),
778 WindowsLookAndFeel.class,
779 "icons/Computer.gif"),
780 "FileView.hardDriveIcon", SwingUtilities2.makeIcon(getClass(),
781 WindowsLookAndFeel.class,
782 "icons/HardDrive.gif"),
783 "FileView.floppyDriveIcon", SwingUtilities2.makeIcon(getClass(),
784 WindowsLookAndFeel.class,
785 "icons/FloppyDrive.gif"),
786
787 "FormattedTextField.font", ControlFont,
788 "InternalFrame.titleFont", WindowFont,
789 "InternalFrame.titlePaneHeight", TitlePaneHeight,
790 "InternalFrame.titleButtonWidth", TitleButtonWidth,
791 "InternalFrame.titleButtonHeight", TitleButtonHeight,
792 "InternalFrame.titleButtonToolTipsOn", hotTrackingOn,
793 "InternalFrame.borderColor", ControlBackgroundColor,
794 "InternalFrame.borderShadow", ControlShadowColor,
795 "InternalFrame.borderDarkShadow", ControlDarkShadowColor,
796 "InternalFrame.borderHighlight", ControlHighlightColor,
797 "InternalFrame.borderLight", ControlLightColor,
798 "InternalFrame.borderWidth", WindowBorderWidth,
799 "InternalFrame.minimizeIconBackground", ControlBackgroundColor,
800 "InternalFrame.resizeIconHighlight", ControlLightColor,
801 "InternalFrame.resizeIconShadow", ControlShadowColor,
802 "InternalFrame.activeBorderColor", new DesktopProperty(
803 "win.frame.activeBorderColor",
804 table.get("windowBorder")),
805 "InternalFrame.inactiveBorderColor", new DesktopProperty(
806 "win.frame.inactiveBorderColor",
807 table.get("windowBorder")),
808 "InternalFrame.activeTitleBackground", new DesktopProperty(
809 "win.frame.activeCaptionColor",
810 table.get("activeCaption")),
811 "InternalFrame.activeTitleGradient", new DesktopProperty(
812 "win.frame.activeCaptionGradientColor",
813 table.get("activeCaption")),
814 "InternalFrame.activeTitleForeground", new DesktopProperty(
815 "win.frame.captionTextColor",
816 table.get("activeCaptionText")),
817 "InternalFrame.inactiveTitleBackground", new DesktopProperty(
818 "win.frame.inactiveCaptionColor",
819 table.get("inactiveCaption")),
820 "InternalFrame.inactiveTitleGradient", new DesktopProperty(
821 "win.frame.inactiveCaptionGradientColor",
822 table.get("inactiveCaption")),
823 "InternalFrame.inactiveTitleForeground", new DesktopProperty(
824 "win.frame.inactiveCaptionTextColor",
825 table.get("inactiveCaptionText")),
826
827 "InternalFrame.maximizeIcon",
828 WindowsIconFactory.createFrameMaximizeIcon(),
829 "InternalFrame.minimizeIcon",
830 WindowsIconFactory.createFrameMinimizeIcon(),
831 "InternalFrame.iconifyIcon",
832 WindowsIconFactory.createFrameIconifyIcon(),
833 "InternalFrame.closeIcon",
834 WindowsIconFactory.createFrameCloseIcon(),
835 "InternalFrame.icon",
836 (LazyValue) t -> new WindowsInternalFrameTitlePane.ScalableIconUIResource(new Object[]{
837 // The constructor takes one arg: an array of UIDefaults.LazyValue
838 // representing the icons
839 SwingUtilities2.makeIcon(getClass(), BasicLookAndFeel.class, "icons/JavaCup16.png"),
840 SwingUtilities2.makeIcon(getClass(), WindowsLookAndFeel.class, "icons/JavaCup32.png")
841 }),
842 // Internal Frame Auditory Cue Mappings
843 "InternalFrame.closeSound", "win.sound.close",
844 "InternalFrame.maximizeSound", "win.sound.maximize",
845 "InternalFrame.minimizeSound", "win.sound.minimize",
846 "InternalFrame.restoreDownSound", "win.sound.restoreDown",
847 "InternalFrame.restoreUpSound", "win.sound.restoreUp",
848
849 "InternalFrame.windowBindings", new Object[] {
850 "shift ESCAPE", "showSystemMenu",
851 "ctrl SPACE", "showSystemMenu",
852 "ESCAPE", "hideSystemMenu"},
853
854 // Label
855 "Label.font", ControlFont,
856 "Label.background", ControlBackgroundColor,
857 "Label.foreground", WindowTextColor,
858 "Label.disabledForeground", InactiveTextColor,
859 "Label.disabledShadow", ControlHighlightColor,
860
861 // List.
862 "List.font", ControlFont,
863 "List.background", WindowBackgroundColor,
864 "List.foreground", WindowTextColor,
865 "List.selectionBackground", SelectionBackgroundColor,
866 "List.selectionForeground", SelectionTextColor,
867 "List.lockToPositionOnScroll", Boolean.TRUE,
868 "List.focusInputMap",
869 new UIDefaults.LazyInputMap(new Object[] {
870 "ctrl C", "copy",
871 "ctrl V", "paste",
872 "ctrl X", "cut",
873 "COPY", "copy",
874 "PASTE", "paste",
875 "CUT", "cut",
876 "control INSERT", "copy",
877 "shift INSERT", "paste",
878 "shift DELETE", "cut",
879 "UP", "selectPreviousRow",
880 "KP_UP", "selectPreviousRow",
881 "shift UP", "selectPreviousRowExtendSelection",
882 "shift KP_UP", "selectPreviousRowExtendSelection",
883 "ctrl shift UP", "selectPreviousRowExtendSelection",
884 "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
885 "ctrl UP", "selectPreviousRowChangeLead",
886 "ctrl KP_UP", "selectPreviousRowChangeLead",
887 "DOWN", "selectNextRow",
888 "KP_DOWN", "selectNextRow",
889 "shift DOWN", "selectNextRowExtendSelection",
890 "shift KP_DOWN", "selectNextRowExtendSelection",
891 "ctrl shift DOWN", "selectNextRowExtendSelection",
892 "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
893 "ctrl DOWN", "selectNextRowChangeLead",
894 "ctrl KP_DOWN", "selectNextRowChangeLead",
895 "LEFT", "selectPreviousColumn",
896 "KP_LEFT", "selectPreviousColumn",
897 "shift LEFT", "selectPreviousColumnExtendSelection",
898 "shift KP_LEFT", "selectPreviousColumnExtendSelection",
899 "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
900 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
901 "ctrl LEFT", "selectPreviousColumnChangeLead",
902 "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
903 "RIGHT", "selectNextColumn",
904 "KP_RIGHT", "selectNextColumn",
905 "shift RIGHT", "selectNextColumnExtendSelection",
906 "shift KP_RIGHT", "selectNextColumnExtendSelection",
907 "ctrl shift RIGHT", "selectNextColumnExtendSelection",
908 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
909 "ctrl RIGHT", "selectNextColumnChangeLead",
910 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
911 "HOME", "selectFirstRow",
912 "shift HOME", "selectFirstRowExtendSelection",
913 "ctrl shift HOME", "selectFirstRowExtendSelection",
914 "ctrl HOME", "selectFirstRowChangeLead",
915 "END", "selectLastRow",
916 "shift END", "selectLastRowExtendSelection",
917 "ctrl shift END", "selectLastRowExtendSelection",
918 "ctrl END", "selectLastRowChangeLead",
919 "PAGE_UP", "scrollUp",
920 "shift PAGE_UP", "scrollUpExtendSelection",
921 "ctrl shift PAGE_UP", "scrollUpExtendSelection",
922 "ctrl PAGE_UP", "scrollUpChangeLead",
923 "PAGE_DOWN", "scrollDown",
924 "shift PAGE_DOWN", "scrollDownExtendSelection",
925 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
926 "ctrl PAGE_DOWN", "scrollDownChangeLead",
927 "ctrl A", "selectAll",
928 "ctrl SLASH", "selectAll",
929 "ctrl BACK_SLASH", "clearSelection",
930 "SPACE", "addToSelection",
931 "ctrl SPACE", "toggleAndAnchor",
932 "shift SPACE", "extendTo",
933 "ctrl shift SPACE", "moveSelectionTo"
934 }),
935
936 // PopupMenu
937 "PopupMenu.font", MenuFont,
938 "PopupMenu.background", MenuBackgroundColor,
939 "PopupMenu.foreground", MenuTextColor,
940 "PopupMenu.popupSound", "win.sound.menuPopup",
941 "PopupMenu.consumeEventOnClose", Boolean.TRUE,
942
943 // Menus
944 "Menu.font", MenuFont,
945 "Menu.foreground", MenuTextColor,
946 "Menu.background", MenuBackgroundColor,
947 "Menu.useMenuBarBackgroundForTopLevel", Boolean.TRUE,
948 "Menu.selectionForeground", SelectionTextColor,
949 "Menu.selectionBackground", SelectionBackgroundColor,
950 "Menu.acceleratorForeground", MenuTextColor,
951 "Menu.acceleratorSelectionForeground", SelectionTextColor,
952 "Menu.menuPopupOffsetX", Integer.valueOf(0),
953 "Menu.menuPopupOffsetY", Integer.valueOf(0),
954 "Menu.submenuPopupOffsetX", Integer.valueOf(-4),
955 "Menu.submenuPopupOffsetY", Integer.valueOf(-3),
956 "Menu.crossMenuMnemonic", Boolean.FALSE,
957 "Menu.preserveTopLevelSelection", Boolean.TRUE,
958
959 // MenuBar.
960 "MenuBar.font", MenuFont,
961 "MenuBar.background", new XPValue(MenuBarBackgroundColor,
962 MenuBackgroundColor),
963 "MenuBar.foreground", MenuTextColor,
964 "MenuBar.shadow", ControlShadowColor,
965 "MenuBar.highlight", ControlHighlightColor,
966 "MenuBar.height", menuBarHeight,
967 "MenuBar.rolloverEnabled", hotTrackingOn,
968 "MenuBar.windowBindings", new Object[] {
969 "F10", "takeFocus" },
970
971 "MenuItem.font", MenuFont,
972 "MenuItem.acceleratorFont", MenuFont,
973 "MenuItem.foreground", MenuTextColor,
974 "MenuItem.background", MenuBackgroundColor,
975 "MenuItem.selectionForeground", SelectionTextColor,
976 "MenuItem.selectionBackground", SelectionBackgroundColor,
977 "MenuItem.disabledForeground", InactiveTextColor,
978 "MenuItem.acceleratorForeground", MenuTextColor,
979 "MenuItem.acceleratorSelectionForeground", SelectionTextColor,
980 "MenuItem.acceleratorDelimiter", menuItemAcceleratorDelimiter,
981 // Menu Item Auditory Cue Mapping
982 "MenuItem.commandSound", "win.sound.menuCommand",
983 // indicates that keyboard navigation won't skip disabled menu items
984 "MenuItem.disabledAreNavigable", Boolean.TRUE,
985
986 "RadioButton.font", ControlFont,
987 "RadioButton.interiorBackground", WindowBackgroundColor,
988 "RadioButton.background", ControlBackgroundColor,
989 "RadioButton.foreground", WindowTextColor,
990 "RadioButton.shadow", ControlShadowColor,
991 "RadioButton.darkShadow", ControlDarkShadowColor,
992 "RadioButton.light", ControlLightColor,
993 "RadioButton.highlight", ControlHighlightColor,
994 "RadioButton.focus", buttonFocusColor,
995 "RadioButton.focusInputMap",
996 new UIDefaults.LazyInputMap(new Object[] {
997 "SPACE", "pressed",
998 "released SPACE", "released"
999 }),
1000 // margin is 2 all the way around, BasicBorders.RadioButtonBorder
1001 // is 2 all the way around too.
1002 "RadioButton.totalInsets", new Insets(4, 4, 4, 4),
1003
1004
1005 "RadioButtonMenuItem.font", MenuFont,
1006 "RadioButtonMenuItem.foreground", MenuTextColor,
1007 "RadioButtonMenuItem.background", MenuBackgroundColor,
1008 "RadioButtonMenuItem.selectionForeground", SelectionTextColor,
1009 "RadioButtonMenuItem.selectionBackground", SelectionBackgroundColor,
1010 "RadioButtonMenuItem.disabledForeground", InactiveTextColor,
1011 "RadioButtonMenuItem.acceleratorForeground", MenuTextColor,
1012 "RadioButtonMenuItem.acceleratorSelectionForeground", SelectionTextColor,
1013 "RadioButtonMenuItem.commandSound", "win.sound.menuCommand",
1014
1015 // OptionPane.
1016 "OptionPane.font", MessageFont,
1017 "OptionPane.messageFont", MessageFont,
1018 "OptionPane.buttonFont", MessageFont,
1019 "OptionPane.background", ControlBackgroundColor,
1020 "OptionPane.foreground", WindowTextColor,
1021 "OptionPane.buttonMinimumWidth", new XPDLUValue(50, 50, SwingConstants.EAST),
1022 "OptionPane.messageForeground", ControlTextColor,
1023 "OptionPane.errorIcon", new LazyWindowsIcon("optionPaneIcon Error",
1024 "icons/Error.gif"),
1025 "OptionPane.informationIcon", new LazyWindowsIcon("optionPaneIcon Information",
1026 "icons/Inform.gif"),
1027 "OptionPane.questionIcon", new LazyWindowsIcon("optionPaneIcon Question",
1028 "icons/Question.gif"),
1029 "OptionPane.warningIcon", new LazyWindowsIcon("optionPaneIcon Warning",
1030 "icons/Warn.gif"),
1031 "OptionPane.windowBindings", new Object[] {
1032 "ESCAPE", "close" },
1033 // Option Pane Auditory Cue Mappings
1034 "OptionPane.errorSound", "win.sound.hand", // Error
1035 "OptionPane.informationSound", "win.sound.asterisk", // Info Plain
1036 "OptionPane.questionSound", "win.sound.question", // Question
1037 "OptionPane.warningSound", "win.sound.exclamation", // Warning
1038
1039 "FormattedTextField.focusInputMap",
1040 new UIDefaults.LazyInputMap(new Object[] {
1041 "ctrl C", DefaultEditorKit.copyAction,
1042 "ctrl V", DefaultEditorKit.pasteAction,
1043 "ctrl X", DefaultEditorKit.cutAction,
1044 "COPY", DefaultEditorKit.copyAction,
1045 "PASTE", DefaultEditorKit.pasteAction,
1046 "CUT", DefaultEditorKit.cutAction,
1047 "control INSERT", DefaultEditorKit.copyAction,
1048 "shift INSERT", DefaultEditorKit.pasteAction,
1049 "shift DELETE", DefaultEditorKit.cutAction,
1050 "shift LEFT", DefaultEditorKit.selectionBackwardAction,
1051 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
1052 "shift RIGHT", DefaultEditorKit.selectionForwardAction,
1053 "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
1054 "ctrl LEFT", DefaultEditorKit.previousWordAction,
1055 "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
1056 "ctrl RIGHT", DefaultEditorKit.nextWordAction,
1057 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
1058 "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
1059 "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
1060 "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
1061 "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
1062 "ctrl A", DefaultEditorKit.selectAllAction,
1063 "HOME", DefaultEditorKit.beginLineAction,
1064 "END", DefaultEditorKit.endLineAction,
1065 "shift HOME", DefaultEditorKit.selectionBeginLineAction,
1066 "shift END", DefaultEditorKit.selectionEndLineAction,
1067 "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1068 "shift BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
1069 "ctrl H", DefaultEditorKit.deletePrevCharAction,
1070 "DELETE", DefaultEditorKit.deleteNextCharAction,
1071 "ctrl DELETE", DefaultEditorKit.deleteNextWordAction,
1072 "ctrl BACK_SPACE", DefaultEditorKit.deletePrevWordAction,
1073 "RIGHT", DefaultEditorKit.forwardAction,
1074 "LEFT", DefaultEditorKit.backwardAction,
1075 "KP_RIGHT", DefaultEditorKit.forwardAction,
1076 "KP_LEFT", DefaultEditorKit.backwardAction,
1077 "ENTER", JTextField.notifyAction,
1078 "ctrl BACK_SLASH", "unselect",
1079 "control shift O", "toggle-componentOrientation",
1080 "ESCAPE", "reset-field-edit",
1081 "UP", "increment",
1082 "KP_UP", "increment",
1083 "DOWN", "decrement",
1084 "KP_DOWN", "decrement",
1085 }),
1086 "FormattedTextField.inactiveBackground", ReadOnlyTextBackground,
1087 "FormattedTextField.disabledBackground", DisabledTextBackground,
1088 "FormattedTextField.background", TextBackground,
1089 "FormattedTextField.foreground", WindowTextColor,
1090
1091 // *** Panel
1092 "Panel.font", ControlFont,
1093 "Panel.background", ControlBackgroundColor,
1094 "Panel.foreground", WindowTextColor,
1095
1096 // *** PasswordField
1097 "PasswordField.font", ControlFont,
1098 "PasswordField.background", TextBackground,
1099 "PasswordField.foreground", WindowTextColor,
1100 "PasswordField.inactiveForeground", InactiveTextColor, // for disabled
1101 "PasswordField.inactiveBackground", ReadOnlyTextBackground, // for readonly
1102 "PasswordField.disabledBackground", DisabledTextBackground, // for disabled
1103 "PasswordField.selectionBackground", SelectionBackgroundColor,
1104 "PasswordField.selectionForeground", SelectionTextColor,
1105 "PasswordField.caretForeground",WindowTextColor,
1106 "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
1107
1108 // *** ProgressBar
1109 "ProgressBar.font", ControlFont,
1110 "ProgressBar.foreground", SelectionBackgroundColor,
1111 "ProgressBar.background", ControlBackgroundColor,
1112 "ProgressBar.shadow", ControlShadowColor,
1113 "ProgressBar.highlight", ControlHighlightColor,
1114 "ProgressBar.selectionForeground", ControlBackgroundColor,
1115 "ProgressBar.selectionBackground", SelectionBackgroundColor,
1116 "ProgressBar.cellLength", Integer.valueOf(7),
1117 "ProgressBar.cellSpacing", Integer.valueOf(2),
1118 "ProgressBar.indeterminateInsets", new Insets(3, 3, 3, 3),
1119
1120 // *** RootPane.
1121 // These bindings are only enabled when there is a default
1122 // button set on the rootpane.
1123 "RootPane.defaultButtonWindowKeyBindings", new Object[] {
1124 "ENTER", "press",
1125 "released ENTER", "release",
1126 "ctrl ENTER", "press",
1127 "ctrl released ENTER", "release"
1128 },
1129
1130 // *** ScrollBar.
1131 "ScrollBar.background", ScrollbarBackgroundColor,
1132 "ScrollBar.foreground", ControlBackgroundColor,
1133 "ScrollBar.track", white,
1134 "ScrollBar.trackForeground", ScrollbarBackgroundColor,
1135 "ScrollBar.trackHighlight", black,
1136 "ScrollBar.trackHighlightForeground", scrollBarTrackHighlight,
1137 "ScrollBar.thumb", ControlBackgroundColor,
1138 "ScrollBar.thumbHighlight", ControlHighlightColor,
1139 "ScrollBar.thumbDarkShadow", ControlDarkShadowColor,
1140 "ScrollBar.thumbShadow", ControlShadowColor,
1141 "ScrollBar.width", scrollBarWidth,
1142 "ScrollBar.ancestorInputMap",
1143 new UIDefaults.LazyInputMap(new Object[] {
1144 "RIGHT", "positiveUnitIncrement",
1145 "KP_RIGHT", "positiveUnitIncrement",
1146 "DOWN", "positiveUnitIncrement",
1147 "KP_DOWN", "positiveUnitIncrement",
1148 "PAGE_DOWN", "positiveBlockIncrement",
1149 "ctrl PAGE_DOWN", "positiveBlockIncrement",
1150 "LEFT", "negativeUnitIncrement",
1151 "KP_LEFT", "negativeUnitIncrement",
1152 "UP", "negativeUnitIncrement",
1153 "KP_UP", "negativeUnitIncrement",
1154 "PAGE_UP", "negativeBlockIncrement",
1155 "ctrl PAGE_UP", "negativeBlockIncrement",
1156 "HOME", "minScroll",
1157 "END", "maxScroll"
1158 }),
1159
1160 // *** ScrollPane.
1161 "ScrollPane.font", ControlFont,
1162 "ScrollPane.background", ControlBackgroundColor,
1163 "ScrollPane.foreground", ControlTextColor,
1164 "ScrollPane.ancestorInputMap",
1165 new UIDefaults.LazyInputMap(new Object[] {
1166 "RIGHT", "unitScrollRight",
1167 "KP_RIGHT", "unitScrollRight",
1168 "DOWN", "unitScrollDown",
1169 "KP_DOWN", "unitScrollDown",
1170 "LEFT", "unitScrollLeft",
1171 "KP_LEFT", "unitScrollLeft",
1172 "UP", "unitScrollUp",
1173 "KP_UP", "unitScrollUp",
1174 "PAGE_UP", "scrollUp",
1175 "PAGE_DOWN", "scrollDown",
1176 "ctrl PAGE_UP", "scrollLeft",
1177 "ctrl PAGE_DOWN", "scrollRight",
1178 "ctrl HOME", "scrollHome",
1179 "ctrl END", "scrollEnd"
1180 }),
1181
1182 // *** Separator
1183 "Separator.background", ControlHighlightColor,
1184 "Separator.foreground", ControlShadowColor,
1185
1186 // *** Slider.
1187 "Slider.font", ControlFont,
1188 "Slider.foreground", ControlBackgroundColor,
1189 "Slider.background", ControlBackgroundColor,
1190 "Slider.highlight", ControlHighlightColor,
1191 "Slider.shadow", ControlShadowColor,
1192 "Slider.focus", ControlDarkShadowColor,
1193 "Slider.focusInputMap",
1194 new UIDefaults.LazyInputMap(new Object[] {
1195 "RIGHT", "positiveUnitIncrement",
1196 "KP_RIGHT", "positiveUnitIncrement",
1197 "DOWN", "negativeUnitIncrement",
1198 "KP_DOWN", "negativeUnitIncrement",
1199 "PAGE_DOWN", "negativeBlockIncrement",
1200 "LEFT", "negativeUnitIncrement",
1201 "KP_LEFT", "negativeUnitIncrement",
1202 "UP", "positiveUnitIncrement",
1203 "KP_UP", "positiveUnitIncrement",
1204 "PAGE_UP", "positiveBlockIncrement",
1205 "HOME", "minScroll",
1206 "END", "maxScroll"
1207 }),
1208
1209 // Spinner
1210 "Spinner.font", ControlFont,
1211 "Spinner.ancestorInputMap",
1212 new UIDefaults.LazyInputMap(new Object[] {
1213 "UP", "increment",
1214 "KP_UP", "increment",
1215 "DOWN", "decrement",
1216 "KP_DOWN", "decrement",
1217 }),
1218
1219 // *** SplitPane
1220 "SplitPane.background", ControlBackgroundColor,
1221 "SplitPane.highlight", ControlHighlightColor,
1222 "SplitPane.shadow", ControlShadowColor,
1223 "SplitPane.darkShadow", ControlDarkShadowColor,
1224 "SplitPane.dividerSize", Integer.valueOf(5),
1225 "SplitPane.ancestorInputMap",
1226 new UIDefaults.LazyInputMap(new Object[] {
1227 "UP", "negativeIncrement",
1228 "DOWN", "positiveIncrement",
1229 "LEFT", "negativeIncrement",
1230 "RIGHT", "positiveIncrement",
1231 "KP_UP", "negativeIncrement",
1232 "KP_DOWN", "positiveIncrement",
1233 "KP_LEFT", "negativeIncrement",
1234 "KP_RIGHT", "positiveIncrement",
1235 "HOME", "selectMin",
1236 "END", "selectMax",
1237 "F8", "startResize",
1238 "F6", "toggleFocus",
1239 "ctrl TAB", "focusOutForward",
1240 "ctrl shift TAB", "focusOutBackward"
1241 }),
1242
1243 // *** TabbedPane
1244 "TabbedPane.tabsOverlapBorder", new XPValue(Boolean.TRUE, Boolean.FALSE),
1245 "TabbedPane.tabInsets", new XPValue(new InsetsUIResource(1, 4, 1, 4),
1246 new InsetsUIResource(0, 4, 1, 4)),
1247 "TabbedPane.tabAreaInsets", new XPValue(new InsetsUIResource(3, 2, 2, 2),
1248 new InsetsUIResource(3, 2, 0, 2)),
1249 "TabbedPane.font", ControlFont,
1250 "TabbedPane.background", ControlBackgroundColor,
1251 "TabbedPane.foreground", ControlTextColor,
1252 "TabbedPane.highlight", ControlHighlightColor,
1253 "TabbedPane.light", ControlLightColor,
1254 "TabbedPane.shadow", ControlShadowColor,
1255 "TabbedPane.darkShadow", ControlDarkShadowColor,
1256 "TabbedPane.focus", ControlTextColor,
1257 "TabbedPane.focusInputMap",
1258 new UIDefaults.LazyInputMap(new Object[] {
1259 "RIGHT", "navigateRight",
1260 "KP_RIGHT", "navigateRight",
1261 "LEFT", "navigateLeft",
1262 "KP_LEFT", "navigateLeft",
1263 "UP", "navigateUp",
1264 "KP_UP", "navigateUp",
1265 "DOWN", "navigateDown",
1266 "KP_DOWN", "navigateDown",
1267 "ctrl DOWN", "requestFocusForVisibleComponent",
1268 "ctrl KP_DOWN", "requestFocusForVisibleComponent",
1269 }),
1270 "TabbedPane.ancestorInputMap",
1271 new UIDefaults.LazyInputMap(new Object[] {
1272 "ctrl TAB", "navigateNext",
1273 "ctrl shift TAB", "navigatePrevious",
1274 "ctrl PAGE_DOWN", "navigatePageDown",
1275 "ctrl PAGE_UP", "navigatePageUp",
1276 "ctrl UP", "requestFocus",
1277 "ctrl KP_UP", "requestFocus",
1278 }),
1279
1280 // *** Table
1281 "Table.font", ControlFont,
1282 "Table.foreground", ControlTextColor, // cell text color
1283 "Table.background", WindowBackgroundColor, // cell background color
1284 "Table.highlight", ControlHighlightColor,
1285 "Table.light", ControlLightColor,
1286 "Table.shadow", ControlShadowColor,
1287 "Table.darkShadow", ControlDarkShadowColor,
1288 "Table.selectionForeground", SelectionTextColor,
1289 "Table.selectionBackground", SelectionBackgroundColor,
1290 "Table.gridColor", gray, // grid line color
1291 "Table.focusCellBackground", WindowBackgroundColor,
1292 "Table.focusCellForeground", ControlTextColor,
1293 "Table.ancestorInputMap",
1294 new UIDefaults.LazyInputMap(new Object[] {
1295 "ctrl C", "copy",
1296 "ctrl V", "paste",
1297 "ctrl X", "cut",
1298 "COPY", "copy",
1299 "PASTE", "paste",
1300 "CUT", "cut",
1301 "control INSERT", "copy",
1302 "shift INSERT", "paste",
1303 "shift DELETE", "cut",
1304 "RIGHT", "selectNextColumn",
1305 "KP_RIGHT", "selectNextColumn",
1306 "shift RIGHT", "selectNextColumnExtendSelection",
1307 "shift KP_RIGHT", "selectNextColumnExtendSelection",
1308 "ctrl shift RIGHT", "selectNextColumnExtendSelection",
1309 "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
1310 "ctrl RIGHT", "selectNextColumnChangeLead",
1311 "ctrl KP_RIGHT", "selectNextColumnChangeLead",
1312 "LEFT", "selectPreviousColumn",
1313 "KP_LEFT", "selectPreviousColumn",
1314 "shift LEFT", "selectPreviousColumnExtendSelection",
1315 "shift KP_LEFT", "selectPreviousColumnExtendSelection",
1316 "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
1317 "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
1318 "ctrl LEFT", "selectPreviousColumnChangeLead",
1319 "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
1320 "DOWN", "selectNextRow",
1321 "KP_DOWN", "selectNextRow",
1322 "shift DOWN", "selectNextRowExtendSelection",
1323 "shift KP_DOWN", "selectNextRowExtendSelection",
1324 "ctrl shift DOWN", "selectNextRowExtendSelection",
1325 "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
1326 "ctrl DOWN", "selectNextRowChangeLead",
1327 "ctrl KP_DOWN", "selectNextRowChangeLead",
1328 "UP", "selectPreviousRow",
1329 "KP_UP", "selectPreviousRow",
1330 "shift UP", "selectPreviousRowExtendSelection",
1331 "shift KP_UP", "selectPreviousRowExtendSelection",
1332 "ctrl shift UP", "selectPreviousRowExtendSelection",
1333 "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
1334 "ctrl UP", "selectPreviousRowChangeLead",
1335 "ctrl KP_UP", "selectPreviousRowChangeLead",
1336 "HOME", "selectFirstColumn",
1337 "shift HOME", "selectFirstColumnExtendSelection",
1338 "ctrl shift HOME", "selectFirstRowExtendSelection",
1339 "ctrl HOME", "selectFirstRow",
1340 "END", "selectLastColumn",
1341 "shift END", "selectLastColumnExtendSelection",
1342 "ctrl shift END", "selectLastRowExtendSelection",
1343 "ctrl END", "selectLastRow",
1344 "PAGE_UP", "scrollUpChangeSelection",
1345 "shift PAGE_UP", "scrollUpExtendSelection",
1346 "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
1347 "ctrl PAGE_UP", "scrollLeftChangeSelection",
1348 "PAGE_DOWN", "scrollDownChangeSelection",
1349 "shift PAGE_DOWN", "scrollDownExtendSelection",
1350 "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
1351 "ctrl PAGE_DOWN", "scrollRightChangeSelection",
1352 "TAB", "selectNextColumnCell",
1353 "shift TAB", "selectPreviousColumnCell",
1354 "ENTER", "selectNextRowCell",
1355 "shift ENTER", "selectPreviousRowCell",
1356 "ctrl A", "selectAll",
1357 "ctrl SLASH", "selectAll",
1358 "ctrl BACK_SLASH", "clearSelection",
1359 "ESCAPE", "cancel",
1360 "F2", "startEditing",
1361 "SPACE", "addToSelection",
1362 "ctrl SPACE", "toggleAndAnchor",
1363 "shift SPACE", "extendTo",
1364 "ctrl shift SPACE", "moveSelectionTo",
1365 "F8", "focusHeader"
1366 }),
1367 "Table.sortIconHighlight", ControlShadowColor,
1368 "Table.sortIconLight", white,
1369
1370 "TableHeader.font", ControlFont,
1371 "TableHeader.foreground", ControlTextColor, // header text color
1372 "TableHeader.background", ControlBackgroundColor, // header background
1373 "TableHeader.focusCellBackground",
1374 new XPValue(XPValue.NULL_VALUE, // use default bg from XP styles
1375 WindowBackgroundColor), // or white bg otherwise
1376
1377 // *** TextArea
1378 "TextArea.font", FixedControlFont,
1379 "TextArea.background", WindowBackgroundColor,
1380 "TextArea.foreground", WindowTextColor,
1381 "TextArea.inactiveForeground", InactiveTextColor,
1382 "TextArea.inactiveBackground", WindowBackgroundColor,
1383 "TextArea.disabledBackground", DisabledTextBackground,
1384 "TextArea.selectionBackground", SelectionBackgroundColor,
1385 "TextArea.selectionForeground", SelectionTextColor,
1386 "TextArea.caretForeground", WindowTextColor,
1387
1388 // *** TextField
1389 "TextField.font", ControlFont,
1390 "TextField.background", TextBackground,
1391 "TextField.foreground", WindowTextColor,
1392 "TextField.shadow", ControlShadowColor,
1393 "TextField.darkShadow", ControlDarkShadowColor,
1394 "TextField.light", ControlLightColor,
1395 "TextField.highlight", ControlHighlightColor,
1396 "TextField.inactiveForeground", InactiveTextColor, // for disabled
1397 "TextField.inactiveBackground", ReadOnlyTextBackground, // for readonly
1398 "TextField.disabledBackground", DisabledTextBackground, // for disabled
1399 "TextField.selectionBackground", SelectionBackgroundColor,
1400 "TextField.selectionForeground", SelectionTextColor,
1401 "TextField.caretForeground", WindowTextColor,
1402
1403 // *** TextPane
1404 "TextPane.font", ControlFont,
1405 "TextPane.background", WindowBackgroundColor,
1406 "TextPane.foreground", WindowTextColor,
1407 "TextPane.selectionBackground", SelectionBackgroundColor,
1408 "TextPane.selectionForeground", SelectionTextColor,
1409 "TextPane.inactiveBackground", WindowBackgroundColor,
1410 "TextPane.disabledBackground", DisabledTextBackground,
1411 "TextPane.caretForeground", WindowTextColor,
1412
1413 // *** TitledBorder
1414 "TitledBorder.font", ControlFont,
1415 "TitledBorder.titleColor",
1416 new XPColorValue(Part.BP_GROUPBOX, null, Prop.TEXTCOLOR,
1417 WindowTextColor),
1418
1419 // *** ToggleButton
1420 "ToggleButton.font", ControlFont,
1421 "ToggleButton.background", ControlBackgroundColor,
1422 "ToggleButton.foreground", ControlTextColor,
1423 "ToggleButton.shadow", ControlShadowColor,
1424 "ToggleButton.darkShadow", ControlDarkShadowColor,
1425 "ToggleButton.light", ControlLightColor,
1426 "ToggleButton.highlight", ControlHighlightColor,
1427 "ToggleButton.focus", ControlTextColor,
1428 "ToggleButton.textShiftOffset", Integer.valueOf(1),
1429 "ToggleButton.focusInputMap",
1430 new UIDefaults.LazyInputMap(new Object[] {
1431 "SPACE", "pressed",
1432 "released SPACE", "released"
1433 }),
1434
1435 // *** ToolBar
1436 "ToolBar.font", MenuFont,
1437 "ToolBar.background", ControlBackgroundColor,
1438 "ToolBar.foreground", ControlTextColor,
1439 "ToolBar.shadow", ControlShadowColor,
1440 "ToolBar.darkShadow", ControlDarkShadowColor,
1441 "ToolBar.light", ControlLightColor,
1442 "ToolBar.highlight", ControlHighlightColor,
1443 "ToolBar.dockingBackground", ControlBackgroundColor,
1444 "ToolBar.dockingForeground", red,
1445 "ToolBar.floatingBackground", ControlBackgroundColor,
1446 "ToolBar.floatingForeground", darkGray,
1447 "ToolBar.ancestorInputMap",
1448 new UIDefaults.LazyInputMap(new Object[] {
1449 "UP", "navigateUp",
1450 "KP_UP", "navigateUp",
1451 "DOWN", "navigateDown",
1452 "KP_DOWN", "navigateDown",
1453 "LEFT", "navigateLeft",
1454 "KP_LEFT", "navigateLeft",
1455 "RIGHT", "navigateRight",
1456 "KP_RIGHT", "navigateRight"
1457 }),
1458 "ToolBar.separatorSize", null,
1459
1460 // *** ToolTip
1461 "ToolTip.font", ToolTipFont,
1462 "ToolTip.background", new DesktopProperty("win.tooltip.backgroundColor", table.get("info")),
1463 "ToolTip.foreground", new DesktopProperty("win.tooltip.textColor", table.get("infoText")),
1464
1465 // *** ToolTipManager
1466 "ToolTipManager.enableToolTipMode", "activeApplication",
1467
1468 // *** Tree
1469 "Tree.selectionBorderColor", black,
1470 "Tree.drawDashedFocusIndicator", Boolean.TRUE,
1471 "Tree.lineTypeDashed", Boolean.TRUE,
1472 "Tree.font", ControlFont,
1473 "Tree.background", WindowBackgroundColor,
1474 "Tree.foreground", WindowTextColor,
1475 "Tree.hash", gray,
1476 "Tree.leftChildIndent", Integer.valueOf(8),
1477 "Tree.rightChildIndent", Integer.valueOf(11),
1478 "Tree.textForeground", WindowTextColor,
1479 "Tree.textBackground", WindowBackgroundColor,
1480 "Tree.selectionForeground", SelectionTextColor,
1481 "Tree.selectionBackground", SelectionBackgroundColor,
1482 "Tree.expandedIcon", treeExpandedIcon,
1483 "Tree.collapsedIcon", treeCollapsedIcon,
1484 "Tree.openIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
1485 "shell32Icon 5", "icons/TreeOpen.gif"),
1486 "Tree.closedIcon", new ActiveWindowsIcon("win.icon.shellIconBPP",
1487 "shell32Icon 4", "icons/TreeClosed.gif"),
1488 "Tree.focusInputMap",
1489 new UIDefaults.LazyInputMap(new Object[] {
1490 "ADD", "expand",
1491 "SUBTRACT", "collapse",
1492 "ctrl C", "copy",
1493 "ctrl V", "paste",
1494 "ctrl X", "cut",
1495 "COPY", "copy",
1496 "PASTE", "paste",
1497 "CUT", "cut",
1498 "control INSERT", "copy",
1499 "shift INSERT", "paste",
1500 "shift DELETE", "cut",
1501 "UP", "selectPrevious",
1502 "KP_UP", "selectPrevious",
1503 "shift UP", "selectPreviousExtendSelection",
1504 "shift KP_UP", "selectPreviousExtendSelection",
1505 "ctrl shift UP", "selectPreviousExtendSelection",
1506 "ctrl shift KP_UP", "selectPreviousExtendSelection",
1507 "ctrl UP", "selectPreviousChangeLead",
1508 "ctrl KP_UP", "selectPreviousChangeLead",
1509 "DOWN", "selectNext",
1510 "KP_DOWN", "selectNext",
1511 "shift DOWN", "selectNextExtendSelection",
1512 "shift KP_DOWN", "selectNextExtendSelection",
1513 "ctrl shift DOWN", "selectNextExtendSelection",
1514 "ctrl shift KP_DOWN", "selectNextExtendSelection",
1515 "ctrl DOWN", "selectNextChangeLead",
1516 "ctrl KP_DOWN", "selectNextChangeLead",
1517 "RIGHT", "selectChild",
1518 "KP_RIGHT", "selectChild",
1519 "LEFT", "selectParent",
1520 "KP_LEFT", "selectParent",
1521 "PAGE_UP", "scrollUpChangeSelection",
1522 "shift PAGE_UP", "scrollUpExtendSelection",
1523 "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1524 "ctrl PAGE_UP", "scrollUpChangeLead",
1525 "PAGE_DOWN", "scrollDownChangeSelection",
1526 "shift PAGE_DOWN", "scrollDownExtendSelection",
1527 "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1528 "ctrl PAGE_DOWN", "scrollDownChangeLead",
1529 "HOME", "selectFirst",
1530 "shift HOME", "selectFirstExtendSelection",
1531 "ctrl shift HOME", "selectFirstExtendSelection",
1532 "ctrl HOME", "selectFirstChangeLead",
1533 "END", "selectLast",
1534 "shift END", "selectLastExtendSelection",
1535 "ctrl shift END", "selectLastExtendSelection",
1536 "ctrl END", "selectLastChangeLead",
1537 "F2", "startEditing",
1538 "ctrl A", "selectAll",
1539 "ctrl SLASH", "selectAll",
1540 "ctrl BACK_SLASH", "clearSelection",
1541 "ctrl LEFT", "scrollLeft",
1542 "ctrl KP_LEFT", "scrollLeft",
1543 "ctrl RIGHT", "scrollRight",
1544 "ctrl KP_RIGHT", "scrollRight",
1545 "SPACE", "addToSelection",
1546 "ctrl SPACE", "toggleAndAnchor",
1547 "shift SPACE", "extendTo",
1548 "ctrl shift SPACE", "moveSelectionTo"
1549 }),
1550 "Tree.ancestorInputMap",
1551 new UIDefaults.LazyInputMap(new Object[] {
1552 "ESCAPE", "cancel"
1553 }),
1554
1555 // *** Viewport
1556 "Viewport.font", ControlFont,
1557 "Viewport.background", ControlBackgroundColor,
1558 "Viewport.foreground", WindowTextColor,
1559
1560
1561 };
1562
1563 table.putDefaults(defaults);
1564 table.putDefaults(getLazyValueDefaults());
1565 initVistaComponentDefaults(table);
1566 }
1567
1568 static boolean isOnVista() {
1569 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
1570 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_VISTA) >= 0;
1571 }
1572
1573 static boolean isOnWindows7() {
1574 return OSInfo.getOSType() == OSInfo.OSType.WINDOWS
1575 && OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_7) >= 0;
1576 }
1577
1578 private void initVistaComponentDefaults(UIDefaults table) {
1579 if (! isOnVista()) {
1580 return;
1581 }
1582 /* START handling menus for Vista */
1583 String[] menuClasses = { "MenuItem", "Menu",
1584 "CheckBoxMenuItem", "RadioButtonMenuItem",
1585 };
1586
1587 Object menuDefaults[] = new Object[menuClasses.length * 2];
1588
1589 /* all the menus need to be non opaque. */
1590 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1591 String key = menuClasses[i] + ".opaque";
1592 Object oldValue = table.get(key);
1593 menuDefaults[j++] = key;
1594 menuDefaults[j++] =
1595 new XPValue(Boolean.FALSE, oldValue);
1596 }
1597 table.putDefaults(menuDefaults);
1598
1599 /*
1600 * acceleratorSelectionForeground color is the same as
1601 * acceleratorForeground
1602 */
1603 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1604 String key = menuClasses[i] + ".acceleratorSelectionForeground";
1605 Object oldValue = table.get(key);
1606 menuDefaults[j++] = key;
1607 menuDefaults[j++] =
1608 new XPValue(
1609 table.getColor(
1610 menuClasses[i] + ".acceleratorForeground"),
1611 oldValue);
1612 }
1613 table.putDefaults(menuDefaults);
1614
1615 /* they have the same MenuItemCheckIconFactory */
1616 VistaMenuItemCheckIconFactory menuItemCheckIconFactory =
1617 WindowsIconFactory.getMenuItemCheckIconFactory();
1618 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1619 String key = menuClasses[i] + ".checkIconFactory";
1620 Object oldValue = table.get(key);
1621 menuDefaults[j++] = key;
1622 menuDefaults[j++] =
1623 new XPValue(menuItemCheckIconFactory, oldValue);
1624 }
1625 table.putDefaults(menuDefaults);
1626
1627 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1628 String key = menuClasses[i] + ".checkIcon";
1629 Object oldValue = table.get(key);
1630 menuDefaults[j++] = key;
1631 menuDefaults[j++] =
1632 new XPValue(menuItemCheckIconFactory.getIcon(menuClasses[i]),
1633 oldValue);
1634 }
1635 table.putDefaults(menuDefaults);
1636
1637
1638 /* height can be even */
1639 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1640 String key = menuClasses[i] + ".evenHeight";
1641 Object oldValue = table.get(key);
1642 menuDefaults[j++] = key;
1643 menuDefaults[j++] = new XPValue(Boolean.TRUE, oldValue);
1644 }
1645 table.putDefaults(menuDefaults);
1646
1647 /*For Windows7 margin and checkIconOffset should be greater than 0 */
1648 if (!isOnWindows7()) {
1649 /* no margins */
1650 InsetsUIResource insets = new InsetsUIResource(0, 0, 0, 0);
1651 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1652 String key = menuClasses[i] + ".margin";
1653 Object oldValue = table.get(key);
1654 menuDefaults[j++] = key;
1655 menuDefaults[j++] = new XPValue(insets, oldValue);
1656 }
1657 table.putDefaults(menuDefaults);
1658
1659 /* set checkIcon offset */
1660 Integer checkIconOffsetInteger =
1661 Integer.valueOf(0);
1662 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1663 String key = menuClasses[i] + ".checkIconOffset";
1664 Object oldValue = table.get(key);
1665 menuDefaults[j++] = key;
1666 menuDefaults[j++] =
1667 new XPValue(checkIconOffsetInteger, oldValue);
1668 }
1669 table.putDefaults(menuDefaults);
1670 }
1671 /* set width of the gap after check icon */
1672 Integer afterCheckIconGap = WindowsPopupMenuUI.getSpanBeforeGutter()
1673 + WindowsPopupMenuUI.getGutterWidth()
1674 + WindowsPopupMenuUI.getSpanAfterGutter();
1675 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1676 String key = menuClasses[i] + ".afterCheckIconGap";
1677 Object oldValue = table.get(key);
1678 menuDefaults[j++] = key;
1679 menuDefaults[j++] =
1680 new XPValue(afterCheckIconGap, oldValue);
1681 }
1682 table.putDefaults(menuDefaults);
1683
1684 /* text is started after this position */
1685 Object minimumTextOffset = new UIDefaults.ActiveValue() {
1686 public Object createValue(UIDefaults table) {
1687 return VistaMenuItemCheckIconFactory.getIconWidth()
1688 + WindowsPopupMenuUI.getSpanBeforeGutter()
1689 + WindowsPopupMenuUI.getGutterWidth()
1690 + WindowsPopupMenuUI.getSpanAfterGutter();
1691 }
1692 };
1693 for (int i = 0, j = 0; i < menuClasses.length; i++) {
1694 String key = menuClasses[i] + ".minimumTextOffset";
1695 Object oldValue = table.get(key);
1696 menuDefaults[j++] = key;
1697 menuDefaults[j++] = new XPValue(minimumTextOffset, oldValue);
1698 }
1699 table.putDefaults(menuDefaults);
1700
1701 /*
1702 * JPopupMenu has a bit of free space around menu items
1703 */
1704 String POPUP_MENU_BORDER = "PopupMenu.border";
1705
1706 Object popupMenuBorder = new XPBorderValue(Part.MENU,
1707 (LazyValue) t -> BasicBorders.getInternalFrameBorder(),
1708 BorderFactory.createEmptyBorder(2, 2, 2, 2));
1709 table.put(POPUP_MENU_BORDER, popupMenuBorder);
1710 /* END handling menus for Vista */
1711
1712 /* START table handling for Vista */
1713 table.put("Table.ascendingSortIcon", new XPValue(
1714 new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDDOWN),
1715 (LazyValue) t -> new ClassicSortArrowIcon(true)));
1716 table.put("Table.descendingSortIcon", new XPValue(
1717 new SkinIcon(Part.HP_HEADERSORTARROW, State.SORTEDUP),
1718 (LazyValue) t -> new ClassicSortArrowIcon(false)));
1719 /* END table handling for Vista */
1720 }
1721
1722 /**
1723 * If we support loading of fonts from the desktop this will return
1724 * a DesktopProperty representing the font. If the font can't be
1725 * represented in the current encoding this will return null and
1726 * turn off the use of system fonts.
1727 */
1728 private Object getDesktopFontValue(String fontName, Object backup) {
1729 if (useSystemFontSettings) {
1730 return new WindowsFontProperty(fontName, backup);
1731 }
1732 return null;
1733 }
1734
1735 // When a desktop property change is detected, these classes must be
1736 // reinitialized in the defaults table to ensure the classes reference
1737 // the updated desktop property values (colors mostly)
1738 //
1739 private Object[] getLazyValueDefaults() {
1740
1741 Object buttonBorder =
1742 new XPBorderValue(Part.BP_PUSHBUTTON,
1743 (LazyValue) t -> BasicBorders.getButtonBorder());
1744
1745 Object textFieldBorder =
1746 new XPBorderValue(Part.EP_EDIT,
1747 (LazyValue) t -> BasicBorders.getTextFieldBorder());
1748
1749 Object textFieldMargin =
1750 new XPValue(new InsetsUIResource(2, 2, 2, 2),
1751 new InsetsUIResource(1, 1, 1, 1));
1752
1753 Object spinnerBorder =
1754 new XPBorderValue(Part.EP_EDIT, textFieldBorder,
1755 new EmptyBorder(2, 2, 2, 2));
1756
1757 Object spinnerArrowInsets =
1758 new XPValue(new InsetsUIResource(1, 1, 1, 1),
1759 null);
1760
1761 Object comboBoxBorder = new XPBorderValue(Part.CP_COMBOBOX, textFieldBorder);
1762
1763 // For focus rectangle for cells and trees.
1764 LazyValue focusCellHighlightBorder = t -> WindowsBorders.getFocusCellHighlightBorder();
1765
1766 LazyValue etchedBorder = t -> BorderUIResource.getEtchedBorderUIResource();
1767
1768 LazyValue internalFrameBorder = t -> WindowsBorders.getInternalFrameBorder();
1769
1770 LazyValue loweredBevelBorder = t -> BorderUIResource.getLoweredBevelBorderUIResource();
1771
1772
1773 LazyValue marginBorder = t -> new BasicBorders.MarginBorder();
1774
1775 LazyValue menuBarBorder = t -> BasicBorders.getMenuBarBorder();
1776
1777
1778 Object popupMenuBorder = new XPBorderValue(Part.MENU,
1779 (LazyValue) t -> BasicBorders.getInternalFrameBorder());
1780
1781 // *** ProgressBar
1782 LazyValue progressBarBorder = t -> WindowsBorders.getProgressBarBorder();
1783
1784 LazyValue radioButtonBorder = t -> BasicBorders.getRadioButtonBorder();
1785
1786 Object scrollPaneBorder =
1787 new XPBorderValue(Part.LBP_LISTBOX, textFieldBorder);
1788
1789 Object tableScrollPaneBorder =
1790 new XPBorderValue(Part.LBP_LISTBOX, loweredBevelBorder);
1791
1792 LazyValue tableHeaderBorder = t -> WindowsBorders.getTableHeaderBorder();
1793
1794 // *** ToolBar
1795 LazyValue toolBarBorder = t -> WindowsBorders.getToolBarBorder();
1796
1797 // *** ToolTips
1798 LazyValue toolTipBorder = t -> BorderUIResource.getBlackLineBorderUIResource();
1799
1800
1801
1802 LazyValue checkBoxIcon = t -> WindowsIconFactory.getCheckBoxIcon();
1803
1804 LazyValue radioButtonIcon = t -> WindowsIconFactory.getRadioButtonIcon();
1805
1806 LazyValue radioButtonMenuItemIcon = t -> WindowsIconFactory.getRadioButtonMenuItemIcon();
1807
1808 LazyValue menuItemCheckIcon = t -> WindowsIconFactory.getMenuItemCheckIcon();
1809
1810 LazyValue menuItemArrowIcon = t -> WindowsIconFactory.getMenuItemArrowIcon();
1811
1812 LazyValue menuArrowIcon = t -> WindowsIconFactory.getMenuArrowIcon();
1813
1814 Color highlight = (Color) Toolkit.getDefaultToolkit().
1815 getDesktopProperty("win.3d.highlightColor");
1816
1817 Color shadow = (Color) Toolkit.getDefaultToolkit().
1818 getDesktopProperty("win.3d.shadowColor");
1819
1820 Object[] lazyDefaults = {
1821 "Button.border", buttonBorder,
1822 "CheckBox.border", radioButtonBorder,
1823 "ComboBox.border", comboBoxBorder,
1824 "DesktopIcon.border", internalFrameBorder,
1825 "FormattedTextField.border", textFieldBorder,
1826 "FormattedTextField.margin", textFieldMargin,
1827 "InternalFrame.border", internalFrameBorder,
1828 "List.focusCellHighlightBorder", focusCellHighlightBorder,
1829 "Table.focusCellHighlightBorder", focusCellHighlightBorder,
1830 "Menu.border", marginBorder,
1831 "MenuBar.border", menuBarBorder,
1832 "MenuItem.border", marginBorder,
1833 "PasswordField.border", textFieldBorder,
1834 "PasswordField.margin", textFieldMargin,
1835 "PopupMenu.border", popupMenuBorder,
1836 "ProgressBar.border", progressBarBorder,
1837 "RadioButton.border", radioButtonBorder,
1838 "ScrollPane.border", scrollPaneBorder,
1839 "Spinner.border", spinnerBorder,
1840 "Spinner.arrowButtonInsets", spinnerArrowInsets,
1841 "Spinner.arrowButtonSize", new Dimension(17, 9),
1842 "Table.scrollPaneBorder", tableScrollPaneBorder,
1843 "TableHeader.cellBorder", tableHeaderBorder,
1844 "TextArea.margin", textFieldMargin,
1845 "TextField.border", textFieldBorder,
1846 "TextField.margin", textFieldMargin,
1847 "TitledBorder.border", new UIDefaults.LazyValue() {
1848 public Object createValue(UIDefaults table) {
1849 return new BorderUIResource.
1850 EtchedBorderUIResource(highlight, shadow);
1851 }
1852 },
1853 "ToggleButton.border", radioButtonBorder,
1854 "ToolBar.border", toolBarBorder,
1855 "ToolTip.border", toolTipBorder,
1856
1857 "CheckBox.icon", checkBoxIcon,
1858 "Menu.arrowIcon", menuArrowIcon,
1859 "MenuItem.checkIcon", menuItemCheckIcon,
1860 "MenuItem.arrowIcon", menuItemArrowIcon,
1861 "RadioButton.icon", radioButtonIcon,
1862 "RadioButtonMenuItem.checkIcon", radioButtonMenuItemIcon,
1863 "InternalFrame.layoutTitlePaneAtOrigin",
1864 new XPValue(Boolean.TRUE, Boolean.FALSE),
1865 "Table.ascendingSortIcon", new XPValue(
1866 (LazyValue) t -> new SortArrowIcon(true,"Table.sortIconColor"),
1867 (LazyValue) t -> new ClassicSortArrowIcon(true)),
1868 "Table.descendingSortIcon", new XPValue(
1869 (LazyValue) t -> new SortArrowIcon(false,"Table.sortIconColor"),
1870 (LazyValue) t -> new ClassicSortArrowIcon(false)),
1871 };
1872
1873 return lazyDefaults;
1874 }
1875
1876 public void uninitialize() {
1877 super.uninitialize();
1878
1879 if (WindowsPopupMenuUI.mnemonicListener != null) {
1880 MenuSelectionManager.defaultManager().
1881 removeChangeListener(WindowsPopupMenuUI.mnemonicListener);
1882 }
1883 KeyboardFocusManager.getCurrentKeyboardFocusManager().
1884 removeKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);
1885 DesktopProperty.flushUnreferencedProperties();
1886 }
1887
1888
1889 // Toggle flag for drawing the mnemonic state
1890 private static boolean isMnemonicHidden = true;
1891
1892 // Flag which indicates that the Win98/Win2k/WinME features
1893 // should be disabled.
1894 private static boolean isClassicWindows = false;
1895
1896 /**
1897 * Sets the state of the hide mnemonic flag. This flag is used by the
1898 * component UI delegates to determine if the mnemonic should be rendered.
1899 * This method is a non operation if the underlying operating system
1900 * does not support the mnemonic hiding feature.
1901 *
1902 * @param hide true if mnemonics should be hidden
1903 * @since 1.4
1904 */
1905 public static void setMnemonicHidden(boolean hide) {
1906 if (UIManager.getBoolean("Button.showMnemonics") == true) {
1907 // Do not hide mnemonics if the UI defaults do not support this
1908 isMnemonicHidden = false;
1909 } else {
1910 isMnemonicHidden = hide;
1911 }
1912 }
1913
1914 /**
1915 * Gets the state of the hide mnemonic flag. This only has meaning
1916 * if this feature is supported by the underlying OS.
1917 *
1918 * @return true if mnemonics are hidden, otherwise, false
1919 * @see #setMnemonicHidden
1920 * @since 1.4
1921 */
1922 public static boolean isMnemonicHidden() {
1923 if (UIManager.getBoolean("Button.showMnemonics") == true) {
1924 // Do not hide mnemonics if the UI defaults do not support this
1925 isMnemonicHidden = false;
1926 }
1927 return isMnemonicHidden;
1928 }
1929
1930 /**
1931 * Gets the state of the flag which indicates if the old Windows
1932 * look and feel should be rendered. This flag is used by the
1933 * component UI delegates as a hint to determine which style the component
1934 * should be rendered.
1935 *
1936 * @return true if Windows 95 and Windows NT 4 look and feel should
1937 * be rendered
1938 * @since 1.4
1939 */
1940 public static boolean isClassicWindows() {
1941 return isClassicWindows;
1942 }
1943
1944 /**
1945 * <p>
1946 * Invoked when the user attempts an invalid operation,
1947 * such as pasting into an uneditable <code>JTextField</code>
1948 * that has focus.
1949 * </p>
1950 * <p>
1951 * If the user has enabled visual error indication on
1952 * the desktop, this method will flash the caption bar
1953 * of the active window. The user can also set the
1954 * property awt.visualbell=true to achieve the same
1955 * results.
1956 * </p>
1957 *
1958 * @param component Component the error occurred in, may be
1959 * null indicating the error condition is
1960 * not directly associated with a
1961 * <code>Component</code>.
1962 *
1963 * @see javax.swing.LookAndFeel#provideErrorFeedback
1964 */
1965 public void provideErrorFeedback(Component component) {
1966 super.provideErrorFeedback(component);
1967 }
1968
1969 /**
1970 * {@inheritDoc}
1971 */
1972 public LayoutStyle getLayoutStyle() {
1973 LayoutStyle style = this.style;
1974 if (style == null) {
1975 style = new WindowsLayoutStyle();
1976 this.style = style;
1977 }
1978 return style;
1979 }
1980
1981 // ********* Auditory Cue support methods and objects *********
1982
1983 /**
1984 * Returns an <code>Action</code>.
1985 * <P>
1986 * This Action contains the information and logic to render an
1987 * auditory cue. The <code>Object</code> that is passed to this
1988 * method contains the information needed to render the auditory
1989 * cue. Normally, this <code>Object</code> is a <code>String</code>
1990 * that points to a <code>Toolkit</code> <code>desktopProperty</code>.
1991 * This <code>desktopProperty</code> is resolved by AWT and the
1992 * Windows OS.
1993 * <P>
1994 * This <code>Action</code>'s <code>actionPerformed</code> method
1995 * is fired by the <code>playSound</code> method.
1996 *
1997 * @return an Action which knows how to render the auditory
1998 * cue for one particular system or user activity
1999 * @see #playSound(Action)
2000 * @since 1.4
2001 */
2002 protected Action createAudioAction(Object key) {
2003 if (key != null) {
2004 String audioKey = (String)key;
2005 String audioValue = (String)UIManager.get(key);
2006 return new AudioAction(audioKey, audioValue);
2007 } else {
2008 return null;
2009 }
2010 }
2011
2012 static void repaintRootPane(Component c) {
2013 JRootPane root = null;
2014 for (; c != null; c = c.getParent()) {
2015 if (c instanceof JRootPane) {
2016 root = (JRootPane)c;
2017 }
2018 }
2019
2020 if (root != null) {
2021 root.repaint();
2022 } else {
2023 c.repaint();
2024 }
2025 }
2026
2027 /**
2028 * Pass the name String to the super constructor. This is used
2029 * later to identify the Action and decide whether to play it or
2030 * not. Store the resource String. It is used to get the audio
2031 * resource. In this case, the resource is a <code>Runnable</code>
2032 * supplied by <code>Toolkit</code>. This <code>Runnable</code> is
2033 * effectively a pointer down into the Win32 OS that knows how to
2034 * play the right sound.
2035 *
2036 * @since 1.4
2037 */
2038 @SuppressWarnings("serial") // Superclass is not serializable across versions
2039 private static class AudioAction extends AbstractAction {
2040 private Runnable audioRunnable;
2041 private String audioResource;
2042 /**
2043 * We use the String as the name of the Action and as a pointer to
2044 * the underlying OSes audio resource.
2045 */
2046 public AudioAction(String name, String resource) {
2047 super(name);
2048 audioResource = resource;
2049 }
2050 public void actionPerformed(ActionEvent e) {
2051 if (audioRunnable == null) {
2052 audioRunnable = (Runnable)Toolkit.getDefaultToolkit().getDesktopProperty(audioResource);
2053 }
2054 if (audioRunnable != null) {
2055 // Runnable appears to block until completed playing, hence
2056 // start up another thread to handle playing.
2057 new Thread(null, audioRunnable, "Audio", 0, false).start();
2058 }
2059 }
2060 }
2061
2062 /**
2063 * Gets an <code>Icon</code> from the native libraries if available,
2064 * otherwise gets it from an image resource file.
2065 */
2066 private static class LazyWindowsIcon implements UIDefaults.LazyValue {
2067 private String nativeImage;
2068 private String resource;
2069
2070 LazyWindowsIcon(String nativeImage, String resource) {
2071 this.nativeImage = nativeImage;
2072 this.resource = resource;
2073 }
2074
2075 public Object createValue(UIDefaults table) {
2076 if (nativeImage != null) {
2077 Image image = (Image)ShellFolder.get(nativeImage);
2078 if (image != null) {
2079 return new ImageIcon(image);
2080 }
2081 }
2082 return SwingUtilities2.makeIcon(getClass(),
2083 WindowsLookAndFeel.class,
2084 resource);
2085 }
2086 }
2087
2088
2089 /**
2090 * Gets an <code>Icon</code> from the native libraries if available.
2091 * A desktop property is used to trigger reloading the icon when needed.
2092 */
2093 private class ActiveWindowsIcon implements UIDefaults.ActiveValue {
2094 private Icon icon;
2095 private String nativeImageName;
2096 private String fallbackName;
2097 private DesktopProperty desktopProperty;
2098
2099 ActiveWindowsIcon(String desktopPropertyName,
2100 String nativeImageName, String fallbackName) {
2101 this.nativeImageName = nativeImageName;
2102 this.fallbackName = fallbackName;
2103
2104 if (OSInfo.getOSType() == OSInfo.OSType.WINDOWS &&
2105 OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_XP) < 0) {
2106 // This desktop property is needed to trigger reloading the icon.
2107 // It is kept in member variable to avoid GC.
2108 this.desktopProperty = new TriggerDesktopProperty(desktopPropertyName) {
2109 @Override protected void updateUI() {
2110 icon = null;
2111 super.updateUI();
2112 }
2113 };
2114 }
2115 }
2116
2117 @Override
2118 public Object createValue(UIDefaults table) {
2119 if (icon == null) {
2120 Image image = (Image)ShellFolder.get(nativeImageName);
2121 if (image != null) {
2122 icon = new ImageIconUIResource(image);
2123 }
2124 }
2125 if (icon == null && fallbackName != null) {
2126 UIDefaults.LazyValue fallback = (UIDefaults.LazyValue)
2127 SwingUtilities2.makeIcon(WindowsLookAndFeel.class,
2128 BasicLookAndFeel.class, fallbackName);
2129 icon = (Icon) fallback.createValue(table);
2130 }
2131 return icon;
2132 }
2133 }
2134
2135 /**
2136 * Icon backed-up by XP Skin.
2137 */
2138 private static class SkinIcon implements Icon, UIResource {
2139 private final Part part;
2140 private final State state;
2141 SkinIcon(Part part, State state) {
2142 this.part = part;
2143 this.state = state;
2144 }
2145
2146 /**
2147 * Draw the icon at the specified location. Icon implementations
2148 * may use the Component argument to get properties useful for
2149 * painting, e.g. the foreground or background color.
2150 */
2151 public void paintIcon(Component c, Graphics g, int x, int y) {
2152 XPStyle xp = XPStyle.getXP();
2153 assert xp != null;
2154 if (xp != null) {
2155 Skin skin = xp.getSkin(null, part);
2156 skin.paintSkin(g, x, y, state);
2157 }
2158 }
2159
2160 /**
2161 * Returns the icon's width.
2162 *
2163 * @return an int specifying the fixed width of the icon.
2164 */
2165 public int getIconWidth() {
2166 int width = 0;
2167 XPStyle xp = XPStyle.getXP();
2168 assert xp != null;
2169 if (xp != null) {
2170 Skin skin = xp.getSkin(null, part);
2171 width = skin.getWidth();
2172 }
2173 return width;
2174 }
2175
2176 /**
2177 * Returns the icon's height.
2178 *
2179 * @return an int specifying the fixed height of the icon.
2180 */
2181 public int getIconHeight() {
2182 int height = 0;
2183 XPStyle xp = XPStyle.getXP();
2184 if (xp != null) {
2185 Skin skin = xp.getSkin(null, part);
2186 height = skin.getHeight();
2187 }
2188 return height;
2189 }
2190
2191 }
2192
2193 /**
2194 * DesktopProperty for fonts. If a font with the name 'MS Sans Serif'
2195 * is returned, it is mapped to 'Microsoft Sans Serif'.
2196 */
2197 private static class WindowsFontProperty extends DesktopProperty {
2198 WindowsFontProperty(String key, Object backup) {
2199 super(key, backup);
2200 }
2201
2202 public void invalidate(LookAndFeel laf) {
2203 if ("win.defaultGUI.font.height".equals(getKey())) {
2204 ((WindowsLookAndFeel)laf).style = null;
2205 }
2206 super.invalidate(laf);
2207 }
2208
2209 protected Object configureValue(Object value) {
2210 if (value instanceof Font) {
2211 Font font = (Font)value;
2212 if ("MS Sans Serif".equals(font.getName())) {
2213 int size = font.getSize();
2214 // 4950968: Workaround to mimic the way Windows maps the default
2215 // font size of 6 pts to the smallest available bitmap font size.
2216 // This happens mostly on Win 98/Me & NT.
2217 int dpi;
2218 try {
2219 dpi = Toolkit.getDefaultToolkit().getScreenResolution();
2220 } catch (HeadlessException ex) {
2221 dpi = 96;
2222 }
2223 if (Math.round(size * 72F / dpi) < 8) {
2224 size = Math.round(8 * dpi / 72F);
2225 }
2226 Font msFont = new FontUIResource("Microsoft Sans Serif",
2227 font.getStyle(), size);
2228 if (msFont.getName() != null &&
2229 msFont.getName().equals(msFont.getFamily())) {
2230 font = msFont;
2231 } else if (size != font.getSize()) {
2232 font = new FontUIResource("MS Sans Serif",
2233 font.getStyle(), size);
2234 }
2235 }
2236
2237 if (FontUtilities.fontSupportsDefaultEncoding(font)) {
2238 if (!(font instanceof UIResource)) {
2239 font = new FontUIResource(font);
2240 }
2241 }
2242 else {
2243 font = FontUtilities.getCompositeFontUIResource(font);
2244 }
2245 return font;
2246
2247 }
2248 return super.configureValue(value);
2249 }
2250 }
2251
2252
2253 /**
2254 * DesktopProperty for fonts that only gets sizes from the desktop,
2255 * font name and style are passed into the constructor
2256 */
2257 private static class WindowsFontSizeProperty extends DesktopProperty {
2258 private String fontName;
2259 private int fontSize;
2260 private int fontStyle;
2261
2262 WindowsFontSizeProperty(String key, String fontName,
2263 int fontStyle, int fontSize) {
2264 super(key, null);
2265 this.fontName = fontName;
2266 this.fontSize = fontSize;
2267 this.fontStyle = fontStyle;
2268 }
2269
2270 protected Object configureValue(Object value) {
2271 if (value == null) {
2272 value = new FontUIResource(fontName, fontStyle, fontSize);
2273 }
2274 else if (value instanceof Integer) {
2275 value = new FontUIResource(fontName, fontStyle,
2276 ((Integer)value).intValue());
2277 }
2278 return value;
2279 }
2280 }
2281
2282
2283 /**
2284 * A value wrapper that actively retrieves values from xp or falls back
2285 * to the classic value if not running XP styles.
2286 */
2287 private static class XPValue implements UIDefaults.ActiveValue {
2288 protected Object classicValue, xpValue;
2289
2290 // A constant that lets you specify null when using XP styles.
2291 private static final Object NULL_VALUE = new Object();
2292
2293 XPValue(Object xpValue, Object classicValue) {
2294 this.xpValue = xpValue;
2295 this.classicValue = classicValue;
2296 }
2297
2298 public Object createValue(UIDefaults table) {
2299 Object value = null;
2300 if (XPStyle.getXP() != null) {
2301 value = getXPValue(table);
2302 }
2303
2304 if (value == null) {
2305 value = getClassicValue(table);
2306 } else if (value == NULL_VALUE) {
2307 value = null;
2308 }
2309
2310 return value;
2311 }
2312
2313 protected Object getXPValue(UIDefaults table) {
2314 return recursiveCreateValue(xpValue, table);
2315 }
2316
2317 protected Object getClassicValue(UIDefaults table) {
2318 return recursiveCreateValue(classicValue, table);
2319 }
2320
2321 private Object recursiveCreateValue(Object value, UIDefaults table) {
2322 if (value instanceof UIDefaults.LazyValue) {
2323 value = ((UIDefaults.LazyValue)value).createValue(table);
2324 }
2325 if (value instanceof UIDefaults.ActiveValue) {
2326 return ((UIDefaults.ActiveValue)value).createValue(table);
2327 } else {
2328 return value;
2329 }
2330 }
2331 }
2332
2333 private static class XPBorderValue extends XPValue {
2334 private final Border extraMargin;
2335
2336 XPBorderValue(Part xpValue, Object classicValue) {
2337 this(xpValue, classicValue, null);
2338 }
2339
2340 XPBorderValue(Part xpValue, Object classicValue, Border extraMargin) {
2341 super(xpValue, classicValue);
2342 this.extraMargin = extraMargin;
2343 }
2344
2345 public Object getXPValue(UIDefaults table) {
2346 XPStyle xp = XPStyle.getXP();
2347 Border xpBorder = xp != null ? xp.getBorder(null, (Part)xpValue) : null;
2348 if (xpBorder != null && extraMargin != null) {
2349 return new BorderUIResource.
2350 CompoundBorderUIResource(xpBorder, extraMargin);
2351 } else {
2352 return xpBorder;
2353 }
2354 }
2355 }
2356
2357 private static class XPColorValue extends XPValue {
2358 XPColorValue(Part part, State state, Prop prop, Object classicValue) {
2359 super(new XPColorValueKey(part, state, prop), classicValue);
2360 }
2361
2362 public Object getXPValue(UIDefaults table) {
2363 XPColorValueKey key = (XPColorValueKey)xpValue;
2364 XPStyle xp = XPStyle.getXP();
2365 return xp != null ? xp.getColor(key.skin, key.prop, null) : null;
2366 }
2367
2368 private static class XPColorValueKey {
2369 Skin skin;
2370 Prop prop;
2371
2372 XPColorValueKey(Part part, State state, Prop prop) {
2373 this.skin = new Skin(part, state);
2374 this.prop = prop;
2375 }
2376 }
2377 }
2378
2379 private class XPDLUValue extends XPValue {
2380 private int direction;
2381
2382 XPDLUValue(int xpdlu, int classicdlu, int direction) {
2383 super(Integer.valueOf(xpdlu), Integer.valueOf(classicdlu));
2384 this.direction = direction;
2385 }
2386
2387 public Object getXPValue(UIDefaults table) {
2388 int px = dluToPixels(((Integer)xpValue).intValue(), direction);
2389 return Integer.valueOf(px);
2390 }
2391
2392 public Object getClassicValue(UIDefaults table) {
2393 int px = dluToPixels(((Integer)classicValue).intValue(), direction);
2394 return Integer.valueOf(px);
2395 }
2396 }
2397
2398 private class TriggerDesktopProperty extends DesktopProperty {
2399 TriggerDesktopProperty(String key) {
2400 super(key, null);
2401 // This call adds a property change listener for the property,
2402 // which triggers a call to updateUI(). The value returned
2403 // is not interesting here.
2404 getValueFromDesktop();
2405 }
2406
2407 protected void updateUI() {
2408 super.updateUI();
2409
2410 // Make sure property change listener is readded each time
2411 getValueFromDesktop();
2412 }
2413 }
2414
2415 private class FontDesktopProperty extends TriggerDesktopProperty {
2416 FontDesktopProperty(String key) {
2417 super(key);
2418 }
2419
2420 protected void updateUI() {
2421 UIDefaults defaults = UIManager.getLookAndFeelDefaults();
2422 SwingUtilities2.putAATextInfo(true, defaults);
2423 super.updateUI();
2424 }
2425 }
2426
2427 // Windows LayoutStyle. From:
2428 // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwue/html/ch14e.asp
2429 @SuppressWarnings("fallthrough")
2430 private class WindowsLayoutStyle extends DefaultLayoutStyle {
2431 @Override
2432 public int getPreferredGap(JComponent component1,
2433 JComponent component2, ComponentPlacement type, int position,
2434 Container parent) {
2435 // Checks args
2436 super.getPreferredGap(component1, component2, type, position,
2437 parent);
2438
2439 switch(type) {
2440 case INDENT:
2441 // Windows doesn't spec this
2442 if (position == SwingConstants.EAST ||
2443 position == SwingConstants.WEST) {
2444 int indent = getIndent(component1, position);
2445 if (indent > 0) {
2446 return indent;
2447 }
2448 return 10;
2449 }
2450 // Fall through to related.
2451 case RELATED:
2452 if (isLabelAndNonlabel(component1, component2, position)) {
2453 // Between text labels and their associated controls (for
2454 // example, text boxes and list boxes): 3
2455 // NOTE: We're not honoring:
2456 // 'Text label beside a button 3 down from the top of
2457 // the button,' but I suspect that is an attempt to
2458 // enforce a baseline layout which will be handled
2459 // separately. In order to enforce this we would need
2460 // this API to return a more complicated type (Insets,
2461 // or something else).
2462 return getButtonGap(component1, component2, position,
2463 dluToPixels(3, position));
2464 }
2465 // Between related controls: 4
2466 return getButtonGap(component1, component2, position,
2467 dluToPixels(4, position));
2468 case UNRELATED:
2469 // Between unrelated controls: 7
2470 return getButtonGap(component1, component2, position,
2471 dluToPixels(7, position));
2472 }
2473 return 0;
2474 }
2475
2476 @Override
2477 public int getContainerGap(JComponent component, int position,
2478 Container parent) {
2479 // Checks args
2480 super.getContainerGap(component, position, parent);
2481 return getButtonGap(component, position, dluToPixels(7, position));
2482 }
2483
2484 }
2485
2486 /**
2487 * Converts the dialog unit argument to pixels along the specified
2488 * axis.
2489 */
2490 private int dluToPixels(int dlu, int direction) {
2491 if (baseUnitX == 0) {
2492 calculateBaseUnits();
2493 }
2494 if (direction == SwingConstants.EAST ||
2495 direction == SwingConstants.WEST) {
2496 return dlu * baseUnitX / 4;
2497 }
2498 assert (direction == SwingConstants.NORTH ||
2499 direction == SwingConstants.SOUTH);
2500 return dlu * baseUnitY / 8;
2501 }
2502
2503 /**
2504 * Calculates the dialog unit mapping.
2505 */
2506 @SuppressWarnings("deprecation")
2507 private void calculateBaseUnits() {
2508 // This calculation comes from:
2509 // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
2510 FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
2511 UIManager.getFont("Button.font"));
2512 baseUnitX = metrics.stringWidth(
2513 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
2514 baseUnitX = (baseUnitX / 26 + 1) / 2;
2515 // The -1 comes from experimentation.
2516 baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
2517 }
2518
2519 /**
2520 * {@inheritDoc}
2521 *
2522 * @since 1.6
2523 */
2524 public Icon getDisabledIcon(JComponent component, Icon icon) {
2525 // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
2526 // client property set to Boolean.TRUE, then use the new
2527 // hi res algorithm for creating the disabled icon (used
2528 // in particular by the WindowsFileChooserUI class)
2529 if (icon != null
2530 && component != null
2531 && Boolean.TRUE.equals(component.getClientProperty(HI_RES_DISABLED_ICON_CLIENT_KEY))
2532 && icon.getIconWidth() > 0
2533 && icon.getIconHeight() > 0) {
2534 BufferedImage img = new BufferedImage(icon.getIconWidth(),
2535 icon.getIconWidth(), BufferedImage.TYPE_INT_ARGB);
2536 icon.paintIcon(component, img.getGraphics(), 0, 0);
2537 ImageFilter filter = new RGBGrayFilter();
2538 ImageProducer producer = new FilteredImageSource(img.getSource(), filter);
2539 Image resultImage = component.createImage(producer);
2540 return new ImageIconUIResource(resultImage);
2541 }
2542 return super.getDisabledIcon(component, icon);
2543 }
2544
2545 private static class RGBGrayFilter extends RGBImageFilter {
2546 public RGBGrayFilter() {
2547 canFilterIndexColorModel = true;
2548 }
2549 public int filterRGB(int x, int y, int rgb) {
2550 // find the average of red, green, and blue
2551 float avg = (((rgb >> 16) & 0xff) / 255f +
2552 ((rgb >> 8) & 0xff) / 255f +
2553 (rgb & 0xff) / 255f) / 3;
2554 // pull out the alpha channel
2555 float alpha = (((rgb>>24)&0xff)/255f);
2556 // calc the average
2557 avg = Math.min(1.0f, (1f-avg)/(100.0f/35.0f) + avg);
2558 // turn back into rgb
2559 int rgbval = (int)(alpha * 255f) << 24 |
2560 (int)(avg * 255f) << 16 |
2561 (int)(avg * 255f) << 8 |
2562 (int)(avg * 255f);
2563 return rgbval;
2564 }
2565 }
2566
2567 private static class FocusColorProperty extends DesktopProperty {
2568 public FocusColorProperty () {
2569 // Fallback value is never used because of the configureValue method doesn't return null
2570 super("win.3d.backgroundColor", Color.BLACK);
2571 }
2572
2573 @Override
2574 protected Object configureValue(Object value) {
2575 Object highContrastOn = Toolkit.getDefaultToolkit().
2576 getDesktopProperty("win.highContrast.on");
2577 if (highContrastOn == null || !((Boolean) highContrastOn).booleanValue()) {
2578 return Color.BLACK;
2579 }
2580 return Color.BLACK.equals(value) ? Color.WHITE : Color.BLACK;
2581 }
2582 }
2583
2584 }