root/dwt/custom/CLayoutData.d

Revision 108:0f12f6bb9739, 1.7 kB (checked in by Frank Benoit <benoit@tionex.de>, 10 months ago)

author notice

Line 
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 dwt.custom.CLayoutData;
14
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_) flushCache();
27     if (wHint is DWT.DEFAULT && hHint is DWT.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 }
Note: See TracBrowser for help on using the browser.