1 11 package org.eclipse.ui.internal.presentations.util; 12 13 import org.eclipse.jface.util.Geometry; 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 23 public class EnhancedFillLayout extends Layout { 24 25 public int xmargin = 0; 26 public int ymargin = 0; 27 28 protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) { 29 int resultX = 1; 30 int resultY = 1; 31 32 Control[] children = composite.getChildren(); 33 34 for (int i = 0; i < children.length; i++) { 35 Control control = children[i]; 36 37 Point sz = control.computeSize(wHint, hHint, flushCache); 38 39 resultX = Math.max(resultX, sz.x + 2 * xmargin); 40 resultY = Math.max(resultY, sz.y + 2 * ymargin); 41 } 42 43 return new Point(resultX, resultY); 44 } 45 46 protected void layout(Composite composite, boolean flushCache) { 47 Control[] children = composite.getChildren(); 48 49 for (int i = 0; i < children.length; i++) { 50 Control control = children[i]; 51 Rectangle area = composite.getClientArea(); 52 Geometry.expand(area, -xmargin, -xmargin, -ymargin, -ymargin ); 53 control.setBounds(area); 54 } 55 } 56 } 57 | Popular Tags |