2 * (c) Copyright IBM Corp. 2000, 2001.
5 package net.sourceforge.phpdt.internal.ui.util;
7 import org.eclipse.swt.SWT;
8 import org.eclipse.swt.graphics.Point;
9 import org.eclipse.swt.graphics.Rectangle;
10 import org.eclipse.swt.widgets.Composite;
11 import org.eclipse.swt.widgets.Control;
12 import org.eclipse.swt.widgets.Layout;
14 public class TabFolderLayout extends Layout {
16 protected Point computeSize(Composite composite, int wHint, int hHint,
18 if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
19 return new Point(wHint, hHint);
21 Control[] children = composite.getChildren();
22 int count = children.length;
23 int maxWidth = 0, maxHeight = 0;
24 for (int i = 0; i < count; i++) {
25 Control child = children[i];
26 Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
27 maxWidth = Math.max(maxWidth, pt.x);
28 maxHeight = Math.max(maxHeight, pt.y);
31 if (wHint != SWT.DEFAULT)
33 if (hHint != SWT.DEFAULT)
36 return new Point(maxWidth, maxHeight);
40 protected void layout(Composite composite, boolean flushCache) {
41 Rectangle rect = composite.getClientArea();
43 Control[] children = composite.getChildren();
44 for (int i = 0; i < children.length; i++) {
45 children[i].setBounds(rect);