[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: Implementing a proper layout for wizard pages

Note: I'm copying this thread to the SWT newsgroup.

Whenever I have trouble with string-oriented widgets (Text and Label) wanting to stretch their containers, I've found two approaches that usually help:

A) If using a GridLayout, I set the widget's GridData to expand horizontally *and* its width hint to 1. This forces its "preferred" size to be just 1 pixel (which prevents it from stretching the container) and yet forces it to fill available space.

B) Switch to a different layout that will properly use the SWT.WRAP style, such as TableWrapLayout, FillLayout, etc. It is always good to remember that there are other worlds than just GridLayout ;-)

Hope this helps,
Eric


Karsten Stöckmann wrote:
Hi,

currently, I am experimenting with the layout of some wizard pages I've
created for an application I am currently working on.

As to find some kind of "best practise", I've come across the following:

I've got a wizard page containing an explanatory text (Label) that
occupies several lines. In the past, I've solved this by inserting
"hard" line breaks (\n) into the string. However, this is not a very
elegant approach, as of course this label won't adapt its size when the
wizard dialog is resized.

A better solution would be to use a Label that has the SWT.WRAP style
set, and to set a GridData that grabs the available space and fills its
cell as to make the Label automatically adapt its size to the dialog.
This works fine on Linux-Gtk; however, on win32 it does not - the label
stretches the entire dialog.

So, I've got two questions concerning this:

1. What is the difference in the described behaviour based on?
Obviously, gtk takes another "reference" for laying out the dialog and
determining its width than win32 does.

2. What would be a proper solution to this? Setting a width hint? If so,
where? Wizard dialog, wizard page, label?

(Actually, the same applies to PreferencePages; see
https://bugs.eclipse.org/bugs/show_bug.cgi?id=107064)

Best wishes,
Karsten