root/dwt/layout/RowData.d

Revision 246:fd9c62a2998e, 4.2 kB (checked in by Frank Benoit <benoit@tionex.de>, 6 months ago)

Updater SWT 3.4M7 to 3.4

Line 
1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 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;
20 import dwt.dwthelper.utils;
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  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
41  */
42 public final class RowData {
43     /**
44      * width specifies the desired width in pixels. This value
45      * is the wHint passed into Control.computeSize(int, int, bool)
46      * to determine the preferred size of the control.
47      *
48      * The default value is DWT.DEFAULT.
49      *
50      * @see dwt.widgets.Control#computeSize(int, int, bool)
51      */
52     public int width = DWT.DEFAULT;
53     /**
54      * height specifies the preferred height in pixels. This value
55      * is the hHint passed into Control.computeSize(int, int, bool)
56      * to determine the preferred size of the control.
57      *
58      * The default value is DWT.DEFAULT.
59      *
60      * @see dwt.widgets.Control#computeSize(int, int, bool)
61      */
62     public int height = DWT.DEFAULT;
63
64     /**
65      * exclude informs the layout to ignore this control when sizing
66      * and positioning controls.  If this value is <code>true</code>,
67      * the size and position of the control will not be managed by the
68      * layout.  If this value is <code>false</code>, the size and
69      * position of the control will be computed and assigned.
70      *
71      * The default value is <code>false</code>.
72      *
73      * @since 3.1
74      */
75     public bool exclude = false;
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.
86  * A value of DWT.DEFAULT indicates that no minimum width or
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) {
93     this.width = width;
94     this.height = height;
95 }
96
97 /**
98  * Constructs a new instance of RowData according to the parameter.
99  * A value of DWT.DEFAULT indicates that no minimum width or
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) {
106     this (point.x, point.y);
107 }
108
109 String getName () {
110     String string = this.classinfo.name;
111     int index = string.lastIndexOf('.');
112     if (index is -1 ) return string;
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  */
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();
128     string ~= "}";
129     return string;
130 }
131 }
Note: See TracBrowser for help on using the browser.