Home » Eclipse Projects » Platform - User Assistance (UA) » Form layout correct only during resizing?
Form layout correct only during resizing? [message #469617] |
Wed, 12 September 2007 08:32 |
Kim Sullivan Messages: 44 Registered: July 2009 |
Member |
|
|
Hello,
I've encountered a strange problem - my form is laid out too wide, so
that horizontal scrollbars appear. The strange thing is, that the form
is laid out correctly during resizing, but once resizing stops, it goes
back to being too wide (and scrollbars appear).
The main form has a GridLayout (because I sometimes need to display a
master details block on the bottom). The top is filled with a Composite
with GridData(SWT.FILL, GridData.BEGINNING, true, false), and a
TableWrapLayout with two columns (setting columns equal width doesn't help).
The top composite contains 2 sections with a TableWrapLayout, both have
their layuout data set to FILL_GRAB.
+form body - GridLayout-----------------------------------+
| |
| +top composite - TableWrapLayout(boolean,2)-----------+ |
| | | |
| | +section (FILL_GRAB)----+ +section (FILL_GRAB)----+ | |
| | | | | | | |
| | +-----------------------+ +-----------------------+ | |
| | | |
| +-----------------------------------------------------+ |
| |
+---------------------------------------------------------+
Thanks for any pointers,
Kim
|
|
| |
Re: Form layout correct only during resizing? [message #469629 is a reply to message #469617] |
Wed, 12 September 2007 19:51 |
Eric Rizzo Messages: 3070 Registered: July 2009 |
Senior Member |
|
|
Kim Sullivan wrote:
> Hello,
>
> I've encountered a strange problem - my form is laid out too wide, so
> that horizontal scrollbars appear. The strange thing is, that the form
> is laid out correctly during resizing, but once resizing stops, it goes
> back to being too wide (and scrollbars appear).
>
> The main form has a GridLayout
The standard layouts don't all work well as the top-level layout in a
ScrolledForm. Specifically, I've seen GridLayout cause the exact
problems you describe. I hoped that 3.3 would fix it, but if you're
using 3.3 and still see it, then I guess I'm still disappointed.
Anyway, the ColumnLayout and TableWrapLayout obviosuly work (they were
designed specifically for Forms), and I've had good luck with the
FormLayout, too.
If you want to use a GridLayout at the top level, a workaround is to
make the form body use ColumnLayout (specify a maxColumns of 1), add a
"dummy" composite as the only child of that, and then you can use
GridLayout in the "dummy" and make your "real" children under that.
Hope this helps,
Eric
|
|
|
Re: Form layout correct only during resizing? [message #469637 is a reply to message #469629] |
Thu, 13 September 2007 07:06 |
Kim Sullivan Messages: 44 Registered: July 2009 |
Member |
|
|
Hello Eric,
> If you want to use a GridLayout at the top level, a workaround is to
> make the form body use ColumnLayout (specify a maxColumns of 1), add a
> "dummy" composite as the only child of that, and then you can use
> GridLayout in the "dummy" and make your "real" children under that.
Actually, that's not possible, because the
org.eclipse.ui.forms.MasterDetailsBlock forces a GridLayout upon the
body of the form, regardless of what layout I set the form to:
public void createContent(IManagedForm managedForm) {
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
form.getBody().setLayout(layout);
...
}
I can't easily override that method, because it acesses several private
methods, and I didn't want to fix this by cutting and pasting the whole
class and using MyMasterDetailsBlock or something like that (and who
knows what kinds of problems changing the layout might bring), so I had
to resort to the layout I described. I would have preferred to simply
use TableWrapLayout in the first place.
I think there's a bug report somewhere that already addresses the fact
that MasterDetailsBlock doesn't really play well if it's not the only
component on the form (it also reacts to all selection events, not just
events from the master part).
Regards,
Kim
|
|
| |
Re: Form layout correct only during resizing? [message #576733 is a reply to message #469617] |
Wed, 12 September 2007 19:51 |
Eric Rizzo Messages: 3070 Registered: July 2009 |
Senior Member |
|
|
Kim Sullivan wrote:
> Hello,
>
> I've encountered a strange problem - my form is laid out too wide, so
> that horizontal scrollbars appear. The strange thing is, that the form
> is laid out correctly during resizing, but once resizing stops, it goes
> back to being too wide (and scrollbars appear).
>
> The main form has a GridLayout
The standard layouts don't all work well as the top-level layout in a
ScrolledForm. Specifically, I've seen GridLayout cause the exact
problems you describe. I hoped that 3.3 would fix it, but if you're
using 3.3 and still see it, then I guess I'm still disappointed.
Anyway, the ColumnLayout and TableWrapLayout obviosuly work (they were
designed specifically for Forms), and I've had good luck with the
FormLayout, too.
If you want to use a GridLayout at the top level, a workaround is to
make the form body use ColumnLayout (specify a maxColumns of 1), add a
"dummy" composite as the only child of that, and then you can use
GridLayout in the "dummy" and make your "real" children under that.
Hope this helps,
Eric
|
|
|
Re: Form layout correct only during resizing? [message #576775 is a reply to message #469629] |
Thu, 13 September 2007 07:06 |
Kim Sullivan Messages: 44 Registered: July 2009 |
Member |
|
|
Hello Eric,
> If you want to use a GridLayout at the top level, a workaround is to
> make the form body use ColumnLayout (specify a maxColumns of 1), add a
> "dummy" composite as the only child of that, and then you can use
> GridLayout in the "dummy" and make your "real" children under that.
Actually, that's not possible, because the
org.eclipse.ui.forms.MasterDetailsBlock forces a GridLayout upon the
body of the form, regardless of what layout I set the form to:
public void createContent(IManagedForm managedForm) {
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
GridLayout layout = new GridLayout();
layout.marginWidth = 0;
layout.marginHeight = 0;
form.getBody().setLayout(layout);
...
}
I can't easily override that method, because it acesses several private
methods, and I didn't want to fix this by cutting and pasting the whole
class and using MyMasterDetailsBlock or something like that (and who
knows what kinds of problems changing the layout might bring), so I had
to resort to the layout I described. I would have preferred to simply
use TableWrapLayout in the first place.
I think there's a bug report somewhere that already addresses the fact
that MasterDetailsBlock doesn't really play well if it's not the only
component on the form (it also reacts to all selection events, not just
events from the master part).
Regards,
Kim
|
|
|
Goto Forum:
Current Time: Fri Apr 26 05:05:11 GMT 2024
Powered by FUDForum. Page generated in 0.03230 seconds
|