Mercurial > projects > dwt-win
annotate dwt/layout/RowData.d @ 212:ab60f3309436
reverted the char[] to String and use the an alias.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 05 May 2008 00:12:38 +0200 |
parents | 9a64a7781bab |
children | fd9c62a2998e |
rev | line source |
---|---|
0 | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2006 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.layout.RowData; | |
14 | |
15 import dwt.DWT; | |
16 import dwt.graphics.Point; | |
17 import dwt.widgets.Control; | |
18 | |
19 import tango.util.Convert; | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
20 import dwt.dwthelper.utils; |
0 | 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> | |
30 * Display display = new Display(); | |
31 * Shell shell = new Shell(display); | |
32 * shell.setLayout(new RowLayout()); | |
33 * Button button1 = new Button(shell, DWT.PUSH); | |
34 * button1.setText("Button 1"); | |
35 * button1.setLayoutData(new RowData(50, 40)); | |
36 * </pre> | |
37 * </p> | |
38 * | |
39 * @see RowLayout | |
40 */ | |
41 public final class RowData { | |
42 /** | |
43 * width specifies the desired width in pixels. This value | |
44 * is the wHint passed into Control.computeSize(int, int, bool) | |
45 * to determine the preferred size of the control. | |
46 * | |
47 * The default value is DWT.DEFAULT. | |
48 * | |
49 * @see dwt.widgets.Control#computeSize(int, int, bool) | |
50 */ | |
51 public int width = DWT.DEFAULT; | |
52 /** | |
53 * height specifies the preferred height in pixels. This value | |
54 * is the hHint passed into Control.computeSize(int, int, bool) | |
55 * to determine the preferred size of the control. | |
56 * | |
57 * The default value is DWT.DEFAULT. | |
58 * | |
59 * @see dwt.widgets.Control#computeSize(int, int, bool) | |
60 */ | |
61 public int height = DWT.DEFAULT; | |
62 | |
63 /** | |
64 * exclude informs the layout to ignore this control when sizing | |
65 * and positioning controls. If this value is <code>true</code>, | |
66 * the size and position of the control will not be managed by the | |
67 * layout. If this value is <code>false</code>, the size and | |
68 * position of the control will be computed and assigned. | |
69 * | |
70 * The default value is <code>false</code>. | |
71 * | |
72 * @since 3.1 | |
73 */ | |
74 public bool exclude = false; | |
75 | |
76 /** | |
77 * Constructs a new instance of RowData using | |
78 * default values. | |
79 */ | |
80 public this () { | |
81 } | |
82 | |
83 /** | |
84 * Constructs a new instance of RowData according to the parameters. | |
85 * A value of DWT.DEFAULT indicates that no minimum width or | |
86 * no minimum height is specified. | |
87 * | |
88 * @param width a minimum width for the control | |
89 * @param height a minimum height for the control | |
90 */ | |
91 public this (int width, int height) { | |
92 this.width = width; | |
93 this.height = height; | |
94 } | |
95 | |
96 /** | |
97 * Constructs a new instance of RowData according to the parameter. | |
98 * A value of DWT.DEFAULT indicates that no minimum width or | |
99 * no minimum height is specified. | |
100 * | |
101 * @param point a point whose x coordinate specifies a minimum width for the control | |
102 * and y coordinate specifies a minimum height for the control | |
103 */ | |
104 public this (Point point) { | |
105 this (point.x, point.y); | |
106 } | |
107 | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
108 String getName () { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
109 String string = this.classinfo.name; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
110 int index = string.lastIndexOf('.'); |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
111 if (index is -1 ) return string; |
0 | 112 return string[ index + 1 .. string.length ]; |
113 } | |
114 | |
115 /** | |
116 * Returns a string containing a concise, human-readable | |
117 * description of the receiver. | |
118 * | |
119 * @return a string representation of the RowData object | |
120 */ | |
212
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
121 override public String toString () { |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
122 String string = getName ()~" {"; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
123 if (width !is DWT.DEFAULT) string ~= "width="~to!(String)(width)~" "; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
124 if (height !is DWT.DEFAULT) string ~= "height="~to!(String)(height)~" "; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
125 if (exclude) string ~= "exclude="~to!(String)(exclude)~" "; |
ab60f3309436
reverted the char[] to String and use the an alias.
Frank Benoit <benoit@tionex.de>
parents:
48
diff
changeset
|
126 string = string.trim(); |
0 | 127 string ~= "}"; |
128 return string; | |
129 } | |
130 } |