如何缩放 SWT TableItem 中的图像?
我一直在努力让 SWT TableItem 中显示的图像按比例显示。我有一个可以正确缩放字体的侦听器,并且我已确认设置到 TableItem 中的图像已正确缩放。我知道缩放后的图像已成功设置到 TableItem 中,因为我什至可以更改显示的图像。但新图像始终以原始比例显示。
第一个图像定义的大小 控件中的所有图像
由于Windows的限制,就像 工具栏、选项卡文件夹和树、表格 将其显示的图像缩放为 插入的第一张图像的大小 进入控件。
我看到的行为是这句话所建议的最极端的情况 - 表中的图像似乎正在缩放,不是表中第一个图像的大小,而是第一个图像的大小曾经在表中。谁能证实或反驳这一点?有谁有关于 TableItems 中图像行为的更详细信息?这个限制真的像看上去那样令人窒息吗?
特别是,如果我沿着自定义绘图表项目的路径 (自定义绘图表和树项目),我是否可能会遇到更多精彩内容?
(你会注意到,即使在使用所谓的跨平台开发环境时,我也咬紧牙关,没有因为必须处理 Windows 的愚蠢而愤怒,做得多么好!)
I have been struggling to get the images displayed in an SWT TableItem to scale. I have a listener which scales the fonts correctly, and I have confirmed that the images being set into the TableItem are correctly scaled. I know that the scaled images are being successfully set into the TableItem, because I can even change what image gets displayed. 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:
The First Image Defines the Size of
All Images in the ControlDue 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.
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? 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!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我可以根据我在 Windows 上的经验来证实这一点。
我提出两种解决方案之一:
编辑:响应“特别是,如果我沿着路径走下去自定义绘图表项目(自定义绘图表和树项目),我是否可能会遇到任何进一步的阻碍?”
我发现自定义绘图的唯一问题是,最好提前知道最大行高是多少,否则当表格必须增加行高时会出现跳跃,因此在重新调整时稍微滚动项目
I can confirm this in my experience on Windows.
I propose one of two solutions:
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
我对不同的树项目的不同图标(图像)有类似的问题。让它们都具有相同的大小(使用 GIMP 等程序)解决了我的问题。
I had a similar problem with different icons (images) for different tree items. Making them all the same size (with a program such as GIMP) solved my problem.