Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

measuring SWT / JFace column header padding size

I have a number of tables in an eclipse SWT application. They are Table/TableViewer tables and consist of a header, a row down the left with text and a series of graphics going across. There are 32 columns other than the text column, numbered from 0 to 31. On Windows 7 and XP in classic mode, the text is fine, but in XP normal mode, they are truncated so they appear to go 0 1 2 3 4 5 6 7 8 9 1. 1. 1. 1. 1. etc. There is clearly enough room for the text either way.

If I just set the default width to 28 instead of 25, as I found it, they are then fine, but obviously that isn't very good as then I need more room for the interface in Windows 7 and XP Classic, where it was already ok. I tried getting average width from fontmetrics but the text comes back as 5, in all modes. I can't find any way of either reducing of the padding (which would be the best way), or finding out how much padding there is (which would do). Do I need to draw the column headers manually?

ps: Sorry for the JFace / SWT, have only just started with this and not clear on the differences yet!

like image 705
Woody Avatar asked Feb 09 '26 22:02

Woody


1 Answers

Calling TableColumn#pack() should give a column exactly the width it needs to display its content without wasting any space or truncating its content. This includes the column's header text.

like image 76
Frettman Avatar answered Feb 15 '26 14:02

Frettman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!