Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Unlogical layouting
Unlogical layouting [message #511169] |
Sat, 30 January 2010 17:53 |
Simon L. Messages: 22 Registered: January 2010 |
Junior Member |
|
|
Hello,
I created a wizardpage with a few containers on it, including a customized composite wich includes a Table (the composite is extended because extending the Table is forbidden).
I create every single object in the createControl of the Wizardpage. Changing some control's selections causes a preview of the changes in the data i described above, by calling a preview() method.
Now, when I start the Wizard, I change a control's selection, and the preview() method happens. Columns and Items populate the Table, everything works out fine. A screenshot is here:
http://screencast.com/t/YTBkYmQz
Now I want the preview happening on startup, so i call it at the very end of the createControl Method. Now, with nothing changed but this, it looks like this:
http://screencast.com/t/NTMxMzJhN
The only thing that changed was that the time the preview method was called. As far as I see, the layout happened before the preview method call in both cases, but in the second case, the table/the composite containing the table resized to how much columns are there, in the first case it just shows a scrollbar. (And I want it to do this).
The code is here:
The WizardPage (TranspTextWizardPage.java): http://pastebin.com/m2ebb178b
The Composite holding the table (TranspositionTable.java): http://pastebin.com/m1e83fdf6
I tried 2 hours to find my mistake, but wasn't lucky :/ Every help very much appreciated!!
|
|
|
Re: Unlogical layouting [message #511437 is a reply to message #511169] |
Mon, 01 February 2010 15:38 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
When a control is being laid out it is asked for its preferred size, which
is the size that it would take to fully display its content. In your first
case I think that the Table is empty at layout time, so it answers a
preferred size of 64x64, and is then grown by the layout to fill the page's
available width. However in your second case, the preview() invocation at
the end of TranspTextWizardPage.createControl() gives the Table its initial
content, but the Table is not actually laid out until after
TranspTextWizardPage.createControl() has returned. As a result the Table
answers a much wider preferred size, and the wizard page grows accordingly.
There are two possibilities for fixing this:
1. Specify a widthHint for the Table, similar to the heightHint that is
already being specified.
2. Call preview() a bit later. For instance, is there another wizard page
method that you can override, that is invoked by the framework just after
layout has completed? Or, asyncExec()'ing the preview() call would probably
work, though it's not an ideal approach. This would look something like:
transpositionTable1.getDisplay().asyncExec(new Runnable() {
public void run() {
if (transpositionTable1.isDisposed()) return;
preview();
}
});
HTH,
Grant
"Simon L." <abcba1307@yahoo.de> wrote in message
news:hk1rmj$9on$1@build.eclipse.org...
> Hello,
> I created a wizardpage with a few containers on it, including a customized
composite wich includes a Table (the composite is extended because extending
the Table is forbidden).
>
> I create every single object in the createControl of the Wizardpage.
Changing some control's selections causes a preview of the changes in the
data i described above, by calling a preview() method.
>
> Now, when I start the Wizard, I change a control's selection, and the
preview() method happens. Columns and Items populate the Table, everything
works out fine. A screenshot is here:
> http://screencast.com/t/YTBkYmQz
>
> Now I want the preview happening on startup, so i call it at the very end
of the createControl Method. Now, with nothing changed but this, it looks
like this:
> http://screencast.com/t/NTMxMzJhN
>
> The only thing that changed was that the time the preview method was
called. As far as I see, the layout happened before the preview method call
in both cases, but in the second case, the table/the composite containing
the table resized to how much columns are there, in the first case it just
shows a scrollbar. (And I want it to do this).
>
> The code is here:
> The WizardPage (TranspTextWizardPage.java): http://pastebin.com/m2ebb178b
> The Composite holding the table (TranspositionTable.java):
http://pastebin.com/m1e83fdf6
>
> I tried 2 hours to find my mistake, but wasn't lucky :/ Every help very
much appreciated!!
|
|
| |
Goto Forum:
Current Time: Sat May 11 16:55:16 GMT 2024
Powered by FUDForum. Page generated in 0.11816 seconds
|