Ejemplo n.º 1
0
  @Override
  public Point computeSizeHint() {
    updateInput();
    final Point sizeConstraints = getSizeConstraints();
    final Rectangle trim = computeTrim();

    //		int charWidth= 20;
    //		if (fInput.detailInfo != null) {
    //			final int count= Math.min(6, fInfoText.getLineCount());
    //			for (int i= 0; i < count; i++) {
    //				charWidth= Math.max(charWidth, fInfoText.getLine(i).length());
    //			}
    //		}
    int widthHint =
        this.infoText.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x + LayoutUtil.defaultHSpacing();
    final int widthMax2 = LayoutUtil.hintWidth(this.infoText, PREF_DETAIL_PANE_FONT, 80);
    final int widthMax =
        ((sizeConstraints != null && sizeConstraints.x != SWT.DEFAULT)
                ? sizeConstraints.x
                : widthMax2)
            - trim.width;
    this.layoutHint = true;
    final int titleHint =
        LayoutUtil.defaultHMargin()
            + this.titleImage.getSize().x
            + LayoutUtil.defaultHSpacing()
            + this.titleText.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
    this.layoutHint = false;
    if (titleHint > widthHint && widthMax2 > widthHint) {
      widthHint = Math.min(widthMax2, titleHint);
    }
    if (widthMax < widthHint) {
      widthHint = widthMax;
    }
    // avoid change of wrapping caused by scrollbar
    if (widthHint < titleHint
        && widthHint + this.infoText.computeTrim(0, 0, 0, 0).width >= titleHint) {
      widthHint = titleHint;
    }

    final int heightMax =
        ((sizeConstraints != null && sizeConstraints.y != SWT.DEFAULT)
                ? sizeConstraints.y
                : this.infoText.getLineHeight() * 12)
            - trim.height;

    final Point size = this.contentComposite.computeSize(widthHint, SWT.DEFAULT, true);
    size.y += LayoutUtil.defaultVSpacing();
    size.x = Math.max(Math.min(size.x, widthMax), 200) + trim.width;
    size.y = Math.max(Math.min(size.y, heightMax), 100) + trim.height;
    return size;
  }