Beispiel #1
0
 /**
  * Returns color specific to the current style. This method is invoked when other variants don't
  * fit.
  */
 private Color getStyleSpecificColor(SynthContext context, int state, ColorType type) {
   state = GTKLookAndFeel.synthStateToGTKStateType(state).ordinal();
   synchronized (sun.awt.UNIXToolkit.GTK_LOCK) {
     int rgb = nativeGetColorForState(widgetType, state, type.getID());
     return new ColorUIResource(rgb);
   }
 }
Beispiel #2
0
  protected Color getColorForState(SynthContext context, ColorType type) {
    if (type == ColorType.FOCUS || type == GTKColorType.BLACK) {
      return BLACK_COLOR;
    } else if (type == GTKColorType.WHITE) {
      return WHITE_COLOR;
    }

    Region id = context.getRegion();
    int state = context.getComponentState();
    state = GTKLookAndFeel.synthStateToGTKState(id, state);

    if (type == ColorType.TEXT_FOREGROUND
        && (id == Region.BUTTON
            || id == Region.CHECK_BOX
            || id == Region.CHECK_BOX_MENU_ITEM
            || id == Region.MENU
            || id == Region.MENU_ITEM
            || id == Region.RADIO_BUTTON
            || id == Region.RADIO_BUTTON_MENU_ITEM
            || id == Region.TABBED_PANE_TAB
            || id == Region.TOGGLE_BUTTON
            || id == Region.TOOL_TIP
            || id == Region.MENU_ITEM_ACCELERATOR
            || id == Region.TABBED_PANE_TAB)) {
      type = ColorType.FOREGROUND;
    } else if (id == Region.TABLE
        || id == Region.LIST
        || id == Region.TREE
        || id == Region.TREE_CELL) {
      if (type == ColorType.FOREGROUND) {
        type = ColorType.TEXT_FOREGROUND;
        if (state == SynthConstants.PRESSED) {
          state = SynthConstants.SELECTED;
        }
      } else if (type == ColorType.BACKGROUND) {
        type = ColorType.TEXT_BACKGROUND;
      }
    }

    return getStyleSpecificColor(context, state, type);
  }
Beispiel #3
0
  /**
   * Returns the color for the specified state.
   *
   * @param context SynthContext identifying requestor
   * @param state to get the color for
   * @param type of the color
   * @return Color to render with
   */
  Color getGTKColor(SynthContext context, int state, ColorType type) {
    if (context != null) {
      JComponent c = context.getComponent();
      Region id = context.getRegion();

      state = GTKLookAndFeel.synthStateToGTKState(id, state);
      if (!id.isSubregion() && (state & SynthConstants.ENABLED) != 0) {
        if (type == ColorType.BACKGROUND || type == ColorType.TEXT_BACKGROUND) {
          Color bg = c.getBackground();
          if (!(bg instanceof UIResource)) {
            return bg;
          }
        } else if (type == ColorType.FOREGROUND || type == ColorType.TEXT_FOREGROUND) {
          Color fg = c.getForeground();
          if (!(fg instanceof UIResource)) {
            return fg;
          }
        }
      }
    }

    return getStyleSpecificColor(context, state, type);
  }