comparison dwt/custom/CLayoutData.d @ 41:6337764516f1

Sync dwt/custom with dwt-linux (took copy of complete folder)
author Frank Benoit <benoit@tionex.de>
date Tue, 07 Oct 2008 16:29:55 +0200
parents f565d3a95c0a
children
comparison
equal deleted inserted replaced
40:fbe68c33eeee 41:6337764516f1
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2005 IBM Corporation and others. 2 * Copyright (c) 2005 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
8 * Contributors: 8 * Contributors:
9 * IBM Corporation - initial API and implementation 9 * IBM Corporation - initial API and implementation
10 *
11 * Port to the D programming language: 10 * Port to the D programming language:
12 * Jacob Carlborg <jacob.carlborg@gmail.com> 11 * Frank Benoit <benoit@tionex.de>
13 *******************************************************************************/ 12 *******************************************************************************/
14 module dwt.custom.CLayoutData; 13 module dwt.custom.CLayoutData;
14
15 15
16 import dwt.DWT; 16 import dwt.DWT;
17 import dwt.graphics.Point; 17 import dwt.graphics.Point;
18 import dwt.widgets.Control; 18 import dwt.widgets.Control;
19 19
20 class CLayoutData { 20 class CLayoutData {
21 21
22 int defaultWidth = -1, defaultHeight = -1; 22 int defaultWidth = -1, defaultHeight = -1;
23 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; 23 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
24 24
25 Point computeSize (Control control, int wHint, int hHint, bool flushCache) { 25 Point computeSize (Control control, int wHint, int hHint, bool flushCache_) {
26 if (flushCache) 26 if (flushCache_) flushCache();
27 flushCache(); 27 if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) {
28 if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) { 28 if (defaultWidth is -1 || defaultHeight is -1) {
29 if (defaultWidth is -1 || defaultHeight is -1) { 29 Point size = control.computeSize (wHint, hHint, flushCache_);
30 Point size = control.computeSize(wHint, hHint, flushCache); 30 defaultWidth = size.x;
31 defaultWidth = size.x; 31 defaultHeight = size.y;
32 defaultHeight = size.y;
33 }
34 return new Point(defaultWidth, defaultHeight);
35 } 32 }
36 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) { 33 return new Point(defaultWidth, defaultHeight);
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 } 34 }
45 35 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) {
46 void flushCache () { 36 Point size = control.computeSize (wHint, hHint, flushCache_);
47 defaultWidth = defaultHeight = -1; 37 currentWhint = wHint;
48 currentWidth = currentHeight = -1; 38 currentHhint = hHint;
39 currentWidth = size.x;
40 currentHeight = size.y;
49 } 41 }
42 return new Point(currentWidth, currentHeight);
50 } 43 }
44 void flushCache () {
45 defaultWidth = defaultHeight = -1;
46 currentWidth = currentHeight = -1;
47 }
48 }