Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Table Cell and two progress bars
Table Cell and two progress bars [message #1049576] Fri, 26 April 2013 02:47 Go to next message
Wojtek  is currently offline Wojtek
Messages: 47
Registered: August 2011
Member
Is there a way to get two progress bars into a table cell, one above
the other?

--
Wojtek :-)
Re: Table Cell and two progress bars [message #1050777 is a reply to message #1049576] Sat, 27 April 2013 18:53 Go to previous messageGo to next message
Wojtek  is currently offline Wojtek
Messages: 47
Registered: August 2011
Member
Wojtek wrote :
> Is there a way to get two progress bars into a table cell, one above the
> other?

Composite with a FormLayout within a TableEditor. The top progress bar
is FormAttached to the composite, and the bottom is FormAttached to the
top one, which allows the bars to expand when the cell expands in
width.

You also need a Listener so the cell's height expands to show both
bars. Still trying to get this to happen when the table is created
rather than at the first SWT.MeasureItem event.

--
Wojtek :-)
Re: Table Cell and two progress bars [message #1051398 is a reply to message #1050777] Sun, 28 April 2013 18:32 Go to previous message
Wojtek  is currently offline Wojtek
Messages: 47
Registered: August 2011
Member
Wojtek wrote :

> You also need a Listener so the cell's height expands to show both bars.
> Still trying to get this to happen when the table is created rather than at
> the first SWT.MeasureItem event.

Well, it's ugly, but as the last line in the fillTable() method:

table.addListener( SWT.MeasureItem, new TablePaintListener() );

then:

private class TablePaintListener implements Listener
{
@Override
public void handleEvent( Event event )
{
switch (event.type)
{
case SWT.MeasureItem:
{
// we use one of the progress bars to get the height

if ( progressBarTop[0] != null )
{
// set the height to fit two progress bars
// the decimal value is a fudge factor
double newHeight = progressBarTop[0].getSize().y * 2.64;

event.height = (int) newHeight;

// we only need to do the resize once
ivTable.removeListener( SWT.MeasureItem, this );
}
break;
}
}
}
};

What I don't get is why the event affects row height. Presumably it is
fired when the table needs resizing, but how is the event pointing at
the correct widget so that the height adjustment works?

And why do I need the ".64" to correctly set the height? Is the actual
height of a progress bar 1.32 times the reported height? Why?

BTW, the "top" of the top bar is offset "0", and the separation between
the two bars is "0", so I am not adding any extra "y" size.

--
Wojtek :-)
Previous Topic:Drag from SWT to Desktop
Next Topic:Resizing an Image: Without AntiAliasing it doesnt look good
Goto Forum:
  


Current Time: Sat Sep 20 04:13:22 GMT 2014

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

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