示例#1
0
 public Point computeSize(int wHint, int hHint, boolean changed) {
   checkWidget();
   Point e = getTotalSize(image, text);
   if (wHint == SWT.DEFAULT) {
     e.x += leftMargin + rightMargin;
   } else {
     e.x = wHint;
   }
   if (hHint == SWT.DEFAULT) {
     e.y += topMargin + bottomMargin;
   } else {
     e.y = hHint;
   }
   return e;
 }
 @Override
 protected Point getInitialSize() {
   Point size = super.getInitialSize();
   if (size.x < MIN_WIDTH) {
     size.x = MIN_WIDTH;
   }
   if (size.y < MIN_HEIGHT) {
     size.y = MIN_HEIGHT;
   }
   return size;
 }
示例#3
0
  public Point computeSize(int wHint, int hHint, boolean changed) {
    checkWidget();
    Point size = null;
    if (orientation == SWT.HORIZONTAL) {
      size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
    } else {
      size = new Point(DEFAULT_HEIGHT, DEFAULT_WIDTH);
    }
    if (wHint != SWT.DEFAULT) size.x = wHint;
    if (hHint != SWT.DEFAULT) size.y = hHint;

    return size;
  }
示例#4
0
  /** Compute the minimum size. */
  private Point getTotalSize(Image image, String text) {
    Point size = new Point(0, 0);

    if (image != null) {
      Rectangle r = image.getBounds();
      size.x += r.width;
      size.y += r.height;
    }

    GC gc = new GC(this);
    if (text != null && text.length() > 0) {
      Point e = gc.textExtent(text, DRAW_FLAGS);
      size.x += e.x;
      size.y = Math.max(size.y, e.y);
      if (image != null) size.x += GAP;
    } else {
      size.y = Math.max(size.y, gc.getFontMetrics().getHeight());
    }
    gc.dispose();

    return size;
  }
 private void updatePoint(MouseEvent e) {
   p.x = e.x;
   p.y = e.y;
 }