KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > gtk > GTKLookAndFeel


1 /*
2  * @(#)GTKLookAndFeel.java 1.75 06/12/14
3  *
4  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7 package com.sun.java.swing.plaf.gtk;
8
9 import com.sun.java.swing.SwingUtilities2;
10 import java.lang.ref.*;
11 import javax.swing.plaf.synth.*;
12 import java.awt.*;
13 import java.awt.event.*;
14 import java.beans.*;
15 import java.io.File JavaDoc;
16 import java.lang.reflect.*;
17 import java.security.AccessController JavaDoc;
18 import java.security.PrivilegedAction JavaDoc;
19 import java.util.HashMap JavaDoc;
20 import java.util.Locale JavaDoc;
21 import javax.swing.*;
22 import javax.swing.colorchooser.*;
23 import javax.swing.plaf.*;
24 import javax.swing.text.DefaultEditorKit JavaDoc;
25 import java.io.IOException JavaDoc;
26
27 import sun.security.action.GetPropertyAction;
28
29 /**
30  * @version 1.75, 12/14/06
31  * @author Scott Violet
32  */

33 public class GTKLookAndFeel extends SynthLookAndFeel {
34     private static final boolean IS_22;
35
36     /**
37      * Whether or not text is drawn antialiased. This keys off the
38      * desktop property 'gnome.Xft/Antialias'.
39      */

40     static Boolean JavaDoc aaText = Boolean.FALSE;
41
42     /**
43      * Whether or not the default locale is CJK. If it is,
44      * the GNOME desktop property for antialiasing is ignored
45      * and the text is always rendered w/o aa.
46      * This is done to be consistent with what GTK does - they
47      * disable text aa for CJK locales as well.
48      *
49      * Note: this doesn't work well with changing locales
50      * at runtime. But most of Swing/2D code (including fonts
51      * initialization) doesn't either.
52      */

53     static boolean cjkLocale;
54
55     /**
56      * Font to use in places where there is no widget.
57      */

58     private Font fallbackFont;
59
60     /**
61      * If true, GTKLookAndFeel is inside the <code>initialize</code>
62      * method.
63      */

64     private boolean inInitialize;
65
66     static {
67         // Backup for specifying the version, this isn't currently documented.
68
// If you pass in anything but 2.2 you got the 2.0 colors/look.
69
String JavaDoc version = (String JavaDoc)java.security.AccessController.doPrivileged(
70                new GetPropertyAction("swing.gtk.version"));
71         if (version != null) {
72             IS_22 = version.equals("2.2");
73         }
74         else {
75             IS_22 = true;
76         }
77     }
78
79     /**
80      * Returns true if running on system containing at least 2.2.
81      */

82     static boolean is2_2() {
83         // NOTE: We're currently hard coding to use 2.2.
84
// If we want to support both GTK 2.0 and 2.2, we'll
85
// need to get the major/minor/micro version from the .so.
86
// Refer to bug 4912613 for details.
87
return IS_22;
88     }
89
90     /**
91      * Maps a swing constant to a GTK constant.
92      */

93     static int SwingOrientationConstantToGTK(int side) {
94         switch (side) {
95         case SwingConstants.LEFT:
96             return GTKConstants.LEFT;
97         case SwingConstants.RIGHT:
98             return GTKConstants.RIGHT;
99         case SwingConstants.TOP:
100             return GTKConstants.TOP;
101         case SwingConstants.BOTTOM:
102             return GTKConstants.BOTTOM;
103         }
104         assert false : "Unknowning orientation: " + side;
105         return side;
106     }
107
108     /**
109      * Maps from a Synth state to the corresponding GTK state.
110      * The GTK states are named differently than Synth's states, the
111      * following gives the mapping:
112      * <table><tr><td>Synth<td>GTK
113      * <tr><td>SynthConstants.PRESSED<td>ACTIVE
114      * <tr><td>SynthConstants.SELECTED<td>SELECTED
115      * <tr><td>SynthConstants.MOUSE_OVER<td>PRELIGHT
116      * <tr><td>SynthConstants.DISABLED<td>INACTIVE
117      * <tr><td>SynthConstants.ENABLED<td>NORMAL
118      * </table>
119      * Additionally some widgets are special cased.
120      */

121     static int synthStateToGTKState(Region region, int state) {
122         int orgState = state;
123
124         if ((state & SynthConstants.PRESSED) != 0) {
125             if (region == Region.RADIO_BUTTON
126                     || region == Region.CHECK_BOX
127                     || region == Region.TOGGLE_BUTTON
128                     || region == Region.MENU
129                     || region == Region.MENU_ITEM
130                     || region == Region.RADIO_BUTTON_MENU_ITEM
131                     || region == Region.CHECK_BOX_MENU_ITEM
132                     || region == Region.SPLIT_PANE) {
133                 state = SynthConstants.MOUSE_OVER;
134             } else {
135                 state = SynthConstants.PRESSED;
136             }
137         }
138         else if ((state & SynthConstants.SELECTED) != 0) {
139             if (region == Region.MENU) {
140                 state = SynthConstants.MOUSE_OVER;
141             } else if (region == Region.RADIO_BUTTON ||
142                           region == Region.TOGGLE_BUTTON ||
143                           region == Region.RADIO_BUTTON_MENU_ITEM ||
144                           region == Region.CHECK_BOX_MENU_ITEM ||
145                           region == Region.CHECK_BOX ||
146                           region == Region.BUTTON) {
147                 // If the button is SELECTED and is PRELIGHT we need to
148
// make the state MOUSE_OVER otherwise we don't paint the
149
// PRELIGHT.
150
if ((state & SynthConstants.MOUSE_OVER) != 0) {
151                     state = SynthConstants.MOUSE_OVER;
152                 } else if ((state & SynthConstants.DISABLED) != 0){
153                     state = SynthConstants.DISABLED;
154                 } else {
155                     state = SynthConstants.PRESSED;
156                 }
157             } else if (region == Region.TABBED_PANE_TAB) {
158                 state = SynthConstants.ENABLED;
159             } else {
160                 state = SynthConstants.SELECTED;
161             }
162         }
163         else if ((state & SynthConstants.MOUSE_OVER) != 0) {
164             state = SynthConstants.MOUSE_OVER;
165         }
166         else if ((state & SynthConstants.DISABLED) != 0) {
167             state = SynthConstants.DISABLED;
168         }
169         else {
170             if (region == Region.SLIDER_TRACK) {
171                 state = SynthConstants.PRESSED;
172             } else if (region == Region.TABBED_PANE_TAB) {
173                 state = SynthConstants.PRESSED;
174             } else {
175                 state = SynthConstants.ENABLED;
176             }
177         }
178         return state;
179     }
180
181     static boolean isText(Region region) {
182         // These Regions treat FOREGROUND as TEXT.
183
return (region == Region.TEXT_FIELD ||
184                 region == Region.FORMATTED_TEXT_FIELD ||
185                 region == Region.LIST ||
186                 region == Region.PASSWORD_FIELD ||
187                 region == Region.SPINNER ||
188                 region == Region.TABLE ||
189                 region == Region.TEXT_AREA ||
190                 region == Region.TEXT_FIELD ||
191                 region == Region.TEXT_PANE ||
192                 region == Region.TREE);
193     }
194
195     public UIDefaults getDefaults() {
196         // We need to call super for basic's properties file.
197
UIDefaults table = super.getDefaults();
198
199         initResourceBundle(table);
200         // For compatability with apps expecting certain defaults we'll
201
// populate the table with the values from basic.
202
initSystemColorDefaults(table);
203         initComponentDefaults(table);
204         return table;
205     }
206
207     private void initResourceBundle(UIDefaults table) {
208         table.addResourceBundle("com.sun.java.swing.plaf.gtk.resources.gtk");
209     }
210
211     protected void initComponentDefaults(UIDefaults table) {
212         // For compatability with apps expecting certain defaults we'll
213
// populate the table with the values from basic.
214
super.initComponentDefaults(table);
215
216         Object JavaDoc focusBorder = new GTKStyle.GTKLazyValue(
217             "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder",
218             "getUnselectedCellBorder");
219         Object JavaDoc focusSelectedBorder = new GTKStyle.GTKLazyValue(
220             "com.sun.java.swing.plaf.gtk.GTKPainter$ListTableFocusBorder",
221             "getSelectedCellBorder");
222
223         GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
224         GTKStyle tableStyle = (GTKStyle)factory.getStyle("GtkTreeView");
225         Color tableFocusCellBg = tableStyle.getColorForState(null, Region.TABLE,
226                 SynthConstants.ENABLED, GTKColorType.BACKGROUND);
227         Color tableFocusCellFg = tableStyle.getColorForState(null, Region.TABLE,
228                 SynthConstants.ENABLED, GTKColorType.FOREGROUND);
229         
230         Integer JavaDoc caretBlinkRate = new Integer JavaDoc(500);
231         Insets zeroInsets = new InsetsUIResource(0, 0, 0, 0);
232
233         Double JavaDoc defaultCaretAspectRatio = new Double JavaDoc(0.025);
234         Color caretColor = table.getColor("caretColor");
235         
236         Object JavaDoc fieldInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
237                        "ctrl C", DefaultEditorKit.copyAction,
238                        "ctrl V", DefaultEditorKit.pasteAction,
239                        "ctrl X", DefaultEditorKit.cutAction,
240                          "COPY", DefaultEditorKit.copyAction,
241                         "PASTE", DefaultEditorKit.pasteAction,
242                           "CUT", DefaultEditorKit.cutAction,
243                    "shift LEFT", DefaultEditorKit.selectionBackwardAction,
244                 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
245                   "shift RIGHT", DefaultEditorKit.selectionForwardAction,
246                "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
247                     "ctrl LEFT", DefaultEditorKit.previousWordAction,
248                  "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
249                    "ctrl RIGHT", DefaultEditorKit.nextWordAction,
250                 "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
251               "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
252            "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
253              "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
254           "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
255                        "ctrl A", DefaultEditorKit.selectAllAction,
256                          "HOME", DefaultEditorKit.beginLineAction,
257                           "END", DefaultEditorKit.endLineAction,
258                    "shift HOME", DefaultEditorKit.selectionBeginLineAction,
259                     "shift END", DefaultEditorKit.selectionEndLineAction,
260                    "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
261                        "ctrl H", DefaultEditorKit.deletePrevCharAction,
262                        "DELETE", DefaultEditorKit.deleteNextCharAction,
263                         "RIGHT", DefaultEditorKit.forwardAction,
264                          "LEFT", DefaultEditorKit.backwardAction,
265                      "KP_RIGHT", DefaultEditorKit.forwardAction,
266                       "KP_LEFT", DefaultEditorKit.backwardAction,
267                         "ENTER", JTextField.notifyAction,
268               "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
269                "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
270             });
271
272         Object JavaDoc passwordInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
273                        "ctrl C", DefaultEditorKit.copyAction,
274                        "ctrl V", DefaultEditorKit.pasteAction,
275                        "ctrl X", DefaultEditorKit.cutAction,
276                          "COPY", DefaultEditorKit.copyAction,
277                         "PASTE", DefaultEditorKit.pasteAction,
278                           "CUT", DefaultEditorKit.cutAction,
279                    "shift LEFT", DefaultEditorKit.selectionBackwardAction,
280                 "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
281                   "shift RIGHT", DefaultEditorKit.selectionForwardAction,
282                "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
283                     "ctrl LEFT", DefaultEditorKit.beginLineAction,
284                  "ctrl KP_LEFT", DefaultEditorKit.beginLineAction,
285                    "ctrl RIGHT", DefaultEditorKit.endLineAction,
286                 "ctrl KP_RIGHT", DefaultEditorKit.endLineAction,
287               "ctrl shift LEFT", DefaultEditorKit.selectionBeginLineAction,
288            "ctrl shift KP_LEFT", DefaultEditorKit.selectionBeginLineAction,
289              "ctrl shift RIGHT", DefaultEditorKit.selectionEndLineAction,
290           "ctrl shift KP_RIGHT", DefaultEditorKit.selectionEndLineAction,
291                        "ctrl A", DefaultEditorKit.selectAllAction,
292                          "HOME", DefaultEditorKit.beginLineAction,
293                           "END", DefaultEditorKit.endLineAction,
294                    "shift HOME", DefaultEditorKit.selectionBeginLineAction,
295                     "shift END", DefaultEditorKit.selectionEndLineAction,
296                    "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
297                        "ctrl H", DefaultEditorKit.deletePrevCharAction,
298                        "DELETE", DefaultEditorKit.deleteNextCharAction,
299                         "RIGHT", DefaultEditorKit.forwardAction,
300                          "LEFT", DefaultEditorKit.backwardAction,
301                      "KP_RIGHT", DefaultEditorKit.forwardAction,
302                       "KP_LEFT", DefaultEditorKit.backwardAction,
303                         "ENTER", JTextField.notifyAction,
304               "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
305                "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
306             });
307
308         Object JavaDoc editorMargin = new InsetsUIResource(3,3,3,3);
309
310         Object JavaDoc multilineInputMap = new UIDefaults.LazyInputMap(new Object JavaDoc[] {
311                            "ctrl C", DefaultEditorKit.copyAction,
312                            "ctrl V", DefaultEditorKit.pasteAction,
313                            "ctrl X", DefaultEditorKit.cutAction,
314                              "COPY", DefaultEditorKit.copyAction,
315                             "PASTE", DefaultEditorKit.pasteAction,
316                               "CUT", DefaultEditorKit.cutAction,
317                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
318                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
319                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
320                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
321                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
322                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
323                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
324                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
325                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
326                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
327                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
328               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
329                            "ctrl A", DefaultEditorKit.selectAllAction,
330                              "HOME", DefaultEditorKit.beginLineAction,
331                               "END", DefaultEditorKit.endLineAction,
332                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
333                         "shift END", DefaultEditorKit.selectionEndLineAction,
334
335                                "UP", DefaultEditorKit.upAction,
336                             "KP_UP", DefaultEditorKit.upAction,
337                              "DOWN", DefaultEditorKit.downAction,
338                           "KP_DOWN", DefaultEditorKit.downAction,
339                           "PAGE_UP", DefaultEditorKit.pageUpAction,
340                         "PAGE_DOWN", DefaultEditorKit.pageDownAction,
341                     "shift PAGE_UP", "selection-page-up",
342                   "shift PAGE_DOWN", "selection-page-down",
343                "ctrl shift PAGE_UP", "selection-page-left",
344              "ctrl shift PAGE_DOWN", "selection-page-right",
345                          "shift UP", DefaultEditorKit.selectionUpAction,
346                       "shift KP_UP", DefaultEditorKit.selectionUpAction,
347                        "shift DOWN", DefaultEditorKit.selectionDownAction,
348                     "shift KP_DOWN", DefaultEditorKit.selectionDownAction,
349                             "ENTER", DefaultEditorKit.insertBreakAction,
350                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
351                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
352                            "DELETE", DefaultEditorKit.deleteNextCharAction,
353                             "RIGHT", DefaultEditorKit.forwardAction,
354                              "LEFT", DefaultEditorKit.backwardAction,
355                          "KP_RIGHT", DefaultEditorKit.forwardAction,
356                           "KP_LEFT", DefaultEditorKit.backwardAction,
357                               "TAB", DefaultEditorKit.insertTabAction,
358                   "ctrl BACK_SLASH", "unselect"/*DefaultEditorKit.unselectAction*/,
359                         "ctrl HOME", DefaultEditorKit.beginAction,
360                          "ctrl END", DefaultEditorKit.endAction,
361                   "ctrl shift HOME", DefaultEditorKit.selectionBeginAction,
362                    "ctrl shift END", DefaultEditorKit.selectionEndAction,
363                            "ctrl T", "next-link-action",
364                      "ctrl shift T", "previous-link-action",
365                        "ctrl SPACE", "activate-link-action",
366                    "control shift O", "toggle-componentOrientation"/*DefaultEditorKit.toggleComponentOrientation*/
367             });
368
369         class FontLazyValue implements UIDefaults.LazyValue {
370             private Region region;
371             FontLazyValue(Region region) {
372                 this.region = region;
373             }
374             public Object JavaDoc createValue(UIDefaults table) {
375                 GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
376                 GTKStyle style = (GTKStyle)factory.getStyle(
377                         GTKStyleFactory.gtkClassFor(region));
378                 return style.getFontForState(
379                         null, region, SynthConstants.ENABLED);
380             }
381         }
382         
383         Object JavaDoc[] defaults = new Object JavaDoc[] {
384             "ArrowButton.size", new Integer JavaDoc(13),
385
386
387             "Button.defaultButtonFollowsFocus", Boolean.FALSE,
388         "Button.focusInputMap", new UIDefaults.LazyInputMap(new Object JavaDoc[] {
389                          "SPACE", "pressed",
390                 "released SPACE", "released",
391                          "ENTER", "pressed",
392                 "released ENTER", "released"
393               }),
394             "Button.font", new FontLazyValue(Region.BUTTON),
395
396
397         "CheckBox.focusInputMap", new UIDefaults.LazyInputMap(new Object JavaDoc[]{
398                          "SPACE", "pressed",
399                 "released SPACE", "released",
400               }),
401             "CheckBox.icon", new GTKStyle.GTKLazyValue(
402                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
403                               "getCheckBoxIcon"),
404             "CheckBox.font", new FontLazyValue(Region.CHECK_BOX),
405
406
407             "CheckBoxMenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
408                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
409                               "getCheckBoxMenuItemArrowIcon"),
410             "CheckBoxMenuItem.checkIcon", new GTKStyle.GTKLazyValue(
411                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
412                               "getCheckBoxMenuItemCheckIcon"),
413             "CheckBoxMenuItem.font",
414                 new FontLazyValue(Region.CHECK_BOX_MENU_ITEM),
415             "CheckBoxMenuItem.margin", zeroInsets,
416
417
418             "ColorChooser.showPreviewPanelText", Boolean.FALSE,
419             "ColorChooser.panels", new UIDefaults.ActiveValue() {
420                 public Object JavaDoc createValue(UIDefaults table) {
421                     return new AbstractColorChooserPanel[] {
422                                        new GTKColorChooserPanel() };
423                 }
424             },
425             "ColorChooser.font", new FontLazyValue(Region.COLOR_CHOOSER),
426
427
428         "ComboBox.ancestorInputMap",
429            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
430              "ESCAPE", "hidePopup",
431             "PAGE_UP", "pageUpPassThrough",
432           "PAGE_DOWN", "pageDownPassThrough",
433                "HOME", "homePassThrough",
434                 "END", "endPassThrough",
435                "DOWN", "selectNext",
436             "KP_DOWN", "selectNext",
437            "alt DOWN", "togglePopup",
438         "alt KP_DOWN", "togglePopup",
439              "alt UP", "togglePopup",
440           "alt KP_UP", "togglePopup",
441               "SPACE", "spacePopup",
442                       "ENTER", "enterPressed",
443                  "UP", "selectPrevious",
444               "KP_UP", "selectPrevious"
445
446          }),
447             "ComboBox.font", new FontLazyValue(Region.COMBO_BOX),
448
449
450             "EditorPane.caretForeground", caretColor,
451             "EditorPane.caretAspectRatio", defaultCaretAspectRatio,
452             "EditorPane.caretBlinkRate", caretBlinkRate,
453             "EditorPane.margin", editorMargin,
454             "EditorPane.focusInputMap", multilineInputMap,
455             "EditorPane.font", new FontLazyValue(Region.EDITOR_PANE),
456
457
458         "FileChooser.ancestorInputMap",
459            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
460              "ESCAPE", "cancelSelection"
461          }),
462             "FileChooserUI", "com.sun.java.swing.plaf.gtk.GTKLookAndFeel",
463
464
465             "FormattedTextField.caretForeground", caretColor,
466             "FormattedTextField.caretAspectRatio", defaultCaretAspectRatio,
467             "FormattedTextField.caretBlinkRate", caretBlinkRate,
468         "FormattedTextField.focusInputMap",
469               new UIDefaults.LazyInputMap(new Object JavaDoc[] {
470                            "ctrl C", DefaultEditorKit.copyAction,
471                            "ctrl V", DefaultEditorKit.pasteAction,
472                            "ctrl X", DefaultEditorKit.cutAction,
473                              "COPY", DefaultEditorKit.copyAction,
474                             "PASTE", DefaultEditorKit.pasteAction,
475                               "CUT", DefaultEditorKit.cutAction,
476                        "shift LEFT", DefaultEditorKit.selectionBackwardAction,
477                     "shift KP_LEFT", DefaultEditorKit.selectionBackwardAction,
478                       "shift RIGHT", DefaultEditorKit.selectionForwardAction,
479                    "shift KP_RIGHT", DefaultEditorKit.selectionForwardAction,
480                         "ctrl LEFT", DefaultEditorKit.previousWordAction,
481                      "ctrl KP_LEFT", DefaultEditorKit.previousWordAction,
482                        "ctrl RIGHT", DefaultEditorKit.nextWordAction,
483                     "ctrl KP_RIGHT", DefaultEditorKit.nextWordAction,
484                   "ctrl shift LEFT", DefaultEditorKit.selectionPreviousWordAction,
485                "ctrl shift KP_LEFT", DefaultEditorKit.selectionPreviousWordAction,
486                  "ctrl shift RIGHT", DefaultEditorKit.selectionNextWordAction,
487               "ctrl shift KP_RIGHT", DefaultEditorKit.selectionNextWordAction,
488                            "ctrl A", DefaultEditorKit.selectAllAction,
489                              "HOME", DefaultEditorKit.beginLineAction,
490                               "END", DefaultEditorKit.endLineAction,
491                        "shift HOME", DefaultEditorKit.selectionBeginLineAction,
492                         "shift END", DefaultEditorKit.selectionEndLineAction,
493                        "BACK_SPACE", DefaultEditorKit.deletePrevCharAction,
494                            "ctrl H", DefaultEditorKit.deletePrevCharAction,
495                            "DELETE", DefaultEditorKit.deleteNextCharAction,
496                             "RIGHT", DefaultEditorKit.forwardAction,
497                              "LEFT", DefaultEditorKit.backwardAction,
498                          "KP_RIGHT", DefaultEditorKit.forwardAction,
499                           "KP_LEFT", DefaultEditorKit.backwardAction,
500                             "ENTER", JTextField.notifyAction,
501                   "ctrl BACK_SLASH", "unselect",
502                   "control shift O", "toggle-componentOrientation",
503                            "ESCAPE", "reset-field-edit",
504                                "UP", "increment",
505                             "KP_UP", "increment",
506                              "DOWN", "decrement",
507                           "KP_DOWN", "decrement",
508               }),
509             "FormattedTextField.font",
510                 new FontLazyValue(Region.FORMATTED_TEXT_FIELD),
511
512
513         "InternalFrameTitlePane.titlePaneLayout",
514                 new GTKStyle.GTKLazyValue("com.sun.java.swing.plaf.gtk.Metacity",
515                          "getTitlePaneLayout"),
516             "InternalFrame.windowBindings", new Object JavaDoc[] {
517                   "shift ESCAPE", "showSystemMenu",
518                     "ctrl SPACE", "showSystemMenu",
519                         "ESCAPE", "hideSystemMenu" },
520             "InternalFrame.layoutTitlePaneAtOrigin", Boolean.TRUE,
521             "InternalFrame.useTaskBar", Boolean.TRUE,
522
523             "Label.font", new FontLazyValue(Region.LABEL),
524
525             "List.focusCellHighlightBorder", focusBorder,
526             "List.focusSelectedCellHighlightBorder", focusSelectedBorder,
527         "List.focusInputMap",
528            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
529                            "ctrl C", "copy",
530                            "ctrl V", "paste",
531                            "ctrl X", "cut",
532                              "COPY", "copy",
533                             "PASTE", "paste",
534                               "CUT", "cut",
535                        "UP", "selectPreviousRow",
536                     "KP_UP", "selectPreviousRow",
537                  "shift UP", "selectPreviousRowExtendSelection",
538               "shift KP_UP", "selectPreviousRowExtendSelection",
539                     "ctrl shift UP", "selectPreviousRowExtendSelection",
540                  "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
541                           "ctrl UP", "selectPreviousRowChangeLead",
542                        "ctrl KP_UP", "selectPreviousRowChangeLead",
543                      "DOWN", "selectNextRow",
544                   "KP_DOWN", "selectNextRow",
545                "shift DOWN", "selectNextRowExtendSelection",
546             "shift KP_DOWN", "selectNextRowExtendSelection",
547                   "ctrl shift DOWN", "selectNextRowExtendSelection",
548                "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
549                         "ctrl DOWN", "selectNextRowChangeLead",
550                      "ctrl KP_DOWN", "selectNextRowChangeLead",
551                      "LEFT", "selectPreviousColumn",
552                   "KP_LEFT", "selectPreviousColumn",
553                "shift LEFT", "selectPreviousColumnExtendSelection",
554             "shift KP_LEFT", "selectPreviousColumnExtendSelection",
555                   "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
556                "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
557                         "ctrl LEFT", "selectPreviousColumnChangeLead",
558                      "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
559                     "RIGHT", "selectNextColumn",
560                  "KP_RIGHT", "selectNextColumn",
561               "shift RIGHT", "selectNextColumnExtendSelection",
562            "shift KP_RIGHT", "selectNextColumnExtendSelection",
563                  "ctrl shift RIGHT", "selectNextColumnExtendSelection",
564               "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
565                        "ctrl RIGHT", "selectNextColumnChangeLead",
566                     "ctrl KP_RIGHT", "selectNextColumnChangeLead",
567                      "HOME", "selectFirstRow",
568                "shift HOME", "selectFirstRowExtendSelection",
569                   "ctrl shift HOME", "selectFirstRowExtendSelection",
570                         "ctrl HOME", "selectFirstRowChangeLead",
571                       "END", "selectLastRow",
572                 "shift END", "selectLastRowExtendSelection",
573                    "ctrl shift END", "selectLastRowExtendSelection",
574                          "ctrl END", "selectLastRowChangeLead",
575                   "PAGE_UP", "scrollUp",
576             "shift PAGE_UP", "scrollUpExtendSelection",
577                "ctrl shift PAGE_UP", "scrollUpExtendSelection",
578                      "ctrl PAGE_UP", "scrollUpChangeLead",
579                 "PAGE_DOWN", "scrollDown",
580           "shift PAGE_DOWN", "scrollDownExtendSelection",
581              "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
582                    "ctrl PAGE_DOWN", "scrollDownChangeLead",
583                    "ctrl A", "selectAll",
584                "ctrl SLASH", "selectAll",
585           "ctrl BACK_SLASH", "clearSelection",
586                             "SPACE", "addToSelection",
587                        "ctrl SPACE", "toggleAndAnchor",
588                       "shift SPACE", "extendTo",
589                  "ctrl shift SPACE", "moveSelectionTo"
590          }),
591         "List.focusInputMap.RightToLeft",
592            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
593                      "LEFT", "selectNextColumn",
594                   "KP_LEFT", "selectNextColumn",
595                "shift LEFT", "selectNextColumnExtendSelection",
596             "shift KP_LEFT", "selectNextColumnExtendSelection",
597                   "ctrl shift LEFT", "selectNextColumnExtendSelection",
598                "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
599                         "ctrl LEFT", "selectNextColumnChangeLead",
600                      "ctrl KP_LEFT", "selectNextColumnChangeLead",
601                     "RIGHT", "selectPreviousColumn",
602                  "KP_RIGHT", "selectPreviousColumn",
603               "shift RIGHT", "selectPreviousColumnExtendSelection",
604            "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
605                  "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
606               "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
607                        "ctrl RIGHT", "selectPreviousColumnChangeLead",
608                     "ctrl KP_RIGHT", "selectPreviousColumnChangeLead",
609          }),
610             "List.font", new FontLazyValue(Region.LIST),
611
612
613         "Menu.shortcutKeys", new int[] {KeyEvent.ALT_MASK},
614             "Menu.arrowIcon", new GTKStyle.GTKLazyValue(
615                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
616                               "getMenuArrowIcon"),
617             "Menu.font", new FontLazyValue(Region.MENU),
618             "Menu.margin", zeroInsets,
619
620
621         "MenuBar.windowBindings", new Object JavaDoc[] {
622         "F10", "takeFocus" },
623             "MenuBar.font", new FontLazyValue(Region.MENU_BAR),
624
625
626             "MenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
627                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
628                               "getMenuItemArrowIcon"),
629             "MenuItem.font", new FontLazyValue(Region.MENU_ITEM),
630             "MenuItem.margin", zeroInsets,
631
632
633             "OptionPane.setButtonMargin", Boolean.FALSE,
634             "OptionPane.sameSizeButtons", Boolean.TRUE,
635             "OptionPane.buttonOrientation", new Integer JavaDoc(SwingConstants.RIGHT),
636             "OptionPane.minimumSize", new DimensionUIResource(262, 90),
637             "OptionPane.buttonPadding", new Integer JavaDoc(10),
638         "OptionPane.windowBindings", new Object JavaDoc[] {
639         "ESCAPE", "close" },
640         "OptionPane.buttonClickThreshhold", new Integer JavaDoc(500),
641             "OptionPane.isYesLast", Boolean.TRUE,
642             "OptionPane.font", new FontLazyValue(Region.OPTION_PANE),
643
644             "Panel.font", new FontLazyValue(Region.PANEL),
645
646             "PasswordField.caretForeground", caretColor,
647             "PasswordField.caretAspectRatio", defaultCaretAspectRatio,
648             "PasswordField.caretBlinkRate", caretBlinkRate,
649             "PasswordField.margin", zeroInsets,
650             "PasswordField.focusInputMap", passwordInputMap,
651             "PasswordField.font", new FontLazyValue(Region.PASSWORD_FIELD),
652
653
654             "PopupMenu.consumeEventOnClose", Boolean.TRUE,
655         "PopupMenu.selectedWindowInputMapBindings", new Object JavaDoc[] {
656           "ESCAPE", "cancel",
657                     "DOWN", "selectNext",
658          "KP_DOWN", "selectNext",
659               "UP", "selectPrevious",
660            "KP_UP", "selectPrevious",
661             "LEFT", "selectParent",
662          "KP_LEFT", "selectParent",
663            "RIGHT", "selectChild",
664         "KP_RIGHT", "selectChild",
665            "ENTER", "return",
666            "SPACE", "return"
667         },
668         "PopupMenu.selectedWindowInputMapBindings.RightToLeft",
669                   new Object JavaDoc[] {
670             "LEFT", "selectChild",
671          "KP_LEFT", "selectChild",
672            "RIGHT", "selectParent",
673         "KP_RIGHT", "selectParent",
674         },
675             "PopupMenu.font", new FontLazyValue(Region.POPUP_MENU),
676
677             "ProgressBar.horizontalSize", new DimensionUIResource(146, 16),
678             "ProgressBar.verticalSize", new DimensionUIResource(16, 146),
679             "ProgressBar.font", new FontLazyValue(Region.PROGRESS_BAR),
680
681         "RadioButton.focusInputMap",
682                    new UIDefaults.LazyInputMap(new Object JavaDoc[] {
683                     "SPACE", "pressed",
684                    "released SPACE", "released",
685                            "RETURN", "pressed"
686                }),
687             "RadioButton.icon", new GTKStyle.GTKLazyValue(
688                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
689                               "getRadioButtonIcon"),
690             "RadioButton.font", new FontLazyValue(Region.RADIO_BUTTON),
691
692
693             "RadioButtonMenuItem.arrowIcon", new GTKStyle.GTKLazyValue(
694                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
695                               "getRadioButtonMenuItemArrowIcon"),
696             "RadioButtonMenuItem.checkIcon", new GTKStyle.GTKLazyValue(
697                               "com.sun.java.swing.plaf.gtk.GTKIconFactory",
698                               "getRadioButtonMenuItemCheckIcon"),
699             "RadioButtonMenuItem.font", new FontLazyValue(Region.RADIO_BUTTON_MENU_ITEM),
700             "RadioButtonMenuItem.margin", zeroInsets,
701
702             // These bindings are only enabled when there is a default
703
// button set on the rootpane.
704
"RootPane.defaultButtonWindowKeyBindings", new Object JavaDoc[] {
705                        "ENTER", "press",
706               "released ENTER", "release",
707                   "ctrl ENTER", "press",
708                  "ctrl released ENTER", "release"
709             },
710
711
712             "ScrollBar.squareButtons", Boolean.TRUE,
713             "ScrollBar.thumbHeight", new Integer JavaDoc(14),
714             "ScrollBar.width", new Integer JavaDoc(16),
715             "ScrollBar.minimumThumbSize", new Dimension(8, 8),
716             "ScrollBar.maximumThumbSize", new Dimension(4096, 4096),
717             "ScrollBar.allowsAbsolutePositioning", Boolean.TRUE,
718             "ScrollBar.ancestorInputMap",
719                new UIDefaults.LazyInputMap(new Object JavaDoc[] {
720                "RIGHT", "positiveUnitIncrement",
721             "KP_RIGHT", "positiveUnitIncrement",
722                 "DOWN", "positiveUnitIncrement",
723              "KP_DOWN", "positiveUnitIncrement",
724            "PAGE_DOWN", "positiveBlockIncrement",
725                 "LEFT", "negativeUnitIncrement",
726              "KP_LEFT", "negativeUnitIncrement",
727                   "UP", "negativeUnitIncrement",
728                "KP_UP", "negativeUnitIncrement",
729              "PAGE_UP", "negativeBlockIncrement",
730                 "HOME", "minScroll",
731                  "END", "maxScroll"
732                    }),
733             "ScrollBar.ancestorInputMap.RightToLeft",
734                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
735                "RIGHT", "negativeUnitIncrement",
736             "KP_RIGHT", "negativeUnitIncrement",
737                 "LEFT", "positiveUnitIncrement",
738              "KP_LEFT", "positiveUnitIncrement",
739                     }),
740
741
742             "ScrollPane.ancestorInputMap",
743                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
744                    "RIGHT", "unitScrollRight",
745                 "KP_RIGHT", "unitScrollRight",
746                     "DOWN", "unitScrollDown",
747                  "KP_DOWN", "unitScrollDown",
748                     "LEFT", "unitScrollLeft",
749                  "KP_LEFT", "unitScrollLeft",
750                       "UP", "unitScrollUp",
751                    "KP_UP", "unitScrollUp",
752                  "PAGE_UP", "scrollUp",
753                "PAGE_DOWN", "scrollDown",
754             "ctrl PAGE_UP", "scrollLeft",
755           "ctrl PAGE_DOWN", "scrollRight",
756                "ctrl HOME", "scrollHome",
757                 "ctrl END", "scrollEnd"
758                     }),
759             "ScrollPane.ancestorInputMap.RightToLeft",
760                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
761             "ctrl PAGE_UP", "scrollRight",
762           "ctrl PAGE_DOWN", "scrollLeft",
763                     }),
764             "ScrollPane.font", new FontLazyValue(Region.SCROLL_PANE),
765
766
767             "Separator.insets", zeroInsets,
768             "Separator.thickness", new Integer JavaDoc(2),
769
770
771             "Slider.paintValue", Boolean.TRUE,
772             "Slider.thumbWidth", new Integer JavaDoc(30),
773             "Slider.thumbHeight", new Integer JavaDoc(14),
774             "Slider.focusInputMap",
775                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
776                             "RIGHT", "positiveUnitIncrement",
777                          "KP_RIGHT", "positiveUnitIncrement",
778                              "DOWN", "negativeUnitIncrement",
779                           "KP_DOWN", "negativeUnitIncrement",
780                         "PAGE_DOWN", "negativeBlockIncrement",
781                              "LEFT", "negativeUnitIncrement",
782                           "KP_LEFT", "negativeUnitIncrement",
783                                "UP", "positiveUnitIncrement",
784                             "KP_UP", "positiveUnitIncrement",
785                           "PAGE_UP", "positiveBlockIncrement",
786                              "HOME", "minScroll",
787                               "END", "maxScroll"
788                         }),
789             "Slider.focusInputMap.RightToLeft",
790                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
791                             "RIGHT", "negativeUnitIncrement",
792                          "KP_RIGHT", "negativeUnitIncrement",
793                              "LEFT", "positiveUnitIncrement",
794                           "KP_LEFT", "positiveUnitIncrement",
795                          }),
796
797
798             "Spinner.ancestorInputMap",
799            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
800                                "UP", "increment",
801                             "KP_UP", "increment",
802                              "DOWN", "decrement",
803                           "KP_DOWN", "decrement",
804                }),
805             "Spinner.font", new FontLazyValue(Region.SPINNER),
806
807
808             "SplitPane.ancestorInputMap",
809                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
810                 "UP", "negativeIncrement",
811               "DOWN", "positiveIncrement",
812               "LEFT", "negativeIncrement",
813              "RIGHT", "positiveIncrement",
814              "KP_UP", "negativeIncrement",
815            "KP_DOWN", "positiveIncrement",
816            "KP_LEFT", "negativeIncrement",
817           "KP_RIGHT", "positiveIncrement",
818               "HOME", "selectMin",
819                "END", "selectMax",
820                 "F8", "startResize",
821                 "F6", "toggleFocus",
822           "ctrl TAB", "focusOutForward",
823         "ctrl shift TAB", "focusOutBackward"
824                     }),
825
826
827             "SplitPane.size", new Integer JavaDoc(7),
828             "SplitPane.oneTouchOffset", new Integer JavaDoc(2),
829             "SplitPane.oneTouchButtonSize", new Integer JavaDoc(5),
830             "SplitPane.supportsOneTouchButtons", Boolean.FALSE,
831
832
833         "TabbedPane.focusInputMap",
834           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
835                  "RIGHT", "navigateRight",
836                   "KP_RIGHT", "navigateRight",
837                       "LEFT", "navigateLeft",
838                    "KP_LEFT", "navigateLeft",
839                         "UP", "navigateUp",
840                      "KP_UP", "navigateUp",
841                       "DOWN", "navigateDown",
842                    "KP_DOWN", "navigateDown",
843                  "ctrl DOWN", "requestFocusForVisibleComponent",
844               "ctrl KP_DOWN", "requestFocusForVisibleComponent",
845              "SPACE", "selectTabWithFocus"
846         }),
847         "TabbedPane.ancestorInputMap",
848            new UIDefaults.LazyInputMap(new Object JavaDoc[] {
849                  "ctrl TAB", "navigateNext",
850            "ctrl shift TAB", "navigatePrevious",
851            "ctrl PAGE_DOWN", "navigatePageDown",
852                  "ctrl PAGE_UP", "navigatePageUp",
853                       "ctrl UP", "requestFocus",
854                    "ctrl KP_UP", "requestFocus",
855          }),
856
857             "TabbedPane.selectionFollowsFocus", Boolean.FALSE,
858             "TabbedPane.font", new FontLazyValue(Region.TABBED_PANE),
859
860             "Table.focusCellBackground", tableFocusCellBg,
861             "Table.focusCellForeground", tableFocusCellFg,
862             "Table.focusCellHighlightBorder", focusBorder,
863             "Table.focusSelectedCellHighlightBorder", focusSelectedBorder,
864             "Table.ancestorInputMap",
865                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
866                                "ctrl C", "copy",
867                                "ctrl V", "paste",
868                                "ctrl X", "cut",
869                                  "COPY", "copy",
870                                 "PASTE", "paste",
871                                   "CUT", "cut",
872                                 "RIGHT", "selectNextColumn",
873                              "KP_RIGHT", "selectNextColumn",
874                           "shift RIGHT", "selectNextColumnExtendSelection",
875                        "shift KP_RIGHT", "selectNextColumnExtendSelection",
876                      "ctrl shift RIGHT", "selectNextColumnExtendSelection",
877                   "ctrl shift KP_RIGHT", "selectNextColumnExtendSelection",
878                            "ctrl RIGHT", "selectNextColumnChangeLead",
879                         "ctrl KP_RIGHT", "selectNextColumnChangeLead",
880                                  "LEFT", "selectPreviousColumn",
881                               "KP_LEFT", "selectPreviousColumn",
882                            "shift LEFT", "selectPreviousColumnExtendSelection",
883                         "shift KP_LEFT", "selectPreviousColumnExtendSelection",
884                       "ctrl shift LEFT", "selectPreviousColumnExtendSelection",
885                    "ctrl shift KP_LEFT", "selectPreviousColumnExtendSelection",
886                             "ctrl LEFT", "selectPreviousColumnChangeLead",
887                          "ctrl KP_LEFT", "selectPreviousColumnChangeLead",
888                                  "DOWN", "selectNextRow",
889                               "KP_DOWN", "selectNextRow",
890                            "shift DOWN", "selectNextRowExtendSelection",
891                         "shift KP_DOWN", "selectNextRowExtendSelection",
892                       "ctrl shift DOWN", "selectNextRowExtendSelection",
893                    "ctrl shift KP_DOWN", "selectNextRowExtendSelection",
894                             "ctrl DOWN", "selectNextRowChangeLead",
895                          "ctrl KP_DOWN", "selectNextRowChangeLead",
896                                    "UP", "selectPreviousRow",
897                                 "KP_UP", "selectPreviousRow",
898                              "shift UP", "selectPreviousRowExtendSelection",
899                           "shift KP_UP", "selectPreviousRowExtendSelection",
900                         "ctrl shift UP", "selectPreviousRowExtendSelection",
901                      "ctrl shift KP_UP", "selectPreviousRowExtendSelection",
902                               "ctrl UP", "selectPreviousRowChangeLead",
903                            "ctrl KP_UP", "selectPreviousRowChangeLead",
904                                  "HOME", "selectFirstColumn",
905                            "shift HOME", "selectFirstColumnExtendSelection",
906                       "ctrl shift HOME", "selectFirstRowExtendSelection",
907                             "ctrl HOME", "selectFirstRow",
908                                   "END", "selectLastColumn",
909                             "shift END", "selectLastColumnExtendSelection",
910                        "ctrl shift END", "selectLastRowExtendSelection",
911                              "ctrl END", "selectLastRow",
912                               "PAGE_UP", "scrollUpChangeSelection",
913                         "shift PAGE_UP", "scrollUpExtendSelection",
914                    "ctrl shift PAGE_UP", "scrollLeftExtendSelection",
915                          "ctrl PAGE_UP", "scrollLeftChangeSelection",
916                             "PAGE_DOWN", "scrollDownChangeSelection",
917                       "shift PAGE_DOWN", "scrollDownExtendSelection",
918                  "ctrl shift PAGE_DOWN", "scrollRightExtendSelection",
919                        "ctrl PAGE_DOWN", "scrollRightChangeSelection",
920                                   "TAB", "selectNextColumnCell",
921                             "shift TAB", "selectPreviousColumnCell",
922                                 "ENTER", "selectNextRowCell",
923                           "shift ENTER", "selectPreviousRowCell",
924                                "ctrl A", "selectAll",
925                            "ctrl SLASH", "selectAll",
926                       "ctrl BACK_SLASH", "clearSelection",
927                                "ESCAPE", "cancel",
928                                    "F2", "startEditing",
929                                 "SPACE", "addToSelection",
930                            "ctrl SPACE", "toggleAndAnchor",
931                           "shift SPACE", "extendTo",
932                      "ctrl shift SPACE", "moveSelectionTo"
933                     }),
934             "Table.ancestorInputMap.RightToLeft",
935                     new UIDefaults.LazyInputMap(new Object JavaDoc[] {
936                                 "RIGHT", "selectPreviousColumn",
937                              "KP_RIGHT", "selectPreviousColumn",
938                           "shift RIGHT", "selectPreviousColumnExtendSelection",
939                        "shift KP_RIGHT", "selectPreviousColumnExtendSelection",
940                      "ctrl shift RIGHT", "selectPreviousColumnExtendSelection",
941                   "ctrl shift KP_RIGHT", "selectPreviousColumnExtendSelection",
942                           "shift RIGHT", "selectPreviousColumnChangeLead",
943                        "shift KP_RIGHT", "selectPreviousColumnChangeLead",
944                                  "LEFT", "selectNextColumn",
945                               "KP_LEFT", "selectNextColumn",
946                            "shift LEFT", "selectNextColumnExtendSelection",
947                         "shift KP_LEFT", "selectNextColumnExtendSelection",
948                       "ctrl shift LEFT", "selectNextColumnExtendSelection",
949                    "ctrl shift KP_LEFT", "selectNextColumnExtendSelection",
950                             "ctrl LEFT", "selectNextColumnChangeLead",
951                          "ctrl KP_LEFT", "selectNextColumnChangeLead",
952                          "ctrl PAGE_UP", "scrollRightChangeSelection",
953                        "ctrl PAGE_DOWN", "scrollLeftChangeSelection",
954                    "ctrl shift PAGE_UP", "scrollRightExtendSelection",
955                  "ctrl shift PAGE_DOWN", "scrollLeftExtendSelection",
956                     }),
957             "Table.font", new FontLazyValue(Region.TABLE),
958             
959             "TableHeader.font", new FontLazyValue(Region.TABLE_HEADER),
960
961             "TextArea.caretForeground", caretColor,
962             "TextArea.caretAspectRatio", defaultCaretAspectRatio,
963             "TextArea.caretBlinkRate", caretBlinkRate,
964             "TextArea.margin", zeroInsets,
965             "TextArea.focusInputMap", multilineInputMap,
966             "TextArea.font", new FontLazyValue(Region.TEXT_AREA),
967
968
969             "TextField.caretForeground", caretColor,
970             "TextField.caretAspectRatio", defaultCaretAspectRatio,
971             "TextField.caretBlinkRate", caretBlinkRate,
972             "TextField.margin", zeroInsets,
973             "TextField.focusInputMap", fieldInputMap,
974             "TextField.font", new FontLazyValue(Region.TEXT_FIELD),
975
976
977             "TextPane.caretForeground", caretColor,
978             "TextPane.caretAspectRatio", defaultCaretAspectRatio,
979             "TextPane.caretBlinkRate", caretBlinkRate,
980             "TextPane.margin", editorMargin,
981             "TextPane.focusInputMap", multilineInputMap,
982             "TextPane.font", new FontLazyValue(Region.TEXT_PANE),
983
984
985             "TitledBorder.titleColor", new ColorUIResource(Color.BLACK),
986             "TitledBorder.border", new UIDefaults.ProxyLazyValue(
987                       "javax.swing.plaf.BorderUIResource",
988                       "getEtchedBorderUIResource"),
989
990         "ToggleButton.focusInputMap",
991                    new UIDefaults.LazyInputMap(new Object JavaDoc[] {
992                     "SPACE", "pressed",
993                    "released SPACE", "released"
994                }),
995             "ToggleButton.font", new FontLazyValue(Region.TOGGLE_BUTTON),
996
997
998             "ToolBar.separatorSize", new DimensionUIResource(10, 10),
999             "ToolBar.handleIcon", new UIDefaults.ActiveValue() {
1000                public Object JavaDoc createValue(UIDefaults table) {
1001                    return GTKIconFactory.getToolBarHandleIcon();
1002                }
1003            },
1004        "ToolBar.ancestorInputMap",
1005           new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1006                "UP", "navigateUp",
1007             "KP_UP", "navigateUp",
1008              "DOWN", "navigateDown",
1009           "KP_DOWN", "navigateDown",
1010              "LEFT", "navigateLeft",
1011           "KP_LEFT", "navigateLeft",
1012             "RIGHT", "navigateRight",
1013          "KP_RIGHT", "navigateRight"
1014         }),
1015            "ToolBar.font", new FontLazyValue(Region.TOOL_BAR),
1016
1017            "ToolTip.font", new FontLazyValue(Region.TOOL_TIP),
1018
1019            "Tree.padding", new Integer JavaDoc(4),
1020            "Tree.drawHorizontalLines", Boolean.FALSE,
1021            "Tree.drawVerticalLines", Boolean.FALSE,
1022            "Tree.rowHeight", new Integer JavaDoc(-1),
1023            "Tree.scrollsOnExpand", Boolean.FALSE,
1024            "Tree.expanderSize", new Integer JavaDoc(10),
1025        "Tree.closedIcon", null,
1026        "Tree.leafIcon", null,
1027        "Tree.openIcon", null,
1028            "Tree.expandedIcon", new GTKStyle.GTKLazyValue(
1029                              "com.sun.java.swing.plaf.gtk.GTKIconFactory",
1030                              "getTreeExpandedIcon"),
1031            "Tree.collapsedIcon", new GTKStyle.GTKLazyValue(
1032                              "com.sun.java.swing.plaf.gtk.GTKIconFactory",
1033                              "getTreeCollapsedIcon"),
1034            "Tree.leftChildIndent", new Integer JavaDoc(2),
1035            "Tree.rightChildIndent", new Integer JavaDoc(12),
1036            "Tree.scrollsHorizontallyAndVertically", Boolean.FALSE,
1037            "Tree.drawsFocusBorder", Boolean.TRUE,
1038            "Tree.focusInputMap",
1039                    new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1040                                 "ctrl C", "copy",
1041                                 "ctrl V", "paste",
1042                                 "ctrl X", "cut",
1043                                   "COPY", "copy",
1044                                  "PASTE", "paste",
1045                                    "CUT", "cut",
1046                             "UP", "selectPrevious",
1047                          "KP_UP", "selectPrevious",
1048                       "shift UP", "selectPreviousExtendSelection",
1049                    "shift KP_UP", "selectPreviousExtendSelection",
1050                          "ctrl shift UP", "selectPreviousExtendSelection",
1051                       "ctrl shift KP_UP", "selectPreviousExtendSelection",
1052                                "ctrl UP", "selectPreviousChangeLead",
1053                             "ctrl KP_UP", "selectPreviousChangeLead",
1054                           "DOWN", "selectNext",
1055                        "KP_DOWN", "selectNext",
1056                     "shift DOWN", "selectNextExtendSelection",
1057                  "shift KP_DOWN", "selectNextExtendSelection",
1058                        "ctrl shift DOWN", "selectNextExtendSelection",
1059                     "ctrl shift KP_DOWN", "selectNextExtendSelection",
1060                              "ctrl DOWN", "selectNextChangeLead",
1061                           "ctrl KP_DOWN", "selectNextChangeLead",
1062                          "RIGHT", "selectChild",
1063                       "KP_RIGHT", "selectChild",
1064                           "LEFT", "selectParent",
1065                        "KP_LEFT", "selectParent",
1066                                "typed +", "expand",
1067                                "typed -", "collapse",
1068                             "BACK_SPACE", "moveSelectionToParent",
1069                        "PAGE_UP", "scrollUpChangeSelection",
1070                  "shift PAGE_UP", "scrollUpExtendSelection",
1071                     "ctrl shift PAGE_UP", "scrollUpExtendSelection",
1072                           "ctrl PAGE_UP", "scrollUpChangeLead",
1073                      "PAGE_DOWN", "scrollDownChangeSelection",
1074                "shift PAGE_DOWN", "scrollDownExtendSelection",
1075                   "ctrl shift PAGE_DOWN", "scrollDownExtendSelection",
1076                         "ctrl PAGE_DOWN", "scrollDownChangeLead",
1077                           "HOME", "selectFirst",
1078                     "shift HOME", "selectFirstExtendSelection",
1079                        "ctrl shift HOME", "selectFirstExtendSelection",
1080                              "ctrl HOME", "selectFirstChangeLead",
1081                            "END", "selectLast",
1082                      "shift END", "selectLastExtendSelection",
1083                         "ctrl shift END", "selectLastExtendSelection",
1084                               "ctrl END", "selectLastChangeLead",
1085                             "F2", "startEditing",
1086                         "ctrl A", "selectAll",
1087                     "ctrl SLASH", "selectAll",
1088                "ctrl BACK_SLASH", "clearSelection",
1089                      "ctrl LEFT", "scrollLeft",
1090                   "ctrl KP_LEFT", "scrollLeft",
1091                     "ctrl RIGHT", "scrollRight",
1092                  "ctrl KP_RIGHT", "scrollRight",
1093                                  "SPACE", "addToSelection",
1094                             "ctrl SPACE", "toggleAndAnchor",
1095                            "shift SPACE", "extendTo",
1096                       "ctrl shift SPACE", "moveSelectionTo"
1097                    }),
1098            "Tree.focusInputMap.RightToLeft",
1099                    new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1100                          "RIGHT", "selectParent",
1101                       "KP_RIGHT", "selectParent",
1102                           "LEFT", "selectChild",
1103                        "KP_LEFT", "selectChild",
1104         }),
1105            "Tree.ancestorInputMap",
1106                      new UIDefaults.LazyInputMap(new Object JavaDoc[] {
1107                 "ESCAPE", "cancel"
1108                      }),
1109            "Tree.font", new FontLazyValue(Region.TREE),
1110            
1111            "Viewport.font", new FontLazyValue(Region.VIEWPORT)
1112        };
1113    table.putDefaults(defaults);
1114
1115        if (fallbackFont != null) {
1116            table.put("TitledBorder.font", fallbackFont);
1117        }
1118    }
1119
1120    protected void initSystemColorDefaults(UIDefaults table) {
1121        GTKStyleFactory factory = (GTKStyleFactory)getStyleFactory();
1122        GTKStyle windowStyle = (GTKStyle)factory.getStyle("GtkWindow");
1123        table.put("window", windowStyle.getGTKColor(SynthConstants.ENABLED,
1124                                                    GTKColorType.BACKGROUND));
1125        table.put("windowText", windowStyle.getGTKColor(
1126                SynthConstants.ENABLED, GTKColorType.TEXT_FOREGROUND));
1127
1128        GTKStyle entryStyle = (GTKStyle)factory.getStyle("GtkEntry");
1129        table.put("text", entryStyle.getGTKColor(SynthConstants.ENABLED,
1130                                           GTKColorType.TEXT_BACKGROUND));
1131        table.put("textText", entryStyle.getGTKColor(SynthConstants.ENABLED,
1132                                           GTKColorType.TEXT_FOREGROUND));
1133        table.put("textHighlight",
1134                  entryStyle.getGTKColor(SynthConstants.SELECTED,
1135                                         GTKColorType.TEXT_BACKGROUND));
1136        table.put("textHighlightText",
1137                  entryStyle.getGTKColor(SynthConstants.SELECTED,
1138                                         GTKColorType.TEXT_FOREGROUND));
1139        table.put("textInactiveText",
1140                  entryStyle.getGTKColor(SynthConstants.DISABLED,
1141                                         GTKColorType.TEXT_FOREGROUND));
1142        Object JavaDoc caretColor =
1143            entryStyle.getClassSpecificValue(Region.TEXT_FIELD, "cursor-color");
1144        if (caretColor == null) {
1145            caretColor = GTKStyle.BLACK_COLOR;
1146        }
1147        table.put("caretColor", caretColor);
1148        
1149        GTKStyle widgetStyle = (GTKStyle)factory.getStyle("GtkWidget");
1150        table.put("control", widgetStyle.getGTKColor(SynthConstants.ENABLED,
1151                                           GTKColorType.BACKGROUND));
1152        table.put("controlText", widgetStyle.getGTKColor(
1153                      SynthConstants.ENABLED,
1154                      GTKColorType.TEXT_FOREGROUND));
1155        
1156        table.put("controlHighlight", widgetStyle.getGTKColor(
1157                SynthConstants.ENABLED, GTKColorType.BACKGROUND));
1158        table.put("controlLtHighlight", widgetStyle.getGTKColor(
1159                SynthConstants.ENABLED, GTKColorType.LIGHT));
1160        table.put("controlShadow", widgetStyle.getGTKColor(
1161                SynthConstants.ENABLED, GTKColorType.DARK));
1162        table.put("controlDkShadow", widgetStyle.getGTKColor(
1163                SynthConstants.ENABLED, GTKColorType.BLACK));
1164        
1165        
1166        GTKStyle menuStyle = (GTKStyle)factory.getStyle("GtkMenuItem");
1167        table.put("menu", menuStyle.getGTKColor(SynthConstants.ENABLED,
1168                                           GTKColorType.BACKGROUND));
1169        table.put("menuText", menuStyle.getGTKColor(SynthConstants.ENABLED,
1170                                           GTKColorType.TEXT_FOREGROUND));
1171        
1172        GTKStyle scrollbarStyle = (GTKStyle)factory.getStyle("GtkScrollbar");
1173        table.put("scrollbar", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
1174                                           GTKColorType.BACKGROUND));
1175        
1176        GTKStyle infoStyle = (GTKStyle)factory.getStyle("GtkMessageDialog");
1177        table.put("info", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
1178                                           GTKColorType.BACKGROUND));
1179        table.put("infoText", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
1180                                           GTKColorType.TEXT_FOREGROUND));
1181        
1182        GTKStyle desktopStyle = (GTKStyle)factory.getStyle("GtkContainer");
1183        table.put("desktop", scrollbarStyle.getGTKColor(SynthConstants.ENABLED,
1184                                           GTKColorType.BACKGROUND));
1185        
1186        // colors specific only for GTK
1187
table.put("light", widgetStyle.getGTKColor(
1188                SynthConstants.ENABLED, GTKColorType.LIGHT));
1189        table.put("mid", widgetStyle.getGTKColor(
1190                SynthConstants.ENABLED, GTKColorType.MID));
1191        table.put("dark", widgetStyle.getGTKColor(
1192                SynthConstants.ENABLED, GTKColorType.DARK));
1193        table.put("black", widgetStyle.getGTKColor(
1194                SynthConstants.ENABLED, GTKColorType.BLACK));
1195        table.put("white", widgetStyle.getGTKColor(
1196                SynthConstants.ENABLED, GTKColorType.WHITE));
1197    }
1198
1199    /**
1200     * Creates the GTK look and feel class for the passed in Component.
1201     */

