コード例 #1
0
  /** Paint the Label's border. */
  private void paintBorder(GC gc, Rectangle r) {
    Display disp = getDisplay();

    Color c1 = null;
    Color c2 = null;

    int style = getStyle();
    if ((style & SWT.SHADOW_IN) != 0) {
      c1 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
      c2 = disp.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
    }
    if ((style & SWT.SHADOW_OUT) != 0) {
      c1 = disp.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
      c2 = disp.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
    }

    if (c1 != null && c2 != null) {
      gc.setLineWidth(1);
      drawBevelRect(gc, r.x, r.y, r.width - 1, r.height - 1, c1, c2);
    }
  }
コード例 #2
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;
    }
  }
コード例 #3
0
  private static void paintImage2(GC gc, Point size, int f) {
    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.fillRectangle(0, 0, size.x, size.y);

    // Scale line width, corner roundness, and font size.
    // Caveat: line width expands in all directions, so the origin also has to move.

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_LIST_SELECTION));
    gc.fillRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);

    gc.setBackground(gc.getDevice().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    gc.setLineWidth(f);
    gc.drawRoundRectangle(f / 2, f / 2, size.x - f, size.y - f, 10 * f, 10 * f);
    FontData fontData = gc.getFont().getFontData()[0];
    fontData.setHeight(fontData.getHeight() * f);
    Font font = new Font(gc.getDevice(), fontData);
    try {
      gc.setFont(font);
      gc.drawText(fontData.toString(), 10 * f, 10 * f, true);
    } finally {
      font.dispose();
    }
  }