Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Problem with RowLayout wrap inside a FormLayout?
Problem with RowLayout wrap inside a FormLayout? [message #451458] |
Wed, 02 March 2005 16:42 |
Donna Gresh Messages: 30 Registered: July 2009 |
Member |
|
|
This is a multipart message in MIME format.
--=_alternative 005BCAB285256FB8_=
Content-Type: text/plain; charset="US-ASCII"
This seems very similar to an earlier post regarding a problem with
RowLayout wrap inside a GridLayout, but the same solution didn't work for
me because FormData does not have a widthHint.
Briefly, I have a composite which has a FormLayout. I want one component
of it to be a "button holder" composite with a rowLayout (horizontal), and
I want it to take up just enough room to hold its buttons, and that might
be one or two or three rows, depending on the width of the overall
composite. I want the other component of the composite to be the largest
size it can be (it's a drawing), taking up "the rest" of the room.
I attach the "button composite" to the left, top, and right of the
Composite holding it, and I attach the "picture" to the left, right, and
bottom of the Composite holding it, plus I attach its top to the
"buttonComposite". This does just what I want *except* that the "button
Composite" does not wrap; it clips the buttons instead, and remains one
row in height at all times.
As I mentioned, FormData does not have a widthHint, so I experimented with
using "width" instead like so (modifying the workaround given in the
earlier posting): however in this case, while it did wrap, the space it
takes up vertically did not change (that is, the "picture" did not get any
smaller, so it clipped off the buttons)
shell.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Rectangle area = shell.getClientArea();
FormData data = (FormData)(rightPanel.getLayoutData());
data.width = area.width;
shell.layout(true);
}
});
Is it possible to do what I want, that is, have the RowLayout "button
Composite" wrap properly?
--=_alternative 005BCAB285256FB8_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 face="sans-serif">This seems very similar to an earlier
post regarding a problem with RowLayout wrap inside a GridLayout, but the
same solution didn't work for me because FormData does not have a widthHint.</font>
<br>
<br><font size=2 face="sans-serif">Briefly, I have a composite which has
a FormLayout. I want one component of it to be a "button holder"
composite with a rowLayout (horizontal), and I want it to take up just
enough room to hold its buttons, and that might be one or two or three
rows, depending on the width of the overall composite. I want the other
component of the composite to be the largest size it can be (it's
a drawing), taking up "the rest" of the room.</font>
<br>
<br><font size=2 face="sans-serif">I attach the "button composite"
to the left, top, and right of the Composite holding it, and I attach the
"picture" to the left, right, and bottom of the Composite holding
it, plus I attach its top to the "buttonComposite". This does
just what I want *except* that the "button Composite" does not
wrap; it clips the buttons instead, and remains one row in height at all
times.</font>
<br>
<br><font size=2 face="sans-serif">As I mentioned, FormData does not have
a widthHint, so I experimented with using "width" instead like
so (modifying the workaround given in the earlier posting): however
in this case, while it did wrap, the space it takes up vertically did not
change (that is, the "picture" did not get any smaller, so it
clipped off the buttons)</font>
<br>
<br><font size=2 face="sans-serif"> shell.addListener(SWT.Resize,
new Listener() {</font>
<br><font size=2 face="sans-serif">
public void handleEvent(Event e) {</font>
<br><font size=2 face="sans-serif">
Rectangle area = shell.getClientArea();</font>
<br><font size=2 face="sans-serif">
FormData data = (FormData)(rightPanel.getLayoutData());</font>
<br><font size=2 face="sans-serif">
data.width = area.width;</font>
<br><font size=2 face="sans-serif">
shell.layout(true);</font>
<br><font size=2 face="sans-serif">
}</font>
<br><font size=2 face="sans-serif">
});</font>
<br>
<br><font size=2 face="sans-serif">Is it possible to do what I want, that
is, have the RowLayout "button Composite" wrap properly?</font>
--=_alternative 005BCAB285256FB8_=--
|
|
|
Re: Problem with RowLayout wrap inside a FormLayout? [message #451461 is a reply to message #451458] |
Wed, 02 March 2005 17:08 |
Veronika Irvine Messages: 1272 Registered: July 2009 |
Senior Member |
|
|
This is a multi-part message in MIME format.
------=_NextPart_000_00B8_01C51F20.8302CAE0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
What version of Eclipse/SWT are you running? In Eclipse 3.1 M3 or later =
the wrapping should just work without messing with the width value.
The following works for me in 3.0:
public static void main(String[] args) {
Display display =3D new Display();
final Shell shell =3D new Shell(display);
shell.setLayout(new FormLayout());
final Composite rightPanel =3D new Composite(shell, SWT.BORDER);
rightPanel.setLayout(new RowLayout());
for (int i =3D 0; i < 15; i++) {
Button b =3D new Button(rightPanel, SWT.PUSH);
b.setText("Button "+i);
}
FormData data =3D new FormData();
data.left =3D new FormAttachment(0, 10);
data.top =3D new FormAttachment(0, 10);
rightPanel.setLayoutData(data);
final Composite leftPanel =3D new Composite(shell, SWT.BORDER);
data =3D new FormData();
data.left =3D new FormAttachment(0, 10);
data.right =3D new FormAttachment(100, -10);
data.top =3D new FormAttachment(rightPanel, 10);
data.bottom =3D new FormAttachment(100, -10);
leftPanel.setLayoutData(data);
=20
shell.addListener(SWT.Resize, new Listener() {
public void handleEvent(Event e) {
Rectangle area =3D shell.getClientArea();=20
FormData data =3D (FormData)(rightPanel.getLayoutData());=20
data.width =3D area.width - 20;=20
shell.layout(true);=20
}
});
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
The code above works in 3.1 but it can also be simplified to:
public static void main(String[] args) {
Display display =3D new Display();
final Shell shell =3D new Shell(display);
shell.setLayout(new FormLayout());
final Composite rightPanel =3D new Composite(shell, SWT.BORDER);
rightPanel.setLayout(new RowLayout());
for (int i =3D 0; i < 15; i++) {
Button b =3D new Button(rightPanel, SWT.PUSH);
b.setText("Button "+i);
}
FormData data =3D new FormData();
data.left =3D new FormAttachment(0, 10);
data.top =3D new FormAttachment(0, 10);
data.right =3D new FormAttachment(100, -10);
rightPanel.setLayoutData(data);
final Composite leftPanel =3D new Composite(shell, SWT.BORDER);
data =3D new FormData();
data.left =3D new FormAttachment(0, 10);
data.right =3D new FormAttachment(100, -10);
data.top =3D new FormAttachment(rightPanel, 10);
data.bottom =3D new FormAttachment(100, -10);
leftPanel.setLayoutData(data);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
<gresh@us.ibm.com> wrote in message =
news:d04qdr$mcn$1@www.eclipse.org...
This seems very similar to an earlier post regarding a problem with =
RowLayout wrap inside a GridLayout, but the same solution didn't work =
for me because FormData does not have a widthHint.=20
Briefly, I have a composite which has a FormLayout. I want one =
component of it to be a "button holder" composite with a rowLayout =
(horizontal), and I want it to take up just enough room to hold its =
buttons, and that might be one or two or three rows, depending on the =
width of the overall composite. I want the other component of the =
composite to be the largest size it can be (it's a drawing), taking up =
"the rest" of the room.=20
I attach the "button composite" to the left, top, and right of the =
Composite holding it, and I attach the "picture" to the left, right, and =
bottom of the Composite holding it, plus I attach its top to the =
"buttonComposite". This does just what I want *except* that the "button =
Composite" does not wrap; it clips the buttons instead, and remains one =
row in height at all times.=20
As I mentioned, FormData does not have a widthHint, so I experimented =
with using "width" instead like so (modifying the workaround given in =
the earlier posting): however in this case, while it did wrap, the =
space it takes up vertically did not change (that is, the "picture" did =
not get any smaller, so it clipped off the buttons)=20
shell.addListener(SWT.Resize, new Listener() {=20
public void handleEvent(Event e) {=20
Rectangle area =3D shell.getClientArea();=20
FormData data =3D (FormData)(rightPanel.getLayoutData()); =
data.width =3D area.width;=20
shell.layout(true);=20
}=20
});=20
Is it possible to do what I want, that is, have the RowLayout "button =
Composite" wrap properly?
------=_NextPart_000_00B8_01C51F20.8302CAE0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2604" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>What version of Eclipse/SWT are you running? =
In Eclipse=20
3.1 M3 or later the wrapping should just work without messing with the =
width=20
value.</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>The following works for me in 3.0:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>public static void main(String[] args)=20
{<BR> Display display =3D new=20
Display();<BR> final Shell =
shell =3D new=20
Shell(display);<BR> =20
shell.setLayout(new =
FormLayout());<BR> =20
final Composite rightPanel =3D new Composite(shell,=20
SWT.BORDER);<BR> =20
rightPanel.setLayout(new=20
RowLayout());<BR> for (int i =
=3D 0; i=20
< 15; i++)=20
{<BR> &n=
bsp; =20
Button b =3D new Button(rightPanel,=20
SWT.PUSH);<BR>  =
; =20
b.setText("Button "+i);<BR> =20
}<BR> FormData data =3D new=20
FormData();<BR> data.left =3D =
new=20
FormAttachment(0, 10);<BR> =
data.top=20
=3D new FormAttachment(0, =
10);<BR> =20
rightPanel.setLayoutData(data);<BR> &n=
bsp;=20
final Composite leftPanel =3D new Composite(shell,=20
SWT.BORDER);<BR> data =3D new=20
FormData();<BR> data.left =3D =
new=20
FormAttachment(0, 10);<BR> =
data.right=20
=3D new FormAttachment(100, =
-10);<BR> =20
data.top =3D new FormAttachment(rightPanel,=20
10);<BR> data.bottom =3D new=20
FormAttachment(100, -10);<BR> =20
leftPanel.setLayoutData(data);<BR> &nb=
sp;=20
<BR> =
shell.addListener(SWT.Resize, new=20
Listener()=20
{<BR> &n=
bsp; =20
public void handleEvent(Event e)=20
{<BR> &n=
bsp; &n bsp; =20
Rectangle area =3D shell.getClientArea();=20
<BR> =
FormData=20
data =3D (FormData)(rightPanel.getLayoutData());=20
<BR> =20
data.width =3D area.width - 20;=20
<BR> =20
shell.layout(true);=20
<BR> &nb=
sp; =20
}<BR> =20
});<BR> =20
shell.open();<BR> while=20
(!shell.isDisposed())=20
{<BR> &n=
bsp; =20
if=20
(!display.readAndDispatch())<BR>  =
;   ;   ;=
=20
display.sleep();<BR> =20
}<BR> =20
display.dispose();<BR>}</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>The code above works in 3.1 but it can also be =
simplified=20
to:</FONT></DIV>
<DIV><FONT size=3D2></FONT> </DIV>
<DIV><FONT size=3D2>public static void main(String[] args)=20
{<BR> Display display =3D new=20
Display();<BR> final Shell =
shell =3D new=20
Shell(display);<BR> =20
shell.setLayout(new =
FormLayout());<BR> =20
final Composite rightPanel =3D new Composite(shell,=20
SWT.BORDER);<BR> =20
rightPanel.setLayout(new=20
RowLayout());<BR> for (int i =
=3D 0; i=20
< 15; i++)=20
{<BR> &n=
bsp; =20
Button b =3D new Button(rightPanel,=20
SWT.PUSH);<BR>  =
; =20
b.setText("Button "+i);<BR> =20
}<BR> FormData data =3D new=20
FormData();<BR> data.left =3D =
new=20
FormAttachment(0, 10);<BR> =
data.top=20
=3D new FormAttachment(0, =
10);<BR> =20
data.right =3D new FormAttachment(100,=20
-10);<BR> =20
rightPanel.setLayoutData(data);<BR> &n=
bsp;=20
final Composite leftPanel =3D new Composite(shell,=20
SWT.BORDER);<BR> data =3D new=20
FormData();<BR> data.left =3D =
new=20
FormAttachment(0, 10);<BR> =
data.right=20
=3D new FormAttachment(100, =
-10);<BR> =20
data.top =3D new FormAttachment(rightPanel,=20
10);<BR> data.bottom =3D new=20
FormAttachment(100, -10);<BR> =20
leftPanel.setLayoutData(data);<BR> &nb=
sp;=20
shell.open();<BR> while=20
(!shell.isDisposed())=20
{<BR> &n=
bsp; =20
if=20
(!display.readAndDispatch())<BR>  =
;   ;   ;=
=20
display.sleep();<BR> =20
}<BR> =20
display.dispose();<BR>}</FONT></DIV>
<BLOCKQUOTE=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV><<A href=3D"mailto:gresh@us.ibm.com">gresh@us.ibm.com</A>> =
wrote in=20
message <A=20
=
href=3D"news:d04qdr$mcn$1@www.eclipse.org">news:d04qdr$mcn$1@www.eclipse.=
org</A>...</DIV><BR><FONT=20
face=3Dsans-serif size=3D2>This seems very similar to an earlier post =
regarding a=20
problem with RowLayout wrap inside a GridLayout, but the same solution =
didn't=20
work for me because FormData does not have a widthHint.</FONT> =
<BR><BR><FONT=20
face=3Dsans-serif size=3D2>Briefly, I have a composite which has a =
FormLayout. I=20
want one component of it to be a "button holder" composite with a =
rowLayout=20
(horizontal), and I want it to take up just enough room to hold its =
buttons,=20
and that might be one or two or three rows, depending on the width of =
the=20
overall composite. I want the other component of the composite to =
be the=20
largest size it can be (it's a drawing), taking up "the rest" of the=20
room.</FONT> <BR><BR><FONT face=3Dsans-serif size=3D2>I attach the =
"button=20
composite" to the left, top, and right of the Composite holding it, =
and I=20
attach the "picture" to the left, right, and bottom of the Composite =
holding=20
it, plus I attach its top to the "buttonComposite". This does just =
what I want=20
*except* that the "button Composite" does not wrap; it clips the =
buttons=20
instead, and remains one row in height at all times.</FONT> =
<BR><BR><FONT=20
face=3Dsans-serif size=3D2>As I mentioned, FormData does not have a =
widthHint, so=20
I experimented with using "width" instead like so (modifying the =
workaround=20
given in the earlier posting): however in this case, while it =
did wrap,=20
the space it takes up vertically did not change (that is, the =
"picture" did=20
not get any smaller, so it clipped off the buttons)</FONT> =
<BR><BR><FONT=20
face=3Dsans-serif size=3D2> =20
shell.addListener(SWT.Resize, new Listener() {</FONT> <BR><FONT=20
face=3Dsans-serif size=3D2> =
public void=20
handleEvent(Event e) {</FONT> <BR><FONT face=3Dsans-serif =
size=3D2> =20
Rectangle area =3D=20
shell.getClientArea();</FONT> <BR><FONT face=3Dsans-serif =
size=3D2> =20
FormData data =3D=20
(FormData)(rightPanel.getLayoutData());</FONT> <BR><FONT =
face=3Dsans-serif=20
size=3D2> data.width =
=3D=20
area.width;</FONT> <BR><FONT face=3Dsans-serif size=3D2> =
=20
shell.layout(true);</FONT> <BR><FONT=20
face=3Dsans-serif size=3D2> =
}</FONT>=20
<BR><FONT face=3Dsans-serif size=3D2> =
=20
});</FONT> <BR><BR><FONT face=3Dsans-serif size=3D2>Is it =
possible to do=20
what I want, that is, have the RowLayout "button Composite" wrap=20
properly?</FONT></BLOCKQUOTE></BODY></HTML>
------=_NextPart_000_00B8_01C51F20.8302CAE0--
|
|
| | |
Re: Problem with RowLayout wrap inside a FormLayout? [message #451549 is a reply to message #451547] |
Wed, 02 March 2005 19:28 |
Donna Gresh Messages: 30 Registered: July 2009 |
Member |
|
|
This is a multipart message in MIME format.
--=_alternative 006AEFC285256FB8_=
Content-Type: text/plain; charset="US-ASCII"
Thanks so much--
I had (stupidly) installed 3.1 over 3.0 and that caused all sorts of
problems. I reinstalled in a clean place, got the corresponding version of
GEF, updated my project properties so that the libraries point to the
newer jars for jface etc., updated my path to find the new swt dll and all
works as advertised. I noticed a need to resize my window to see my
widgets, but I recall something from this list about that so I'm not
worried and I'll go look it up and take care of it.
The rowlayout inside the formlayout does just what I expect now.
Thanks for your help; I have noticed that questions are quickly and
helpfully answered on this group list, even silly ones. It is really
appreciated :)
--=_alternative 006AEFC285256FB8_=
Content-Type: text/html; charset="US-ASCII"
<br><font size=2 face="sans-serif">Thanks so much--</font>
<br><font size=2 face="sans-serif">I had (stupidly) installed 3.1 over
3.0 and that caused all sorts of problems. I reinstalled in a clean place,
got the corresponding version of GEF, updated my project properties so
that the libraries point to the newer jars for jface etc., updated my path
to find the new swt dll and all works as advertised. I noticed a need to
resize my window to see my widgets, but I recall something from this list
about that so I'm not worried and I'll go look it up and take care of it.</font>
<br>
<br><font size=2 face="sans-serif">The rowlayout inside the formlayout
does just what I expect now.</font>
<br>
<br><font size=2 face="sans-serif">Thanks for your help; I have noticed
that questions are quickly and helpfully answered on this group list, even
silly ones. It is really appreciated :)</font>
--=_alternative 006AEFC285256FB8_=--
|
|
|
Goto Forum:
Current Time: Fri Apr 26 20:53:04 GMT 2024
Powered by FUDForum. Page generated in 0.03287 seconds
|