Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Layout manager question
Layout manager question [message #463878] Tue, 15 November 2005 13:54 Go to next message
Eclipse UserFriend
Originally posted by: Thomas.Vogler.softwareAG.com

Hi all,

I am reletively new to SWT, but i think i did my homework. Still i cannot
find a way, not to say a good way, to solve my problem:

I require a canvas that has the same number of pixels in x and y direction.
And that is as big as possible. all space not required for the canvas should
be given to neighboring widgets.

What kind of layout manager and what layout data do i have to use to achieve
this ?

In a different approch i tried to subclass Canvas and to overwrite the
getSize method to return only squares - but this does not work either.

Thank you for any help !

Thomas
Re: Layout manager question [message #463907 is a reply to message #463878] Tue, 15 November 2005 16:35 Go to previous message
Veronika Irvine is currently offline Veronika IrvineFriend
Messages: 1272
Registered: July 2009
Senior Member
The following does almost what you want. It works perfectly when changing
the vertical size and it works when changing the horizontal size except it
will allow the canvas to become taller than the available client area. The
other alternative is to write your own Layout subclass.

public class Newsgroup {
class Test extends Canvas {
Test (Composite parent, int style) {
super(parent, style);
}
public Point computeSize(int wHint, int hHint, boolean changed) {
int width, height;
width = height = Math.max(wHint, hHint);
if (width == SWT.DEFAULT) width = height = 64;
return new Point(width, height);
}
}
public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
shell.setLayout(new GridLayout(3, false));
Button b = new Button(shell, SWT.PUSH);
b.setText("Button 1");
Test test = new Newsgroup().new Test(shell, SWT.BORDER);
test.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
b = new Button(shell, SWT.PUSH);
b.setText("Button 2");
b = new Button(shell, SWT.PUSH);
b.setText("Button 3");
b = new Button(shell, SWT.PUSH);
b.setText("Button 4");
b = new Button(shell, SWT.PUSH);
b.setText("Button 5");
b = new Button(shell, SWT.PUSH);
b.setText("Button 6");
b = new Button(shell, SWT.PUSH);
b.setText("Button 7");
shell.pack();
shell.open ();
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
}

"T. Vogler" <Thomas.Vogler@softwareAG.com> wrote in message
news:dlcpgi$9ca$1@news.eclipse.org...
> Hi all,
>
> I am reletively new to SWT, but i think i did my homework. Still i cannot
> find a way, not to say a good way, to solve my problem:
>
> I require a canvas that has the same number of pixels in x and y
> direction. And that is as big as possible. all space not required for the
> canvas should be given to neighboring widgets.
>
> What kind of layout manager and what layout data do i have to use to
> achieve this ?
>
> In a different approch i tried to subclass Canvas and to overwrite the
> getSize method to return only squares - but this does not work either.
>
> Thank you for any help !
>
> Thomas
>
>
Previous Topic:Error Log
Next Topic:How to avoid flicker when resizing Composite or canvas?
Goto Forum:
  


Current Time: Fri Apr 26 08:40:37 GMT 2024

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

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

Back to the top