Mercurial > projects > dwt-linux
annotate dwt/layout/RowData.d @ 259:c0d810de7093
Update SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Sun, 29 Jun 2008 14:33:38 +0200 |
parents | 380bad9f6852 |
children |
rev | line source |
---|---|
72 | 1 /******************************************************************************* |
259 | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
51 | 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 | |
72 | 10 * Port to the D programming language: |
11 * Frank Benoit <benoit@tionex.de> | |
51 | 12 *******************************************************************************/ |
13 module dwt.layout.RowData; | |
14 | |
71 | 15 import dwt.DWT; |
51 | 16 import dwt.graphics.Point; |
17 import dwt.widgets.Control; | |
18 | |
19 import tango.util.Convert; | |
238 | 20 import dwt.dwthelper.utils; |
51 | 21 |
22 /** | |
23 * Each control controlled by a <code>RowLayout</code> can have its initial | |
24 * width and height specified by setting a <code>RowData</code> object | |
25 * into the control. | |
26 * <p> | |
27 * The following code uses a <code>RowData</code> object to change the initial | |
28 * size of a <code>Button</code> in a <code>Shell</code>: | |
29 * <pre> | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
30 * Display display = new Display(); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
31 * Shell shell = new Shell(display); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
32 * shell.setLayout(new RowLayout()); |
71 | 33 * Button button1 = new Button(shell, DWT.PUSH); |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
34 * button1.setText("Button 1"); |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
35 * button1.setLayoutData(new RowData(50, 40)); |
51 | 36 * </pre> |
37 * </p> | |
38 * | |
39 * @see RowLayout | |
259 | 40 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> |
51 | 41 */ |
42 public final class RowData { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
43 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
44 * width specifies the desired width in pixels. This value |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
45 * is the wHint passed into Control.computeSize(int, int, bool) |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
46 * to determine the preferred size of the control. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
47 * |
71 | 48 * The default value is DWT.DEFAULT. |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
49 * |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
50 * @see dwt.widgets.Control#computeSize(int, int, bool) |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
51 */ |
71 | 52 public int width = DWT.DEFAULT; |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
53 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
54 * height specifies the preferred height in pixels. This value |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
55 * is the hHint passed into Control.computeSize(int, int, bool) |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
56 * to determine the preferred size of the control. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
57 * |
71 | 58 * The default value is DWT.DEFAULT. |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
59 * |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
60 * @see dwt.widgets.Control#computeSize(int, int, bool) |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
61 */ |
71 | 62 public int height = DWT.DEFAULT; |
51 | 63 |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
64 /** |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
65 * exclude informs the layout to ignore this control when sizing |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
66 * and positioning controls. If this value is <code>true</code>, |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
67 * the size and position of the control will not be managed by the |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
68 * layout. If this value is <code>false</code>, the size and |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
69 * position of the control will be computed and assigned. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
70 * |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
71 * The default value is <code>false</code>. |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
72 * |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
73 * @since 3.1 |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
74 */ |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
75 public bool exclude = false; |
51 | 76 |
77 /** | |
78 * Constructs a new instance of RowData using | |
79 * default values. | |
80 */ | |
81 public this () { | |
82 } | |
83 | |
84 /** | |
85 * Constructs a new instance of RowData according to the parameters. | |
71 | 86 * A value of DWT.DEFAULT indicates that no minimum width or |
51 | 87 * no minimum height is specified. |
88 * | |
89 * @param width a minimum width for the control | |
90 * @param height a minimum height for the control | |
91 */ | |
92 public this (int width, int height) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
93 this.width = width; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
94 this.height = height; |
51 | 95 } |
96 | |
97 /** | |
98 * Constructs a new instance of RowData according to the parameter. | |
71 | 99 * A value of DWT.DEFAULT indicates that no minimum width or |
51 | 100 * no minimum height is specified. |
101 * | |
102 * @param point a point whose x coordinate specifies a minimum width for the control | |
103 * and y coordinate specifies a minimum height for the control | |
104 */ | |
105 public this (Point point) { | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
106 this (point.x, point.y); |
51 | 107 } |
108 | |
238 | 109 String getName () { |
110 String string = this.classinfo.name; | |
111 int index = string.lastIndexOf('.'); | |
112 if (index is -1 ) return string; | |
51 | 113 return string[ index + 1 .. string.length ]; |
114 } | |
115 | |
116 /** | |
117 * Returns a string containing a concise, human-readable | |
118 * description of the receiver. | |
119 * | |
120 * @return a string representation of the RowData object | |
121 */ | |
238 | 122 override public String toString () { |
123 String string = getName ()~" {"; | |
124 if (width !is DWT.DEFAULT) string ~= "width="~to!(String)(width)~" "; | |
125 if (height !is DWT.DEFAULT) string ~= "height="~to!(String)(height)~" "; | |
126 if (exclude) string ~= "exclude="~to!(String)(exclude)~" "; | |
127 string = string.trim(); | |
59
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
128 string ~= "}"; |
8cec8f536af3
All D sources complete gvim retab (4 spaces), bug with Composite moveAbove/moveBelow fixed.
Frank Benoit <benoit@tionex.de>
parents:
51
diff
changeset
|
129 return string; |
51 | 130 } |
131 } |