Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Calculate the number of visible items in a Table
Calculate the number of visible items in a Table [message #443760] Thu, 30 September 2004 09:54 Go to next message
Ruben Hesselbæk is currently offline Ruben HesselbækFriend
Messages: 14
Registered: July 2009
Junior Member
I have a Shell with a table inside and i need to calculate the number of
items it can hold that won't produce a vertical scrollbar, whenever it is
resized, but I just can't get it to work.
The problem is getting the height of the table.

If have tried a couple of methods
table.getBounds().height, but that number is way off when the shell is
resized.
table.getClientArea().height, still not right.

The only way if have got it top work is this very ugle hack, which is not
very crossplatform compliant.
((shell.getClientArea().height - 28) - table.getHeaderHeight()) /
table.getItemHeight()

I was hoping someone in here had a better way of doing it.

/Ruben Hesselbaek
Re: Calculate the number of visible items in a Table [message #443767 is a reply to message #443760] Thu, 30 September 2004 14:29 Go to previous messageGo to next message
Randy Hudson is currently offline Randy HudsonFriend
Messages: 123
Registered: July 2009
Senior Member
Have you tried calling computeBounds on a table with nothing but the
headers?

"Ruben Hesselb
Re: Calculate the number of visible items in a Table [message #443817 is a reply to message #443767] Fri, 01 October 2004 12:45 Go to previous message
Ruben Hesselbæk is currently offline Ruben HesselbækFriend
Messages: 14
Registered: July 2009
Junior Member
I have tried calling computeSize(SWT.DEFAULT, SWT.DEFAULT), since i can't
find computeBounds, and it is still not correct.
The problem is that computeSize() just returns the size needed to show the
table with all the current elements, and since the table is allready full,
then the size will be wrong.
If i make the shell larger, the returned size will be too small, because i
need to add TableItems to fill the table.
If i make the shell smaller, the returned size will be too large, because i
need to remove TableItems from the table.
I need a method that tells me the size of the Table after the resize.

/Ruben


"Randy Hudson" <none@us.ibm.com> wrote in message
news:cjh501$1v7$1@eclipse.org...
> Have you tried calling computeBounds on a table with nothing but the
> headers?
>
> "Ruben Hesselb
Previous Topic:General Detail Dialog
Next Topic:Canvas/Composite maximum size?
Goto Forum:
  


Current Time: Thu Apr 25 22:16:05 GMT 2024

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

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

Back to the top