1 11 12 package org.eclipse.ui.internal.layout; 13 14 import org.eclipse.swt.SWT; 15 import org.eclipse.swt.graphics.Point; 16 import org.eclipse.swt.layout.GridData; 17 import org.eclipse.swt.widgets.Composite; 18 import org.eclipse.swt.widgets.Control; 19 import org.eclipse.swt.widgets.Shell; 20 21 27 class CellLayoutUtil { 28 29 private static Point zero = new Point(0, 0); 30 31 private static Point minimumShellSize; 32 33 private static CellData defaultData = new CellData(); 34 35 66 static Point computeMinimumSize(Composite toCompute) { 67 if (toCompute instanceof Shell) { 68 if (minimumShellSize == null) { 69 Shell testShell = new Shell((Shell) toCompute, SWT.DIALOG_TRIM 70 | SWT.RESIZE); 71 testShell.setSize(0, 0); 72 minimumShellSize = testShell.getSize(); 73 testShell.dispose(); 74 } 75 76 return minimumShellSize; 77 } 78 79 82 84 return zero; 85 } 86 87 96 static CellData getData(Control control) { 97 Object layoutData = control.getLayoutData(); 98 CellData data = null; 99 100 if (layoutData instanceof CellData) { 101 data = (CellData) layoutData; 102 } else if (layoutData instanceof GridData) { 103 data = new CellData((GridData) layoutData); 104 } 105 106 if (data == null) { 107 data = defaultData; 108 } 109 110 return data; 111 } 112 } 113 | Popular Tags |