[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: GridLayout fill problem

Eric Rizzo schrieb:
Alexander Shterev wrote:
Hi,

I couldn't think of a good title for this entry, so here's the longer and clearer version:

I need to split a composite into two columns (e.g. with GridLayout or TableWrapLayout)and add components to each of them - something like the Plugin Manifest Editor in PDE. The idea is to fill the whole editor with this composite, so that each column is exactly half the size of the editor space (i.e. the layout will be re-calculated when the window is enlarged).

So far it goes like this:
composite.setLayout(new GridLayout(2,true));
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(composite);

This code is either wrong or the second line is irrelevant and you included it here by mistake. A composite has its layout set via setLayout(), correct; but setting that composite's layout data does not have the effect you seem to think it does. Applying the GridData to composite affects its behavior in its parent, not the behavior of composite's children. You need to set GridData on the children of composite appropriately.


Hope this helps,
    Eric

Of course, the grid data in the second line is for each column. I just copied the line from a diff class :D



The problem is that after adding some wider controls to this composite (wider than half the editor width), the column layout is then re-calculated and respectively the column width is increased. I need to prevent the latter from happening - i.e. I need to have a composite that is both dynamic and will acquire its parent size, and 'static enough' to preserve this size when its children try to enlarge it.
Is this somehow possible?


Thanx and cheers,
Alex