private static void initIconTypeMap() { ICON_TYPE_MAP = new HashMap<String, Integer>(); ICON_TYPE_MAP.put("gtk-menu", Integer.valueOf(1)); ICON_TYPE_MAP.put("gtk-small-toolbar", Integer.valueOf(2)); ICON_TYPE_MAP.put("gtk-large-toolbar", Integer.valueOf(3)); ICON_TYPE_MAP.put("gtk-button", Integer.valueOf(4)); ICON_TYPE_MAP.put("gtk-dnd", Integer.valueOf(5)); ICON_TYPE_MAP.put("gtk-dialog", Integer.valueOf(6)); }
/** * Returns the <code>GTKStyle</code> to use based on the <code>Region</code> id * * @param c this parameter isn't used, may be null. * @param id of the region to get the style. */ public synchronized SynthStyle getStyle(JComponent c, Region id) { WidgetType wt = GTKNativeEngine.getWidgetType(c, id); Object key = null; if (id == Region.SCROLL_BAR) { // The style/insets of a scrollbar can depend on a number of // factors (see GTKStyle.getScrollBarInsets()) so use a // complex key here. if (c != null) { JScrollBar sb = (JScrollBar) c; boolean sp = (sb.getParent() instanceof JScrollPane); boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL); boolean ltr = sb.getComponentOrientation().isLeftToRight(); boolean focusable = sb.isFocusable(); key = new ComplexKey(wt, sp, horiz, ltr, focusable); } } else if (id == Region.CHECK_BOX || id == Region.RADIO_BUTTON) { // The style/insets of a checkbox or radiobutton can depend // on the component orientation, so use a complex key here. if (c != null) { boolean ltr = c.getComponentOrientation().isLeftToRight(); key = new ComplexKey(wt, ltr); } } else if (id == Region.BUTTON) { // The style/insets of a button can depend on whether it is // default capable or in a toolbar, so use a complex key here. if (c != null) { JButton btn = (JButton) c; boolean toolButton = (btn.getParent() instanceof JToolBar); boolean defaultCapable = btn.isDefaultCapable(); key = new ComplexKey(wt, toolButton, defaultCapable); } } if (key == null) { // Otherwise, just use the WidgetType as the key. key = wt; } GTKStyle result = stylesCache.get(key); if (result == null) { result = isNativeGtk ? new GTKNativeStyle(defaultFont, wt) : new GTKDefaultStyle(defaultFont); stylesCache.put(key, result); } return result; }
static { CLASS_SPECIFIC_MAP = new HashMap<String, String>(); CLASS_SPECIFIC_MAP.put("Slider.thumbHeight", "slider-width"); CLASS_SPECIFIC_MAP.put("Slider.trackBorder", "trough-border"); CLASS_SPECIFIC_MAP.put("SplitPane.size", "handle-size"); CLASS_SPECIFIC_MAP.put("Tree.expanderSize", "expander-size"); CLASS_SPECIFIC_MAP.put("ScrollBar.thumbHeight", "slider-width"); CLASS_SPECIFIC_MAP.put("ScrollBar.width", "slider-width"); CLASS_SPECIFIC_MAP.put("TextArea.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("TextArea.caretAspectRatio", "cursor-aspect-ratio"); CLASS_SPECIFIC_MAP.put("TextField.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("TextField.caretAspectRatio", "cursor-aspect-ratio"); CLASS_SPECIFIC_MAP.put("PasswordField.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("PasswordField.caretAspectRatio", "cursor-aspect-ratio"); CLASS_SPECIFIC_MAP.put("FormattedTextField.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("FormattedTextField.caretAspectRatio", "cursor-aspect-"); CLASS_SPECIFIC_MAP.put("TextPane.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("TextPane.caretAspectRatio", "cursor-aspect-ratio"); CLASS_SPECIFIC_MAP.put("EditorPane.caretForeground", "cursor-color"); CLASS_SPECIFIC_MAP.put("EditorPane.caretAspectRatio", "cursor-aspect-ratio"); ICONS_MAP = new HashMap<String, GTKStockIcon>(); ICONS_MAP.put("FileChooser.cancelIcon", new GTKStockIcon("gtk-cancel", 4)); ICONS_MAP.put("FileChooser.okIcon", new GTKStockIcon("gtk-ok", 4)); ICONS_MAP.put("OptionPane.errorIcon", new GTKStockIcon("gtk-dialog-error", 6)); ICONS_MAP.put("OptionPane.informationIcon", new GTKStockIcon("gtk-dialog-info", 6)); ICONS_MAP.put("OptionPane.warningIcon", new GTKStockIcon("gtk-dialog-warning", 6)); ICONS_MAP.put("OptionPane.questionIcon", new GTKStockIcon("gtk-dialog-question", 6)); ICONS_MAP.put("OptionPane.yesIcon", new GTKStockIcon("gtk-yes", 4)); ICONS_MAP.put("OptionPane.noIcon", new GTKStockIcon("gtk-no", 4)); ICONS_MAP.put("OptionPane.cancelIcon", new GTKStockIcon("gtk-cancel", 4)); ICONS_MAP.put("OptionPane.okIcon", new GTKStockIcon("gtk-ok", 4)); }