简体   繁体   English

如何缩放SWT TableItem中的图像?

[英]How to scale images in an SWT TableItem?

I have been struggling to get the images displayed in an SWT TableItem to scale. 我一直在努力使图像显示在SWT TableItem中以进行缩放。 I have a listener which scales the fonts correctly, and I have confirmed that the images being set into the TableItem are correctly scaled. 我有一个可正确缩放字体的侦听器,并且我确认设置在TableItem中的图像已正确缩放。 I know that the scaled images are being successfully set into the TableItem, because I can even change what image gets displayed. 我知道缩放后的图像已成功设置到TableItem中,因为我什至可以更改显示的图像。 But the new image is always displayed at the original scale. 但是新图像始终以原始比例显示。

I have read in SWT: The Standard Widget Toolkit, Volume 1 where the authors state: 我在SWT中阅读过:标准窗口小部件工具包,第1卷 ,作者声明:

The First Image Defines the Size of All Images in the Control 第一个图像定义了控件中所有图像的大小

Due to a Windows limitation, just like ToolBar, TabFolder, and Tree, Table scales the images it displays to be the size of the first image inserted into the control. 由于Windows的限制,就像ToolBar,TabFolder和Tree一样,Table会将其显示的图像缩放为插入到控件中的第一个图像的大小。

The behaviour I'm seeing is the most extreme case suggested by this quote -- images in the table seem to be being scaled, not the the size of the first image in the table, but to the size of the first image ever to have been in the table . 我看到的行为是此报价所建议的最极端的情况-表格中的图片似乎正在缩放,而不是表格中第一张图片的大小,而是缩放到有史以来第一张图片的大小一直在桌子上 Can anyone confirm or refute this? 谁能确认或驳斥? Does anyone have any more detailed information about the behaviour of images in TableItems? 是否有人对TableItems中图像的行为有更详细的信息? Is this restriction really the show-stopper it seems to be? 这个限制真的是它的制胜法宝吗?

And in particular, if I go down the path of custom drawing table items ( Custom Drawing Table and Tree Items ), am I likely to bump into any further showstoppers? 特别是,如果我沿着自定义工程图表项(“ 自定义工程图表”和“树项” )的路径前进,是否有可能碰到更多的热门广告?

(You'll note what a good job I'm doing of gritting my teeth and not giving way to rage at having to deal with Windows stupidity even when using a supposedly cross-platform development environment!) (您会注意到,即使在使用所谓的跨平台开发环境的情况下,我咬牙切齿,也没有因为必须面对Windows愚蠢而大怒,这是一件多么出色的工作!)

I can confirm this in my experience on Windows. 我可以在Windows上的经验中证实这一点。

I propose one of two solutions: 我提出以下两种解决方案之一:

  • Use custom table drawing as per the link you mentioned. 按照您提到的链接使用自定义表格图形。 It's a little annoying but not more than 2 hours of work I'd say to learn and implement it. 这有点烦人,但我要花2个小时以上的时间来学习和实施它。
  • Use an alternative SWT table control eg Nebula Grid or KTable which do not share the same platform limitations of Table on Windows 使用备用SWT表控件,例如Nebula GridKTable ,它们在Windows上不共享Table的相同平台限制

Edit: in response to "And in particular, if I go down the path of custom drawing table items (Custom Drawing Table and Tree Items), am I likely to bump into any further showstoppers?" 编辑:回应“特别是,如果我沿着自定义工程图表项目(自定义工程图表和树项目)的路径前进,我是否有可能碰到任何其他的畅销产品?”

The only issue I found with custom drawing is that it's best to know ahead of time what the maximum row height will be, otherwise there will be jumping when Table has to increase the row height and therefore scroll items a bit while it readjusts 我在自定义绘图中发现的唯一问题是,最好提前知道最大行高是多少,否则当Table必须增加行高时会出现跳跃,因此在重新调整时稍微滚动一下项目

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM