1 11 package org.eclipse.jdt.internal.ui.util; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.graphics.Point; 15 import org.eclipse.swt.graphics.Rectangle; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Control; 18 import org.eclipse.swt.widgets.Layout; 19 20 public class TabFolderLayout extends Layout { 21 22 protected Point computeSize (Composite composite, int wHint, 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, flushCache); 32 maxWidth = Math.max (maxWidth, pt.x); 33 maxHeight = Math.max (maxHeight, pt.y); 34 } 35 36 if (wHint != SWT.DEFAULT) 37 maxWidth= wHint; 38 if (hHint != SWT.DEFAULT) 39 maxHeight= hHint; 40 41 return new Point(maxWidth, maxHeight); 42 43 } 44 45 protected void layout (Composite composite, boolean flushCache) { 46 Rectangle rect= composite.getClientArea(); 47 48 Control[] children = composite.getChildren(); 49 for (int i = 0; i < children.length; i++) { 50 children[i].setBounds(rect); 51 } 52 } 53 } 54 | Popular Tags |