1 11 12 package org.eclipse.ui.internal.editors.text; 13 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.graphics.Point; 16 import org.eclipse.swt.graphics.Rectangle; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Layout; 20 21 27 class TabFolderLayout extends Layout { 28 29 32 protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) { 33 if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT) 34 return new Point(wHint, hHint); 35 36 Control [] children = composite.getChildren (); 37 int count = children.length; 38 int maxWidth = 0, maxHeight = 0; 39 for (int i=0; i<count; i++) { 40 Control child = children [i]; 41 Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache); 42 maxWidth = Math.max (maxWidth, pt.x); 43 maxHeight = Math.max (maxHeight, pt.y); 44 } 45 46 if (wHint != SWT.DEFAULT) 47 maxWidth= wHint; 48 if (hHint != SWT.DEFAULT) 49 maxHeight= hHint; 50 51 return new Point(maxWidth, maxHeight); 52 53 } 54 55 58 protected void layout (Composite composite, boolean flushCache) { 59 Rectangle rect= composite.getClientArea(); 60 61 Control[] children = composite.getChildren(); 62 for (int i = 0; i < children.length; i++) { 63 children[i].setBounds(rect); 64 } 65 } 66 } 67 | Popular Tags |