1202    public static ComponentUI createUI(JComponent c) {
1203        String JavaDoc key = c.getUIClassID().intern();
1204
1205        if (key == "FileChooserUI") {
1206            return GTKFileChooserUI.createUI(c);
1207    }
1208        return SynthLookAndFeel.createUI(c);
1209    }
1210
1211    /**
1212     * Updates the <code>aaText</code> field.
1213     */

1214    static void updateAAText() {
1215        if (!cjkLocale) {
1216            Object JavaDoc aaValue = Toolkit.getDefaultToolkit().
1217                getDesktopProperty("gnome.Xft/Antialias");
1218            aaText = Boolean.valueOf(((aaValue instanceof Number JavaDoc) &&
1219                                      ((Number JavaDoc)aaValue).intValue() == 1));
1220        }
1221    }
1222
1223    static boolean isLeftToRight(Component c) {
1224        return c.getComponentOrientation().isLeftToRight();
1225    }
1226
1227    private static boolean isLocalDisplay() {
1228        try {
1229            Class JavaDoc x11Class = Class.forName("sun.awt.X11GraphicsEnvironment");
1230            Method isDisplayLocalMethod = x11Class.getMethod(
1231                      "isDisplayLocal", new Class JavaDoc[0]);
1232            return (Boolean JavaDoc)isDisplayLocalMethod.invoke(null, null);
1233        } catch (NoSuchMethodException JavaDoc nsme) {
1234        } catch (ClassNotFoundException JavaDoc cnfe) {
1235        } catch (IllegalAccessException JavaDoc iae) {
1236        } catch (InvocationTargetException ite) {
1237        }
1238        // If we get here we're most likely being run on Windows, return
1239
// false.
1240
return false;
1241    }
1242
1243
1244    public void initialize() {
1245        super.initialize();
1246        inInitialize = true;
1247        loadStylesFromThemeFiles();
1248        inInitialize = false;
1249
1250        Toolkit kit = Toolkit.getDefaultToolkit();
1251        WeakPCL pcl = new WeakPCL(this, kit, "gnome.Net/ThemeName");
1252        kit.addPropertyChangeListener(pcl.getKey(), pcl);
1253        pcl = new WeakPCL(this, kit, "gnome.Gtk/FontName");
1254        kit.addPropertyChangeListener(pcl.getKey(), pcl);
1255        pcl = new WeakPCL(this, kit, "gnome.Xft/DPI");
1256        kit.addPropertyChangeListener(pcl.getKey(), pcl);
1257
1258        String JavaDoc language = Locale.getDefault().getLanguage();
1259        cjkLocale =
1260            (Locale.CHINESE.getLanguage().equals(language) ||
1261             Locale.JAPANESE.getLanguage().equals(language) ||
1262             Locale.KOREAN.getLanguage().equals(language));
1263
1264        if (isLocalDisplay()) {
1265            pcl = new WeakPCL(this, kit, "gnome.Xft/Antialias");
1266            kit.addPropertyChangeListener(pcl.getKey(), pcl);
1267            updateAAText();
1268        }
1269        flushUnreferenced();
1270    }
1271
1272    static ReferenceQueue queue = new ReferenceQueue();
1273
1274    static void flushUnreferenced() {
1275        WeakPCL pcl;
1276
1277        while ((pcl = (WeakPCL)queue.poll()) != null) {
1278            pcl.dispose();
1279        }
1280    }
1281
1282    static class WeakPCL extends WeakReference implements
1283            PropertyChangeListener {
1284        private Toolkit kit;
1285        private String JavaDoc key;
1286
1287        WeakPCL(Object JavaDoc target, Toolkit kit, String JavaDoc key) {
1288            super(target, queue);
1289            this.kit = kit;
1290            this.key = key;
1291        }
1292
1293        public String JavaDoc getKey() { return key; }
1294
1295        public void propertyChange(final PropertyChangeEvent pce) {
1296            final GTKLookAndFeel lnf = (GTKLookAndFeel)get();
1297
1298            if (lnf == null || UIManager.getLookAndFeel() != lnf) {
1299                // The property was GC'ed, we're no longer interested in
1300
// PropertyChanges, remove the listener.
1301
dispose();
1302            }
1303            else {
1304                // We are using invokeLater here because we are getting called
1305
// on the AWT-Motif thread which can cause a deadlock.
1306
SwingUtilities.invokeLater(new Runnable JavaDoc() {
1307                    public void run() {
1308                        if ("gnome.Xft/Antialias".equals(
1309                                                  pce.getPropertyName())) {
1310                            updateAAText();
1311                        }
1312                        lnf.loadStylesFromThemeFiles();
1313                        Frame appFrames[] = Frame.getFrames();
1314                        for (int i = 0; i < appFrames.length; i++) {
1315                            SynthLookAndFeel.updateStyles(appFrames[i]);
1316                        }
1317                    }
1318                });
1319            }
1320        }
1321
1322        void dispose() {
1323            kit.removePropertyChangeListener(key, this);
1324        }
1325    }
1326
1327    public void propertyChange(PropertyChangeEvent evt) {
1328        String JavaDoc propertyName = evt.getPropertyName();
1329    loadStylesFromThemeFiles();
1330        Frame appFrames[] = Frame.getFrames();
1331        for (int i = 0; i < appFrames.length; i++) {
1332            SynthLookAndFeel.updateStyles(appFrames[i]);
1333        }
1334    }
1335
1336    public boolean isSupportedLookAndFeel() {
1337        return true;
1338    }
1339
1340    public boolean isNativeLookAndFeel() {
1341        return false;
1342    }
1343
1344    public String JavaDoc getDescription() {
1345        return "GTK look and feel";
1346    }
1347
1348    public String JavaDoc getName() {
1349        return "GTK look and feel";
1350    }
1351
1352    public String JavaDoc getID() {
1353        return "GTK";
1354    }
1355
1356    // Subclassed to pass in false to the superclass, we don't want to try
1357
// and load the system colors.
1358
protected void loadSystemColors(UIDefaults table, String JavaDoc[] systemColors, boolean useNative) {
1359        super.loadSystemColors(table, systemColors, false);
1360    }
1361
1362    private void loadStylesFromThemeFiles() {
1363        AccessController.doPrivileged(new PrivilegedAction JavaDoc() {
1364            public Object JavaDoc run() {
1365                GTKParser parser = new GTKParser();
1366
1367                // GTK rc file parsing:
1368
// First, attempts to load the file specified in the
1369
// swing.gtkthemefile system property.
1370
// RC files come from one of the following locations:
1371
// 1 - environment variable GTK2_RC_FILES, which is colon
1372
// separated list of rc files or
1373
// 2 - SYSCONFDIR/gtk-2.0/gtkrc and ~/.gtkrc-2.0
1374
//
1375
// Additionally the default Theme file is parsed last. The default
1376
// theme name comes from the desktop property gnome.Net/ThemeName
1377
// Default theme is looked for in ~/.themes/THEME/gtk-2.0/gtkrc
1378
// and env variable GTK_DATA_PREFIX/THEME/gtkrc or
1379
// GTK_DATA_PREFIX/THEME/gtk-2.0/gtkrc
1380
// (or compiled GTK_DATA_PREFIX) GTK_DATA_PREFIX is
1381
// /usr/share/themes on debian,
1382
// /usr/sfw/share/themes on Solaris.
1383
// Lastly key bindings are supposed to come from a different theme
1384
// with the path built as above, using the desktop property
1385
// named gnome.Gtk/KeyThemeName.
1386

1387                // Try system property override first:
1388
String JavaDoc filename = System.getProperty("swing.gtkthemefile");
1389                String JavaDoc sep = File.separator;
1390
1391                if (filename == null || !parseThemeFile(filename, parser)) {
1392                // Try to load user's theme first
1393
String JavaDoc userHome = System.getProperty("user.home");
1394                if (userHome != null) {
1395                        parseThemeFile(userHome + sep + ".gtkrc-2.0", parser);
1396                }
1397                // Now try to load "Default" theme
1398
String JavaDoc themeName = (String JavaDoc)Toolkit.getDefaultToolkit().
1399                        getDesktopProperty("gnome.Net/ThemeName");
1400                if (themeName == null) {
1401                themeName = "Default";
1402                }
1403                    String JavaDoc[] dirs = new String JavaDoc[] {
1404                        userHome + "/.themes",
1405                        System.getProperty("swing.gtkthemedir"),
1406                        "/usr/share/themes" // Debian/Redhat/Solaris/SuSE
1407
};
1408
1409                    String JavaDoc themeDirName = null;
1410                    // Find the first existing rc file in the list.
1411
for (int i = 0; i < dirs.length; i++) {
1412                        if (dirs[i] == null) {
1413                            continue;
1414                        }
1415
1416                        if (new File JavaDoc(dirs[i] + sep + themeName + sep +
1417                                    "gtk-2.0" + sep + "gtkrc").canRead()) {
1418                            themeDirName = dirs[i];
1419                            break;
1420                        }
1421                    }
1422
1423                    if (themeDirName != null) {
1424                        parseThemeFile(themeDirName + sep + themeName + sep +
1425                                "gtk-2.0" + sep + "gtkrc", parser);
1426                    }
1427            }
1428                setStyleFactory(handleParsedData(parser));
1429                parser.clearParser();
1430        return null;
1431        }
1432    });
1433        // If we are in initialize initializations will be
1434
// called later, don't do it now.
1435
if (!inInitialize) {
1436            UIDefaults table = UIManager.getLookAndFeelDefaults();
1437            initSystemColorDefaults(table);
1438            initComponentDefaults(table);
1439        }
1440    }
1441
1442    private boolean parseThemeFile(String JavaDoc fileName, GTKParser parser) {
1443        File JavaDoc file = new File JavaDoc(fileName);
1444    if (file.exists()) {
1445            try {
1446                parser.parseFile(file, fileName);
1447            } catch (IOException JavaDoc ioe) {
1448                System.err.println("error: (" + ioe.toString()
1449                                   + ") while parsing file: \""
1450                                   + fileName
1451                                   + "\"");
1452            }
1453            return true;
1454    }
1455        return false; // file doesn't exist
1456
}
1457
1458    /**
1459     * This method is responsible for handling the data that was parsed.
1460     * One of it's jobs is to fetch and deal with the GTK settings stored
1461     * in the parser. It's other job is to create a style factory with an
1462     * appropriate default style, load into it the styles from the parser,
1463     * and return that factory.
1464     */

