コード例 #1
0
ファイル: GTKStyle.java プロジェクト: susotajuraj/jdk8u-jdk
  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);
  }
コード例 #2
0
ファイル: GTKStyle.java プロジェクト: susotajuraj/jdk8u-jdk
  @Override
  public Color getColor(SynthContext context, ColorType type) {
    JComponent c = context.getComponent();
    Region id = context.getRegion();
    int state = context.getComponentState();

    if (c.getName() == "Table.cellRenderer") {
      if (type == ColorType.BACKGROUND) {
        return c.getBackground();
      }
      if (type == ColorType.FOREGROUND) {
        return c.getForeground();
      }
    }

    if (id == Region.LABEL && type == ColorType.TEXT_FOREGROUND) {
      type = ColorType.FOREGROUND;
    }

    // For the enabled state, prefer the widget's colors
    if (!id.isSubregion() && (state & SynthConstants.ENABLED) != 0) {
      if (type == ColorType.BACKGROUND) {
        return c.getBackground();
      } else if (type == ColorType.FOREGROUND) {
        return c.getForeground();
      } else if (type == ColorType.TEXT_FOREGROUND) {
        // If getForeground returns a non-UIResource it means the
        // developer has explicitly set the foreground, use it over
        // that of TEXT_FOREGROUND as that is typically the expected
        // behavior.
        Color color = c.getForeground();
        if (color != null && !(color instanceof UIResource)) {
          return color;
        }
      }
    }
    return getColorForState(context, type);
  }