Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » StackLayout in SashForm
StackLayout in SashForm [message #486517] Thu, 17 September 2009 23:16 Go to next message
Allen D. McDonald is currently offline Allen D. McDonaldFriend
Messages: 13
Registered: July 2009
Junior Member
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?
Re: StackLayout in SashForm [message #487062 is a reply to message #486517] Mon, 21 September 2009 17:33 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
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?
>
Re: StackLayout in SashForm [message #489442 is a reply to message #487062] Sat, 03 October 2009 03:42 Go to previous message
Allen D. McDonald is currently offline Allen D. McDonaldFriend
Messages: 13
Registered: July 2009
Junior Member
Grant, many thanks! That snippet helped me understand more about the StackLayout. My basic problem is that I am trying to switch between a TableViewer and a Text control. A TableViewer is not a Control. Oops.
What I wanted to do is show the detail ala master/detail in one side ot the sash, with a TreeViewer in the other side. Then, when I execute an external program, pipe the output into the Text Control and flip it to the top of the Stack.
I guess I'll have to pop a box to show the output.

Thanks for your help.
Previous Topic:SWT Shell Resizing Problem on Linux/GTK
Next Topic:Timeline widget
Goto Forum:
  


Current Time: Sat Apr 20 16:12:38 GMT 2024

Powered by FUDForum. Page generated in 0.03800 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top