1 11 package org.eclipse.jdt.internal.junit.ui; 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 24 public class TabFolderLayout extends Layout { 25 26 protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { 27 if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) 28 return new Point(wHint, hHint); 29 30 Control [] children = composite.getChildren (); 31 int count = children.length; 32 int maxWidth = 0, maxHeight = 0; 33 for (int i=0; i<count; i++) { 34 Control child = children [i]; 35 Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache); 36 maxWidth = Math.max (maxWidth, pt.x); 37 maxHeight = Math.max (maxHeight, pt.y); 38 } 39 if (wHint != SWT.DEFAULT) 40 maxWidth= wHint; 41 if (hHint != SWT.DEFAULT) 42 maxHeight= hHint; 43 44 return new Point(maxWidth, maxHeight); 45 46 } 47 48 protected void layout (Composite composite, boolean flushCache) { 49 Rectangle rect = composite.getClientArea(); 50 51 Control[] children = composite.getChildren(); 52 for (int i = 0; i < children.length; i++) { 53 children[i].setBounds(rect); 54 } 55 } 56 } 57 | Popular Tags |