如何更改SWT树加/减图标 [英] How to change SWT Tree plus/minus icons

查看:194
本文介绍了如何更改SWT树加/减图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发类似于的SWT树但是,我希望能够在某些情况下显示+符号而不是 - 对于扩展的树项目。这可能吗 ?

I am working on a SWT Tree similar to the one here, however, I want to be able to show + signs in some cases instead of - for an expanded tree item. Is this possible ?

如果没有,是否有Windows API具有树项目的展开/折叠状态的自定义图标?

If not, is there Windows API to have custom icons for the expanded/collapsed state of a tree item ?

推荐答案

SWT树组件使用本机树小部件(如果可用),例如在Windows的情况下 - 它使用本机小部件而在Linux上(取决于所使用的UI引擎),它可以自己创建自定义树。

The SWT Tree component makes use of native Tree widget if available, for example in case of Windows - it uses native widget while on Linux (depends on the UI engine being used), it may create custom tree on its own.

在使用本机Tree小部件的操作系统上,不可能自定义+和 - 图标。

On the OS where it uses native Tree widget, it's not possible to customize the + and - icons.

正如阿里建议的那样(参见 http://msdn.microsoft.com/en-us/library/bb773568%28VS.85%29.aspx ),您可能希望使用 TVE_EXPANDPARTIAL ,但请记住,代码将取决于操作系统(即使在Windows版本中)。

As Ali suggested (see http://msdn.microsoft.com/en-us/library/bb773568%28VS.85%29.aspx), you may wish to use TVE_EXPANDPARTIAL, but keep in mind that the code will be OS dependent (even within versions of Windows).

但是,您可能希望使用自定义图像 - 在 TreeContentProvider 中使用 getImage()方法来指示否则而不是依赖于 TVE_EXPANDPARTIAL 。这也将确保您的代码与操作系统无关。

You may, however, wish you use a custom image - using getImage() method in the TreeContentProvider to indicate the otherwise rather than relying on TVE_EXPANDPARTIAL. This will also ensure that your code is OS independent.

这篇关于如何更改SWT树加/减图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