Ejemplo n.º 1
0
 @Override
 protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
   Dimension d = getLayoutData().getSize();
   Insets insets = container.getInsets();
   d = new Dimension(d.width + insets.getWidth(), d.height + insets.getHeight());
   return d.union(getBorderPreferredSize(container));
 }
 @Override
 public Dimension getPreferredSize(int wHint, int hHint) {
   Dimension prefSize = super.getPreferredSize(wHint, hHint);
   int bodyHeight = getParent().getBounds().height - 10;
   Dimension defaultSize = new Dimension(SWT.DEFAULT, bodyHeight);
   prefSize.union(defaultSize);
   return prefSize;
 }
  protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {
    Dimension extent = null;

    for (Iterator i = container.getChildren().iterator(); i.hasNext(); ) {
      IFigure child = (IFigure) i.next();

      Dimension childSize = null;
      if (!(child instanceof FreeformFigure)) {
        childSize = child.getPreferredSize();
      }
      if (null != childSize) {
        if (null == extent) {
          extent = childSize.getCopy();
        } else {
          extent.width += childSize.width + getMinorSpacing();
          extent.height = Math.max(extent.height, childSize.height);
        }
      }
    }

    if (null != extent) {
      extent.union(container.getMinimumSize());
    } else {
      extent = container.getMinimumSize();
    }

    Insets insets = container.getInsets();
    if (null == extent) {
      extent = new Dimension(insets.getWidth(), insets.getHeight());
    } else {
      // compartment.translateToParent(extent);
      extent.expand(insets.getWidth(), insets.getHeight());
    }

    return extent;
  }