示例#1
0
  void paintStripes(GC gc) {

    if (!showStripes) return;

    Rectangle rect = getClientArea();
    // Subtracted border painted by paint.
    rect = new Rectangle(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4);

    gc.setLineWidth(2);
    gc.setClipping(rect);
    Color color = getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
    gc.setBackground(color);
    gc.fillRectangle(rect);
    gc.setForeground(this.getBackground());
    int step = 12;
    int foregroundValue = value == 0 ? step - 2 : value - 2;
    if (orientation == SWT.HORIZONTAL) {
      int y = rect.y - 1;
      int w = rect.width;
      int h = rect.height + 2;
      for (int i = 0; i < w; i += step) {
        int x = i + foregroundValue;
        gc.drawLine(x, y, x, h);
      }
    } else {
      int x = rect.x - 1;
      int w = rect.width + 2;
      int h = rect.height;

      for (int i = 0; i < h; i += step) {
        int y = i + foregroundValue;
        gc.drawLine(x, y, w, y);
      }
    }

    if (active) {
      value = (value + 2) % step;
    }
  }