Mercurial > projects > dwt-mac
comparison dwt/custom/CLayoutData.d @ 0:380af2bdd8e5
Upload of whole dwt tree
author | Jacob Carlborg <doob@me.com> <jacob.carlborg@gmail.com> |
---|---|
date | Sat, 09 Aug 2008 17:00:02 +0200 |
parents | |
children | f565d3a95c0a |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:380af2bdd8e5 |
---|---|
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 * | |
11 * Port to the D Programming language: | |
12 * Jacob Carlborg <jacob.carlborg@gmail.com> | |
13 *******************************************************************************/ | |
14 module dwt.custom.CLayoutData; | |
15 | |
16 import dwt.DWT; | |
17 import dwt.graphics.Point; | |
18 import dwt.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) | |
27 flushCache(); | |
28 if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) { | |
29 if (defaultWidth is -1 || defaultHeight is -1) { | |
30 Point size = control.computeSize(wHint, hHint, flushCache); | |
31 defaultWidth = size.x; | |
32 defaultHeight = size.y; | |
33 } | |
34 return new Point(defaultWidth, defaultHeight); | |
35 } | |
36 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is 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 } |