|
|
|
|
|
|
|
Re: the controls in a row should not be centered vertically. why?? [message #899602 is a reply to message #899557] |
Wed, 01 August 2012 14:41 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
The vertical centering happens _within the row of widgets_, not relative
to the parent widget (the Shell). So if your Buttons each had a height
of 100 and your Text had a height of 40, then the Text would be placed
at y=30 by the layout ((100 - 40) / 2 = 30).
To do what you want you're asking about you need an additional Composite
that is centered on the Shell, and set the layout on it. In your
snippet this would look like:
public RowLayoutExample() {
Display d = new Display();
Shell s = new Shell();
s.setSize(800, 600);
s.setText("A RowLayoutExample");
s.setLayout(new GridLayout());
Composite c = new Composite(s, SWT.NONE);
c.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_CENTER |
GridData.GRAB_VERTICAL));
RowLayout r1 = new RowLayout();
r1.wrap = false;
r1.pack = false;
r1.center = true;
r1.spacing = 0;
c.setLayout(r1);
new Text(c,SWT.MULTI|SWT.BORDER);
new Button(c,SWT.NONE).setText("ok");
new Button(c,SWT.NONE).setText("cancel");
s.open();
while (!s.isDisposed()) {
if (!d.readAndDispatch()) {
d.sleep();
}
}
d.dispose();
}
Grant
On 8/1/2012 8:20 AM, Jan Krakora wrote:
> Ad 1) But they are centered vertically.
> Ad 2) The cursor in a Text is as high as the font of that Text.
|
|
|
|
Powered by
FUDForum. Page generated in 0.04616 seconds