annotate dwt/custom/CLayoutData.d @ 316:7cffa1a2985c

Add 'all.d' for package import, dwt.all for everything, dwt.std for the most essential.
author Frank Benoit <benoit@tionex.de>
date Sat, 18 Oct 2008 22:15:57 +0200
parents a5afe31f5cdd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
316
7cffa1a2985c Add 'all.d' for package import, dwt.all for everything, dwt.std for the most essential.
Frank Benoit <benoit@tionex.de>
parents: 155
diff changeset
1 /*******************************************************************************
155
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
2 * Copyright (c) 2005 IBM Corporation and others.
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
5 * which accompanies this distribution, and is available at
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
7 *
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
8 * Contributors:
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
10 * Port to the D programming language:
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
12 *******************************************************************************/
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
13 module dwt.custom.CLayoutData;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
14
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
15
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
16 import dwt.DWT;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
17 import dwt.graphics.Point;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
18 import dwt.widgets.Control;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
19
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
20 class CLayoutData {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
21
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
22 int defaultWidth = -1, defaultHeight = -1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
23 int currentWhint, currentHhint, currentWidth = -1, currentHeight = -1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
24
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
25 Point computeSize (Control control, int wHint, int hHint, bool flushCache_) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
26 if (flushCache_) flushCache();
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
27 if (wHint is DWT.DEFAULT && hHint is DWT.DEFAULT) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
28 if (defaultWidth is -1 || defaultHeight is -1) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
29 Point size = control.computeSize (wHint, hHint, flushCache_);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
30 defaultWidth = size.x;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
31 defaultHeight = size.y;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
32 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
33 return new Point(defaultWidth, defaultHeight);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
34 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
35 if (currentWidth is -1 || currentHeight is -1 || wHint !is currentWhint || hHint !is currentHhint) {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
36 Point size = control.computeSize (wHint, hHint, flushCache_);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
37 currentWhint = wHint;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
38 currentHhint = hHint;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
39 currentWidth = size.x;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
40 currentHeight = size.y;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
41 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
42 return new Point(currentWidth, currentHeight);
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
43 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
44 void flushCache () {
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
45 defaultWidth = defaultHeight = -1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
46 currentWidth = currentHeight = -1;
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
47 }
a5afe31f5cdd Added custom controls
Frank Benoit <benoit@tionex.de>
parents:
diff changeset
48 }