[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.platform.swt] Re: Resizing Shell
|
Hello, me again.
I have exactly same problem again, but this time i can't fix it.
Problem is that i'm doing an RCP app, so i have View.
In my View, "parent" is only a composite, i don't have anything else at
start.
Same probleme : i want to expand some widget when i resize my view.
I set a grid layout to my "parent" composite, and also tried with a
gridData with true to expand fields.
Then i have my widget (a tree or a table), with GridData and expand
fileds at "true".
But it simply don't do anything.
Any idea ?
Julien
Julien a écrit :
Thank you Manuel!
I have juste delete my "super-composite" and just put my canvas and
other composite into the shell layout.
VE asked me to create a layout and it generate that top-composite that i
didn't need and some way make the expand fail.
Now it's work fine.
:)
Julien
Manuel Selva a écrit :
Julien,
Here is a snippet showing a to tell a composite to grab excess space
// Creates display and shell
Display display = new Display();
Color white = display.getSystemColor (SWT.COLOR_WHITE);
Color red = display.getSystemColor (SWT.COLOR_RED);
Shell shell = new Shell(display);
shell.setSize(400, 200);
shell.setText("Grab Excess Space");
GridLayout shellLayout = new GridLayout();
shellLayout.numColumns = 2;
shell.setLayout(shellLayout);
// Creates the left canvas (grabbing excess horizontal
and vertical space)
Canvas canvas = new Canvas(shell, SWT.NONE);
canvas.setBackground(red);
GridData canvasData = new GridData();
canvasData.grabExcessHorizontalSpace = true;
canvasData.grabExcessVerticalSpace = true;
canvasData.horizontalAlignment = SWT.FILL;
canvasData.verticalAlignment = SWT.FILL;
canvas.setLayoutData(canvasData);
// Creates the left canvas (grabbing excess horizontal
and vertical space)
Composite composite = new Composite(shell, SWT.NONE);
composite.setBackground(white);
GridData compositeData = new GridData();
compositeData.horizontalAlignment = SWT.FILL;
compositeData.verticalAlignment = SWT.FILL;
composite.setLayoutData(compositeData);
// Opens the shell and starts UI loop
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
// Disposes allocated resources
white.dispose();
red.dispose();
display.dispose();
This simple example creates two composites inside a parent shell. Thsi
parent has a GridLayout with two columns.
The first composite, a canvas grabs excess horizontal and vertical
space when the shell is resized. The second composite only grab
vertical space. In this sample the second composite grabs vertical
space since there is only one raw in the layout and its GridData
object has the field verticalAlignement set to true.
Hope this can help
Manuel
PS : here is a very good article on SWT layouts:
http://www.eclipse.org/articles/Article-Understanding-Layouts/Understanding-Layouts.htm