01: /*******************************************************************************
02: * Copyright (c) 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.preferences;
11:
12: import org.eclipse.swt.SWT;
13: import org.eclipse.swt.graphics.Point;
14: import org.eclipse.swt.graphics.Rectangle;
15: import org.eclipse.swt.widgets.Composite;
16: import org.eclipse.swt.widgets.Control;
17: import org.eclipse.swt.widgets.Layout;
18:
19: public class TabFolderLayout extends Layout {
20:
21: protected Point computeSize(Composite composite, int wHint,
22: int hHint, boolean flushCache) {
23: if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
24: return new Point(wHint, hHint);
25:
26: Control[] children = composite.getChildren();
27: int count = children.length;
28: int maxWidth = 0, maxHeight = 0;
29: for (int i = 0; i < count; i++) {
30: Control child = children[i];
31: Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT,
32: flushCache);
33: maxWidth = Math.max(maxWidth, pt.x);
34: maxHeight = Math.max(maxHeight, pt.y);
35: }
36:
37: if (wHint != SWT.DEFAULT)
38: maxWidth = wHint;
39: if (hHint != SWT.DEFAULT)
40: maxHeight = hHint;
41:
42: return new Point(maxWidth, maxHeight);
43:
44: }
45:
46: protected void layout(Composite composite, boolean flushCache) {
47: Rectangle rect = composite.getClientArea();
48:
49: Control[] children = composite.getChildren();
50: for (int i = 0; i < children.length; i++) {
51: children[i].setBounds(rect);
52: }
53: }
54:
55: }
|