|
Re: StackLayout in SashForm [message #487062 is a reply to message #486517] |
Mon, 21 September 2009 17:33 |
Grant Gayed Messages: 2150 Registered: July 2009 |
Senior Member |
|
|
Hi,
Are you saying you don't have a handle to one of the Controls within the
SashForm to ask it its size? If so then a hacky way to get it is via
SashForm.getChildren(), you just need to know which child index you're
looking for. There isn't other API that's more direct.
I originally read your question a bit differently, and modified Snippet109
to show a Composite with a StackLayout within a SashForm. It's pasted below
in case it could be of use.
public static void main (String [] args) {
final Display display = new Display ();
Shell shell = new Shell(display);
shell.setLayout (new FillLayout());
SashForm form = new SashForm(shell,SWT.HORIZONTAL);
form.setLayout(new FillLayout());
Composite child1 = new Composite(form,SWT.NONE);
child1.setLayout(new FillLayout());
new Label(child1,SWT.NONE).setText("Label in pane 1");
final Composite child2 = new Composite(form,SWT.NONE);
final Composite compWithStackLayout = new Composite(child2, SWT.NONE);
final StackLayout layout = new StackLayout();
compWithStackLayout.setLayout(layout);
final Label control1 = new Label(compWithStackLayout, SWT.WRAP);
control1.setText("I fill the top-left 25% of my parent");
control1.setBackground(display.getSystemColor(SWT.COLOR_RED) );
final Text control2 = new Text(compWithStackLayout, SWT.WRAP);
control2.setText("I fill the top-left 25% of my parent");
control2.setBackground(display.getSystemColor(SWT.COLOR_BLUE ));
layout.topControl = control1;
display.timerExec(2000, new Runnable() {
public void run() {
if (compWithStackLayout.isDisposed()) return;
if (layout.topControl == control1) {
layout.topControl = control2;
} else {
layout.topControl = control1;
}
Point size = child2.getSize();
System.out.println("compWithStackLayout size: " + size);
compWithStackLayout.setSize(size.x / 2, size.y / 2);
compWithStackLayout.layout();
display.timerExec(2000, this);
}
});
Composite child3 = new Composite(form,SWT.NONE);
child3.setLayout(new FillLayout());
new Label(child3,SWT.PUSH).setText("Label in pane3");
form.setWeights(new int[] {30,40,30});
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}
Grant
"Allen D. McDonald" <admcdonald1@verizon.net> wrote in message
news:6185e3c8981159aefec7510e32f3911c$1@www.eclipse.org...
> I am trying to get the aforementioned StackLayout to work in the second
> part of a two part SashForm and having trouble. (Of course, why else am I
> here...)
> I studied the Snippet249 code and played with it a bit and discovered that
> you HAVE TO set the bounds on the composite container ( in Snippet249 the
> contentPanel) or the StackLayout doesn't work. But it seems the SashForm
> doesn't easily lend itself to discovering the internal boundaries and I
> would need that to set the bounds on my content composite.
> So, can anyone help?
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03800 seconds