1 11 package org.eclipse.swt.custom; 12 13 import org.eclipse.swt.*; 14 import org.eclipse.swt.graphics.*; 15 import org.eclipse.swt.widgets.*; 16 17 class CLayoutData { 18 19 int defaultWidth = -1, defaultHeight = -1; 20 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; 21 22 Point computeSize (Control control, int wHint, int hHint, boolean flushCache) { 23 if (flushCache) flushCache(); 24 if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) { 25 if (defaultWidth == -1 || defaultHeight == -1) { 26 Point size = control.computeSize (wHint, hHint, flushCache); 27 defaultWidth = size.x; 28 defaultHeight = size.y; 29 } 30 return new Point(defaultWidth, defaultHeight); 31 } 32 if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) { 33 Point size = control.computeSize (wHint, hHint, flushCache); 34 currentWhint = wHint; 35 currentHhint = hHint; 36 currentWidth = size.x; 37 currentHeight = size.y; 38 } 39 return new Point(currentWidth, currentHeight); 40 } 41 void flushCache () { 42 defaultWidth = defaultHeight = -1; 43 currentWidth = currentHeight = -1; 44 } 45 } 46 | Popular Tags |