测量 SWT/JFace 列标题填充大小
我的 eclipse SWT 应用程序中有许多表。它们是 Table/TableViewer 表格,由标题、左侧一行文字和一系列图形组成。除文本列外还有 32 列,编号从 0 到 31。 在 Windows 7 和 XP 的经典模式下,文本很好,但在 XP 正常模式下,它们被截断,因此看起来为 0 1 2 3 4 5 6 7 8 9 1. 1. 1. 1. 1. 等。无论哪种方式,文本显然都有足够的空间。
如果我只是将默认宽度设置为 28 而不是 25,正如我发现的那样,它们就很好,但显然这不是很好,因为那时我需要更多的空间用于 Windows 7 和 XP Classic 中的界面,其中它是已经可以了。 我尝试从 fontmetrics 获取平均宽度,但在所有模式下文本返回为 5。我找不到任何方法来减少填充(这将是最好的方法),或找出有多少填充(这将是)。我需要手动绘制列标题吗?
ps:对 JFace / SWT 感到抱歉,才刚刚开始使用,还不清楚其中的差异!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调用 TableColumn#pack() 应该为列提供显示其内容所需的宽度,而不会浪费任何空间或截断其内容。这包括列的标题文本。
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.您应该使用 TableLayout 对表格标题进行更动态的大小计算。以下博客文章是一个很好的起点: http ://eclipsenuggets.blogspot.com/2007/11/one-of-less-prominent-novelties-in.html
You should use the TableLayout for a more dynamic size calculation of your table headers. A good starting point is the following blog article: http://eclipsenuggets.blogspot.com/2007/11/one-of-less-prominent-novelties-in.html