Mercurial > projects > dwt2
comparison org.eclipse.swt.gtk.linux.x86/src/org/eclipse/swt/custom/CLayoutData.d @ 25:f713da8bc051
Added SWT Linux GTK
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 20 Mar 2009 23:03:58 +0100 |
parents | |
children | 536e43f63c81 |
comparison
equal
deleted
inserted
replaced
24:b7a1d02a0e1f | 25:f713da8bc051 |
---|---|
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 import java.lang.all; | |
16 | |
17 | |
18 import org.eclipse.swt.SWT; | |
19 import org.eclipse.swt.graphics.Point; | |
20 import org.eclipse.swt.widgets.Control; | |
21 | |
22 class CLayoutData { | |
23 | |
24 int defaultWidth = -1, defaultHeight = -1; | |
25 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1; | |
26 | |
27 Point computeSize (Control control, int wHint, int hHint, bool flushCache_) { | |
28 if (flushCache_) flushCache(); | |
29 if (wHint is SWT.DEFAULT && hHint is SWT.DEFAULT) { | |
30 if (defaultWidth is -1 || defaultHeight is -1) { | |
31 Point size = control.computeSize (wHint, hHint, flushCache_); | |
32 defaultWidth = size.x; | |
33 defaultHeight = size.y; | |
34 } | |
35 return new Point(defaultWidth, defaultHeight); | |
36 } | |
37 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) { | |
38 Point size = control.computeSize (wHint, hHint, flushCache_); | |
39 currentWhint = wHint; | |
40 currentHhint = hHint; | |
41 currentWidth = size.x; | |
42 currentHeight = size.y; | |
43 } | |
44 return new Point(currentWidth, currentHeight); | |
45 } | |
46 void flushCache () { | |
47 defaultWidth = defaultHeight = -1; | |
48 currentWidth = currentHeight = -1; | |
49 } | |
50 } |