1 /*******************************************************************************
2 * Copyright (c) 2000, 2018 IBM Corporation and others.
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/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.layout;
16 import org.eclipse.swt.*;
17 import org.eclipse.swt.graphics.*;
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
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>:
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));
37 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
39 public final class RowData {
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.
45 * The default value is SWT.DEFAULT.
47 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
49 public int width = SWT.DEFAULT;
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.
55 * The default value is SWT.DEFAULT.
57 * @see org.eclipse.swt.widgets.Control#computeSize(int, int, boolean)
59 public int height = SWT.DEFAULT;
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.
68 * The default value is <code>false</code>.
72 public boolean exclude = false;
75 * Constructs a new instance of RowData using
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.
86 * @param width a minimum width for the control
87 * @param height a minimum height for the control
89 public RowData (int width, int height) {
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.
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
102 public RowData (Point point) {
103 this (point.x, point.y);
107 String string = getClass ().getName ();
108 int index = string.lastIndexOf ('.');
109 if (index == -1) return string;
110 return string.substring (index + 1, string.length ());
114 * Returns a string containing a concise, human-readable
115 * description of the receiver.
117 * @return a string representation of the RowData object
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();