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, boolean flushCache) {
17 if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
18 return new Point(wHint, hHint);
20 Control [] children = composite.getChildren ();
21 int count = children.length;
22 int maxWidth = 0, maxHeight = 0;
23 for (int i=0; i<count; i++) {
24 Control child = children [i];
25 Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
26 maxWidth = Math.max (maxWidth, pt.x);
27 maxHeight = Math.max (maxHeight, pt.y);
30 if (wHint != SWT.DEFAULT)
32 if (hHint != SWT.DEFAULT)
35 return new Point(maxWidth, maxHeight);
39 protected void layout (Composite composite, boolean flushCache) {
40 Rectangle rect= composite.getClientArea();
42 Control[] children = composite.getChildren();
43 for (int i = 0; i < children.length; i++) {
44 children[i].setBounds(rect);