Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / util / TabFolderLayout.java
1 /*
2  * (c) Copyright IBM Corp. 2000, 2001.
3  * All Rights Reserved
4  */
5 package net.sourceforge.phpdt.internal.ui.util;
6
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;
13
14 public class TabFolderLayout extends Layout {
15
16         protected Point computeSize(Composite composite, int wHint, int hHint,
17                         boolean flushCache) {
18                 if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
19                         return new Point(wHint, hHint);
20
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);
29                 }
30
31                 if (wHint != SWT.DEFAULT)
32                         maxWidth = wHint;
33                 if (hHint != SWT.DEFAULT)
34                         maxHeight = hHint;
35
36                 return new Point(maxWidth, maxHeight);
37
38         }
39
40         protected void layout(Composite composite, boolean flushCache) {
41                 Rectangle rect = composite.getClientArea();
42
43                 Control[] children = composite.getChildren();
44                 for (int i = 0; i < children.length; i++) {
45                         children[i].setBounds(rect);
46                 }
47         }
48 }