Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Composite Sizes
Composite Sizes [message #465047] Sun, 04 December 2005 13:29 Go to next message
Eclipse User
Originally posted by: eskay187.sbox.tugraz.at

<noob>
Hi.
I've created a Composite which contains a TableViewer and a Lable
(status text etc.) but i have the problem that whenever i set a
GridLayout the TableViewer gets very small and i have to resize
every value manually.
So i tried FillLayout, which sets the acorrect size to the TableViewer
but the label is large as the TableViewer.

I tried to put each into it's own composite but still the label is too
large, even when i try to set the soizes manually.

Could please someone look quickly through the code and help me ?

"
public void createPartControl(Composite parent)
{
// set display
display_= parent.getDisplay();

// create new table viewer
Composite viewer = new Composite(parent, SWT.NONE);
FillLayout fill = new FillLayout (SWT.VERTICAL);
viewer.setLayout(fill);
viewer.setVisible(true);
viewer_ = new TableViewer(viewer, SWT.TOP | SWT.SINGLE | SWT.V_SCROLL);

// SOME VIEWER_ STUFF HERE

Composite test = new Composite (parent, SWT.NONE);
label_ = new Label(test, SWT.HORIZONTAL);
label_.setText("test");

//label_.setFont(font_registry_.get("list"));
label_.pack();
test.pack();
test.setVisible(true);
label_.setVisible(true);


FillLayout grid = new FillLayout (SWT.VERTICAL);
parent.setLayout(grid);

}
"

Kind Regards
Helmut

</noob>
Re: Composite Sizes [message #465058 is a reply to message #465047] Sun, 04 December 2005 23:52 Go to previous messageGo to next message
Eclipse User
Originally posted by: osipov.appliedtech.ru

Anyway, try something like this. I use gridData usually. Actually, you don't
need those size hints. If something like you've described is happening, i.e.
you've messed something with layouts.
public void createPartControl(Composite parent)
{
// set display
display_= parent.getDisplay();
parent.setLayout(new GridLayout());
parent.setLayoutData(new GridData(GridData.FILL_BOTH));

// create new table viewer
Composite viewer = new Composite(parent, SWT.NONE);
viewer.setVisible(true);
viewer = new TableViewer(viewer, SWT.TOP | SWT.SINGLE | SWT.V_SCROLL);
GridData gridData = new GridData(GridData.FILL_BOTH);
gridData.widthHint = 300;
gridData.heightHint = 300;
viewer.setLayoutData(gridData);
//...

}
> Hi.
> I've created a Composite which contains a TableViewer and a Lable
> (status text etc.) but i have the problem that whenever i set a
> GridLayout the TableViewer gets very small and i have to resize
> every value manually.
> So i tried FillLayout, which sets the acorrect size to the TableViewer
> but the label is large as the TableViewer.
>
> I tried to put each into it's own composite but still the label is too
> large, even when i try to set the soizes manually.
>
> Could please someone look quickly through the code and help me ?
>
> "
> public void createPartControl(Composite parent)
> {
> // set display
> display_= parent.getDisplay();
>
> // create new table viewer
> Composite viewer = new Composite(parent, SWT.NONE);
> FillLayout fill = new FillLayout (SWT.VERTICAL);
> viewer.setLayout(fill);
> viewer.setVisible(true);
> viewer_ = new TableViewer(viewer, SWT.TOP | SWT.SINGLE | SWT.V_SCROLL);
>
> // SOME VIEWER_ STUFF HERE
>
> Composite test = new Composite (parent, SWT.NONE);
> label_ = new Label(test, SWT.HORIZONTAL);
> label_.setText("test");
>
> //label_.setFont(font_registry_.get("list"));
> label_.pack();
> test.pack();
> test.setVisible(true);
> label_.setVisible(true);
>
>
> FillLayout grid = new FillLayout (SWT.VERTICAL);
> parent.setLayout(grid);
>
> }
> "
>
> Kind Regards
> Helmut
>
> </noob>
Re: Composite Sizes [message #465065 is a reply to message #465058] Mon, 05 December 2005 02:46 Go to previous message
Eclipse User
Originally posted by: eskay187.sbox.tugraz.at

Hi!
Thank you for your answer, it works better now. I copied your solution
and the sizes of the comosites are perfect, but the label and the
tableviewer did have 0 sizes until i set them manually.

unfortunately the tableviewer "lost" the vertical scrollbar, and the
composite's doesn't work on the viewer. help ?

can i get the size of the view ? parent->size returns 0 (i guess this is
when everthing is constructed -> resizeeventhandler?)

thanks again
helmut


Peter Osipov wrote:
> Anyway, try something like this. I use gridData usually. Actually, you don't
> need those size hints. If something like you've described is happening, i.e.
> you've messed something with layouts.
> public void createPartControl(Composite parent)
> {
> // set display
> display_= parent.getDisplay();
> parent.setLayout(new GridLayout());
> parent.setLayoutData(new GridData(GridData.FILL_BOTH));
>
> // create new table viewer
> Composite viewer = new Composite(parent, SWT.NONE);
> viewer.setVisible(true);
> viewer = new TableViewer(viewer, SWT.TOP | SWT.SINGLE | SWT.V_SCROLL);
> GridData gridData = new GridData(GridData.FILL_BOTH);
> gridData.widthHint = 300;
> gridData.heightHint = 300;
> viewer.setLayoutData(gridData);
> //...
>
> }
>
>>Hi.
>>I've created a Composite which contains a TableViewer and a Lable
>>(status text etc.) but i have the problem that whenever i set a
>>GridLayout the TableViewer gets very small and i have to resize
>>every value manually.
>>So i tried FillLayout, which sets the acorrect size to the TableViewer
>>but the label is large as the TableViewer.
>>
>>I tried to put each into it's own composite but still the label is too
>>large, even when i try to set the soizes manually.
>>
>>Could please someone look quickly through the code and help me ?
>>
>>"
>>public void createPartControl(Composite parent)
>>{
>>// set display
>>display_= parent.getDisplay();
>>
>>// create new table viewer
>>Composite viewer = new Composite(parent, SWT.NONE);
>>FillLayout fill = new FillLayout (SWT.VERTICAL);
>>viewer.setLayout(fill);
>>viewer.setVisible(true);
>>viewer_ = new TableViewer(viewer, SWT.TOP | SWT.SINGLE | SWT.V_SCROLL);
>>
>>// SOME VIEWER_ STUFF HERE
>>
>>Composite test = new Composite (parent, SWT.NONE);
>>label_ = new Label(test, SWT.HORIZONTAL);
>>label_.setText("test");
>>
>> //label_.setFont(font_registry_.get("list"));
>> label_.pack();
>>test.pack();
>>test.setVisible(true);
>>label_.setVisible(true);
>>
>>
>>FillLayout grid = new FillLayout (SWT.VERTICAL);
>>parent.setLayout(grid);
>>
>>}
>>"
>>
>>Kind Regards
>>Helmut
>>
>></noob>
>
>
>
>
Previous Topic:Can I do custom painting of a widget on the Workbench?
Next Topic:libflashplayer inside browser component
Goto Forum:
  


Current Time: Fri Aug 29 06:09:51 EDT 2014

Powered by FUDForum. Page generated in 0.02391 seconds