]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/layout/RowData.java
755917f16eb53fa21065463da4f6f3ea6549ba76
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / layout / RowData.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2018 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.layout;
15
16 import org.eclipse.swt.*;
17 import org.eclipse.swt.graphics.*;
18
19 /**
20  * Each control controlled by a <code>RowLayout</code> can have its initial
21  * width and height specified by setting a <code>RowData</code> object
22  * into the control.
23  * <p>
24  * The following code uses a <code>RowData</code> object to change the initial
25  * size of a <code>Button</code> in a <code>Shell</code>:
26  * </p>
27  * <pre>
28  *              Display display = new Display();
29  *              Shell shell = new Shell(display);
30  *              shell.setLayout(new RowLayout());
31  *              Button button1 = new Button(shell, SWT.PUSH);
32  *              button1.setText("Button 1");
33  *              button1.setLayoutData(new RowData(50, 40));
34  * </pre>
35  *
36  * @see RowLayout
37  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
38  */
39 public final class RowData {
40         /**
41          * width specifies the desired width in points. This value
42          * is the wHint passed into Control.computeSize(int, int, boolean)
43          * to determine the preferred size of the control.
44          *
45          * The default value is SWT.DEFAULT.
46          *
47          * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
48          */
49         public int width = SWT.DEFAULT;
50         /**
51          * height specifies the preferred height in points. This value
52          * is the hHint passed into Control.computeSize(int, int, boolean)
53          * to determine the preferred size of the control.
54          *
55          * The default value is SWT.DEFAULT.
56          *
57          * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
58          */
59         public int height = SWT.DEFAULT;
60
61         /**
62          * exclude informs the layout to ignore this control when sizing
63          * and positioning controls.  If this value is <code>true</code>,
64          * the size and position of the control will not be managed by the
65          * layout.  If this     value is <code>false</code>, the size and
66          * position of the control will be computed and assigned.
67          *
68          * The default value is <code>false</code>.
69          *
70          * @since 3.1
71          */
72         public boolean exclude = false;
73
74 /**
75  * Constructs a new instance of RowData using
76  * default values.
77  */
78 public RowData () {
79 }
80
81 /**
82  * Constructs a new instance of RowData according to the parameters.
83  * A value of SWT.DEFAULT indicates that no minimum width or
84  * no minimum height is specified.
85  *
86  * @param width a minimum width for the control
87  * @param height a minimum height for the control
88  */
89 public RowData (int width, int height) {
90         this.width = width;
91         this.height = height;
92 }
93
94 /**
95  * Constructs a new instance of RowData according to the parameter.
96  * A value of SWT.DEFAULT indicates that no minimum width or
97  * no minimum height is specified.
98  *
99  * @param point a point whose x coordinate specifies a minimum width for the control
100  * and y coordinate specifies a minimum height for the control
101  */
102 public RowData (Point point) {
103         this (point.x, point.y);
104 }
105
106 String getName () {
107         String string = getClass ().getName ();
108         int index = string.lastIndexOf ('.');
109         if (index == -1) return string;
110         return string.substring (index + 1, string.length ());
111 }
112
113 /**
114  * Returns a string containing a concise, human-readable
115  * description of the receiver.
116  *
117  * @return a string representation of the RowData object
118  */
119 @Override
120 public String toString () {
121         String string = getName ()+" {";
122         if (width != SWT.DEFAULT) string += "width="+width+" ";
123         if (height != SWT.DEFAULT) string += "height="+height+" ";
124         if (exclude) string += "exclude="+exclude+" ";
125         string = string.trim();
126         string += "}";
127         return string;
128 }
129 }