01: /*******************************************************************************
02: * Copyright (c) 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.swt.layout;
11:
12: import org.eclipse.swt.*;
13: import org.eclipse.swt.graphics.*;
14: import org.eclipse.swt.widgets.*;
15:
16: class FillData {
17:
18: int defaultWidth = -1, defaultHeight = -1;
19: int currentWhint, currentHhint, currentWidth = -1,
20: currentHeight = -1;
21:
22: Point computeSize(Control control, int wHint, int hHint,
23: boolean flushCache) {
24: if (flushCache)
25: flushCache();
26: if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
27: if (defaultWidth == -1 || defaultHeight == -1) {
28: Point size = control.computeSize(wHint, hHint,
29: flushCache);
30: defaultWidth = size.x;
31: defaultHeight = size.y;
32: }
33: return new Point(defaultWidth, defaultHeight);
34: }
35: if (currentWidth == -1 || currentHeight == -1
36: || wHint != currentWhint || hHint != currentHhint) {
37: Point size = control.computeSize(wHint, hHint, flushCache);
38: currentWhint = wHint;
39: currentHhint = hHint;
40: currentWidth = size.x;
41: currentHeight = size.y;
42: }
43: return new Point(currentWidth, currentHeight);
44: }
45:
46: void flushCache() {
47: defaultWidth = defaultHeight = -1;
48: currentWidth = currentHeight = -1;
49: }
50: }
|