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.text.Util;
|
|
20 import tango.util.Convert;
|
|
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
|
|
108 char[] getName () {
|
|
109 char[] string = this.classinfo.name;
|
|
110 int index = locatePrior( string, '.');
|
|
111 if (index is string.length ) return string;
|
|
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 */
|
|
121 public char[] toString () {
|
|
122 char[] string = getName ()~" {";
|
|
123 if (width !is DWT.DEFAULT) string ~= "width="~to!(char[])(width)~" ";
|
|
124 if (height !is DWT.DEFAULT) string ~= "height="~to!(char[])(height)~" ";
|
|
125 if (exclude) string ~= "exclude="~to!(char[])(exclude)~" ";
|
|
126 string = trim( string );
|
|
127 string ~= "}";
|
|
128 return string;
|
|
129 }
|
|
130 }
|