1465    private GTKStyleFactory handleParsedData(GTKParser parser) {
1466        HashMap JavaDoc settings = parser.getGTKSettings();
1467
1468        /*
1469         * The following is a list of the settings that GTK supports and their meanings.
1470         * Currently, we only support a subset ("gtk-font-name" and "gtk-icon-sizes"):
1471         *
1472         * "gtk-can-change-accels" : Whether menu accelerators can be changed
1473         * by pressing a key over the menu item.
1474         * "gtk-color-palette" : Palette to use in the color selector.
1475         * "gtk-cursor-blink" : Whether the cursor should blink.
1476         * "gtk-cursor-blink-time" : Length of the cursor blink cycle, in milleseconds.
1477         * "gtk-dnd-drag-threshold" : Number of pixels the cursor can move before dragging.
1478         * "gtk-double-click-time" : Maximum time allowed between two clicks for them
1479         * to be considered a double click (in milliseconds).
1480         * "gtk-entry-select-on-focus" : Whether to select the contents of an entry when it
1481         * is focused.
1482         * "gtk-font-name" : Name of default font to use.
1483         * "gtk-icon-sizes" : List of icon sizes (gtk-menu=16,16:gtk-button=20,20...
1484         * "gtk-key-theme-name" : Name of key theme RC file to load.
1485         * "gtk-menu-bar-accel" : Keybinding to activate the menu bar.
1486         * "gtk-menu-bar-popup-delay" : Delay before the submenus of a menu bar appear.
1487         * "gtk-menu-popdown-delay" : The time before hiding a submenu when the pointer is
1488         * moving towards the submenu.
1489         * "gtk-menu-popup-delay" : Minimum time the pointer must stay over a menu item
1490         * before the submenu appear.
1491         * "gtk-split-cursor" : Whether two cursors should be displayed for mixed
1492         * left-to-right and right-to-left text.
1493         * "gtk-theme-name" : Name of theme RC file to load.
1494         * "gtk-toolbar-icon-size" : Size of icons in default toolbars.
1495         * "gtk-toolbar-style" : Whether default toolbars have text only, text and icons,
1496         * icons only, etc.
1497         */

1498
1499        Object JavaDoc iconSizes = settings.get("gtk-icon-sizes");
1500        if (iconSizes instanceof String JavaDoc) {
1501            if (!configIconSizes((String JavaDoc)iconSizes)) {
1502                System.err.println("Error parsing gtk-icon-sizes string: '" + iconSizes + "'");
1503            }
1504        }
1505
1506        // Desktop property appears to have preference over rc font.
1507
Object JavaDoc fontName = Toolkit.getDefaultToolkit().getDesktopProperty(
1508                                  "gnome.Gtk/FontName");
1509
1510        if (!(fontName instanceof String JavaDoc)) {
1511            fontName = settings.get("gtk-font-name");
1512            if (!(fontName instanceof String JavaDoc)) {
1513                fontName = "sans 10";
1514            }
1515        }
1516        Font defaultFont = PangoFonts.lookupFont((String JavaDoc)fontName);
1517        GTKStyle defaultStyle = new GTKStyle(defaultFont);
1518        GTKStyleFactory factory = new GTKStyleFactory(defaultStyle);
1519
1520        parser.loadStylesInto(factory);
1521        fallbackFont = defaultFont;
1522        return factory;
1523    }
1524
1525    private boolean configIconSizes(String JavaDoc sizeString) {
1526        String JavaDoc[] sizes = sizeString.split(":");
1527        for (int i = 0; i < sizes.length; i++) {
1528            String JavaDoc[] splits = sizes[i].split("=");
1529
1530            if (splits.length != 2) {
1531                return false;
1532            }
1533            
1534            String JavaDoc size = splits[0].trim().intern();
1535            if (size.length() < 1) {
1536                return false;
1537            }
1538
1539            splits = splits[1].split(",");
1540            
1541            if (splits.length != 2) {
1542                return false;
1543            }
1544            
1545            String JavaDoc width = splits[0].trim();
1546            String JavaDoc height = splits[1].trim();
1547            
1548            if (width.length() < 1 || height.length() < 1) {
1549                return false;
1550            }
1551
1552            int w = 0;
1553            int h = 0;
1554
1555            try {
1556                w = Integer.parseInt(width);
1557                h = Integer.parseInt(height);
1558            } catch (NumberFormatException JavaDoc nfe) {
1559                return false;
1560            }
1561
1562            if (w > 0 && h > 0) {
1563                int type = GTKStyle.GTKStockIconInfo.getIconType(size);
1564                GTKStyle.GTKStockIconInfo.setIconSize(type, w, h);
1565            } else {
1566                System.err.println("Invalid size in gtk-icon-sizes: " + w + "," + h);
1567            }
1568        }
1569        
1570        return true;
1571    }
1572
1573    /**
1574     * Returns whether or not the UIs should update their
1575     * <code>SynthStyles</code> from the <code>SynthStyleFactory</code>
1576     * when the ancestor of the Component changes.
1577     *
1578     * @return whether or not the UIs should update their
1579     * <code>SynthStyles</code> from the <code>SynthStyleFactory</code>
1580     * when the ancestor changed.
1581     */

1582    public boolean shouldUpdateStyleOnAncestorChanged() {
1583        return true;
1584    }
1585}
1586
Popular Tags