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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
1 /*******************************************************************************
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
2 * Copyright (c) 2000, 2006 IBM Corporation and others.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
3 * All rights reserved. This program and the accompanying materials
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
4 * are made available under the terms of the Eclipse Public License v1.0
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
5 * which accompanies this distribution, and is available at
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
6 * http://www.eclipse.org/legal/epl-v10.html
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
7 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
8 * Contributors:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
9 * IBM Corporation - initial API and implementation
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
10 * Port to the D programming language:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
11 * Frank Benoit <benoit@tionex.de>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
12 *******************************************************************************/
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
13 module dwt.layout.RowData;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
14
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
15 import dwt.DWT;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
16 import dwt.graphics.Point;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
17 import dwt.widgets.Control;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
18
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
21
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
22 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
23 * Each control controlled by a <code>RowLayout</code> can have its initial
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
24 * width and height specified by setting a <code>RowData</code> object
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
25 * into the control.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
26 * <p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
27 * The following code uses a <code>RowData</code> object to change the initial
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
28 * size of a <code>Button</code> in a <code>Shell</code>:
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
29 * <pre>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
30 * Display display = new Display();
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
31 * Shell shell = new Shell(display);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
32 * shell.setLayout(new RowLayout());
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
33 * Button button1 = new Button(shell, DWT.PUSH);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
34 * button1.setText("Button 1");
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
35 * button1.setLayoutData(new RowData(50, 40));
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
36 * </pre>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
37 * </p>
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
38 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
39 * @see RowLayout
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
40 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
41 public final class RowData {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
42 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
43 * width specifies the desired width in pixels. This value
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
44 * is the wHint passed into Control.computeSize(int, int, bool)
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
45 * to determine the preferred size of the control.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
46 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
47 * The default value is DWT.DEFAULT.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
48 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
49 * @see dwt.widgets.Control#computeSize(int, int, bool)
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
50 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
51 public int width = DWT.DEFAULT;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
52 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
53 * height specifies the preferred height in pixels. This value
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
54 * is the hHint passed into Control.computeSize(int, int, bool)
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
55 * to determine the preferred size of the control.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
56 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
57 * The default value is DWT.DEFAULT.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
58 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
59 * @see dwt.widgets.Control#computeSize(int, int, bool)
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
60 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
61 public int height = DWT.DEFAULT;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
62
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
63 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
64 * exclude informs the layout to ignore this control when sizing
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
65 * and positioning controls. If this value is <code>true</code>,
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
66 * the size and position of the control will not be managed by the
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
67 * layout. If this value is <code>false</code>, the size and
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
68 * position of the control will be computed and assigned.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
69 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
70 * The default value is <code>false</code>.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
71 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
72 * @since 3.1
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
73 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
74 public bool exclude = false;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
75
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
76 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
77 * Constructs a new instance of RowData using
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
78 * default values.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
79 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
80 public this () {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
81 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
82
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
83 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
84 * Constructs a new instance of RowData according to the parameters.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
85 * A value of DWT.DEFAULT indicates that no minimum width or
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
86 * no minimum height is specified.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
87 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
88 * @param width a minimum width for the control
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
89 * @param height a minimum height for the control
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
90 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
91 public this (int width, int height) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
92 this.width = width;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
93 this.height = height;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
94 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
95
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
96 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
97 * Constructs a new instance of RowData according to the parameter.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
98 * A value of DWT.DEFAULT indicates that no minimum width or
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
99 * no minimum height is specified.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
100 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
101 * @param point a point whose x coordinate specifies a minimum width for the control
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
102 * and y coordinate specifies a minimum height for the control
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
103 */
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
104 public this (Point point) {
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
105 this (point.x, point.y);
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
106 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
112 return string[ index + 1 .. string.length ];
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
113 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
114
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
115 /**
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
116 * Returns a string containing a concise, human-readable
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
117 * description of the receiver.
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
118 *
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
119 * @return a string representation of the RowData object
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
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
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
127 string ~= "}";
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
128 return string;
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
129 }
5406a8f6526d Add initial files
John Reimer <terminal.node@gmail.com
parents:
diff changeset
130 }