comparison org.eclipse.swt.win32.win32.x86/src/org/eclipse/swt/custom/CLayoutData.d @ 0:6dd524f61e62

add dwt win and basic java stuff
author Frank Benoit <benoit@tionex.de>
date Mon, 02 Mar 2009 14:44:16 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:6dd524f61e62
1 /*******************************************************************************
2 * Copyright (c) 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module org.eclipse.swt.custom.CLayoutData;
14
15
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.graphics.Point;
18 import org.eclipse.swt.widgets.Control;
19
20 class CLayoutData {
21
22 int defaultWidth = -1, defaultHeight = -1;
23 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
24
25 Point computeSize (Control control, int wHint, int hHint, bool flushCache_) {
26 if (flushCache_) flushCache();
27 if (wHint is SWT.DEFAULT && hHint is SWT.DEFAULT) {
28 if (defaultWidth is -1 || defaultHeight is -1) {
29 Point size = control.computeSize (wHint, hHint, flushCache_);
30 defaultWidth = size.x;
31 defaultHeight = size.y;
32 }
33 return new Point(defaultWidth, defaultHeight);
34 }
35 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) {
36 Point size = control.computeSize (wHint, hHint, flushCache_);
37 currentWhint = wHint;
38 currentHhint = hHint;
39 currentWidth = size.x;
40 currentHeight = size.y;
41 }
42 return new Point(currentWidth, currentHeight);
43 }
44 void flushCache () {
45 defaultWidth = defaultHeight = -1;
46 currentWidth = currentHeight = -1;
47 }
48 }