Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 /**
  * Return icon type (GtkIconSize value) given a symbolic name which can occur in a theme file.
  *
  * @param size symbolic name, e.g. gtk-button
  * @return icon type. Valid types are 1 to 6
  */
 public static int getIconType(String size) {
   if (size == null) {
     return UNDEFINED;
   }
   if (ICON_TYPE_MAP == null) {
     initIconTypeMap();
   }
   Integer n = ICON_TYPE_MAP.get(size);
   return n != null ? n.intValue() : UNDEFINED;
 }
Exemplo n.º 3
0
  @Override
  public Object get(SynthContext context, Object key) {
    // See if this is a class specific value.
    String classKey = CLASS_SPECIFIC_MAP.get(key);
    if (classKey != null) {
      Object value = getClassSpecificValue(classKey);
      if (value != null) {
        return value;
      }
    }

    // Is it a specific value ?
    if (key == "ScrollPane.viewportBorderInsets") {
      return getThicknessInsets(context, new Insets(0, 0, 0, 0));
    } else if (key == "Slider.tickColor") {
      return getColorForState(context, ColorType.FOREGROUND);
    } else if (key == "ScrollBar.minimumThumbSize") {
      int len = getClassSpecificIntValue(context, "min-slider-length", 21);
      JScrollBar sb = (JScrollBar) context.getComponent();
      if (sb.getOrientation() == JScrollBar.HORIZONTAL) {
        return new DimensionUIResource(len, 0);
      } else {
        return new DimensionUIResource(0, len);
      }
    } else if (key == "Separator.thickness") {
      JSeparator sep = (JSeparator) context.getComponent();
      if (sep.getOrientation() == JSeparator.HORIZONTAL) {
        return getYThickness();
      } else {
        return getXThickness();
      }
    } else if (key == "ToolBar.separatorSize") {
      int size = getClassSpecificIntValue(WidgetType.TOOL_BAR, "space-size", 12);
      return new DimensionUIResource(size, size);
    } else if (key == "ScrollBar.buttonSize") {
      JScrollBar sb = (JScrollBar) context.getComponent().getParent();
      boolean horiz = (sb.getOrientation() == JScrollBar.HORIZONTAL);
      WidgetType wt = horiz ? WidgetType.HSCROLL_BAR : WidgetType.VSCROLL_BAR;
      int sliderWidth = getClassSpecificIntValue(wt, "slider-width", 14);
      int stepperSize = getClassSpecificIntValue(wt, "stepper-size", 14);
      return horiz
          ? new DimensionUIResource(stepperSize, sliderWidth)
          : new DimensionUIResource(sliderWidth, stepperSize);
    } else if (key == "ArrowButton.size") {
      String name = context.getComponent().getName();
      if (name != null && name.startsWith("Spinner")) {
        // Believe it or not, the size of a spinner arrow button is
        // dependent upon the size of the spinner's font.  These
        // calculations come from gtkspinbutton.c (version 2.8.20),
        // spin_button_get_arrow_size() method.
        String pangoFontName;
        synchronized (sun.awt.UNIXToolkit.GTK_LOCK) {
          pangoFontName = nativeGetPangoFontName(WidgetType.SPINNER.ordinal());
        }
        int arrowSize = (pangoFontName != null) ? PangoFonts.getFontSize(pangoFontName) : 10;
        return (arrowSize + (getXThickness() * 2));
      }
      // For all other kinds of arrow buttons (e.g. combobox arrow
      // buttons), we will simply fall back on the value of
      // ArrowButton.size as defined in the UIDefaults for
      // GTKLookAndFeel when we call UIManager.get() below...
    } else if ("CheckBox.iconTextGap".equals(key) || "RadioButton.iconTextGap".equals(key)) {
      // The iconTextGap value needs to include "indicator-spacing"
      // and it also needs to leave enough space for the focus line,
      // which falls between the indicator icon and the text.
      // See getRadioInsets() and 6489585 for more details.
      int indicatorSpacing = getClassSpecificIntValue(context, "indicator-spacing", 2);
      int focusSize = getClassSpecificIntValue(context, "focus-line-width", 1);
      int focusPad = getClassSpecificIntValue(context, "focus-padding", 1);
      return indicatorSpacing + focusSize + focusPad;
    }

    // Is it a stock icon ?
    GTKStockIcon stockIcon = null;
    synchronized (ICONS_MAP) {
      stockIcon = ICONS_MAP.get(key);
    }

    if (stockIcon != null) {
      return stockIcon;
    }

    // Is it another kind of value ?
    if (key != "engine") {
      // For backward compatibility we'll fallback to the UIManager.
      // We don't go to the UIManager for engine as the engine is GTK
      // specific.
      Object value = UIManager.get(key);
      if (key == "Table.rowHeight") {
        int focusLineWidth = getClassSpecificIntValue(context, "focus-line-width", 0);
        if (value == null && focusLineWidth > 0) {
          value = Integer.valueOf(16 + 2 * focusLineWidth);
        }
      }
      return value;
    }

    // Don't call super, we don't want to pick up defaults from
    // SynthStyle.
    return null;
  }
Exemplo n.º 4
0
  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));
  }