1 /*******************************************************************************
2 * Copyright (c) 2005 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.layout;
16 import org.eclipse.swt.*;
17 import org.eclipse.swt.graphics.*;
18 import org.eclipse.swt.widgets.*;
22 int defaultWidth = -1, defaultHeight = -1;
23 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
25 Point computeSize (Control control, int wHint, int hHint, boolean flushCache) {
26 if (flushCache) flushCache();
27 if (wHint == SWT.DEFAULT && hHint == SWT.DEFAULT) {
28 if (defaultWidth == -1 || defaultHeight == -1) {
29 Point size = control.computeSize (wHint, hHint, flushCache);
30 defaultWidth = size.x;
31 defaultHeight = size.y;
33 return new Point(defaultWidth, defaultHeight);
35 if (currentWidth == -1 || currentHeight == -1 || wHint != currentWhint || hHint != currentHhint) {
36 Point size = control.computeSize (wHint, hHint, flushCache);
39 currentWidth = size.x;
40 currentHeight = size.y;
42 return new Point(currentWidth, currentHeight);
45 defaultWidth = defaultHeight = -1;
46 currentWidth = currentHeight = -1;