如何获取 SWT 小部件的皮肤?
我想创建一个带有两个/多个拇指的 SWT Scale 小部件。问题是我希望它在每个平台上都有原生皮肤,而不是定制的皮肤。
实际上,我想获取小部件每个组件的皮肤并自己绘制它们。
有什么想法可以做到这一点,或者也许有替代解决方案?
谢谢!
I want to create an SWT Scale widget with two/multiple thumbs. The problem is that I want it to have the native skin on each platform and not a custom made skin.
Practically, I want to get the skin of every component of the widget and draw them myself.
Any ideas how to do that, or maybe an alternate solution?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SWT 小部件没有皮肤(与 Swing 小部件一样),它们由本机窗口工具包(Win32、Gtk+ 等)绘制。
SWT widgets don't have skins (as Swing widgets do), they are drawn by the native windowing toolkit (Win32, Gtk+, etc.).
看看 Riena 的外观和感觉:
http://wiki.eclipse.org/Riena_Look_and_Feel
Have a look on Riena Look and Feel:
http://wiki.eclipse.org/Riena_Look_and_Feel
虽然 Peter 的答案是正确的,但您可以尝试使用拇指在不同位置拍摄
Scale
的屏幕截图并将其覆盖。请参阅 http://tom-eclipse-dev.blogspot。 com/2007/01/tableviewers-and-nativelooking.html 有关此技术的示例。While Peter's answer is correct, you could try to take screenshots of
Scale
with thumbs in different positions and overlay them. See http://tom-eclipse-dev.blogspot.com/2007/01/tableviewers-and-nativelooking.html for an example of this technique.在Windows上,在SWT实现绘图控件的API之前:
首先检查应用程序是否有主题,然后使用一个或另一个绘图 API:
您可以在 http://msdn.microsoft.com/en-us/library/windows/desktop/bb773210%28v=vs.85%29 .aspx 以及非主题 API 的类型和状态,位于 http://msdn.microsoft.com/en-us/library/dd162480%28v=vs.85%29.aspx
请注意,并非所有控件都具有非主题类型。我认为在非主题应用程序中,比例拇指应该是一个按钮。
由于上面的链接没有为您提供部件、状态和类型值的值,因此我建议从头文件 winuser.h 和 vsstyle.h 中获取它们。
编辑:对于规模,在非主题应用程序中,我相信您必须使用拇指按钮。另外,我忘了提及,这使用了未记录的 API,并且不可移植。
On Windows, before SWT implements API for drawing controls:
first check if application is themed, and then use one or the other drawing API:
You can find class names and part and state ids at http://msdn.microsoft.com/en-us/library/windows/desktop/bb773210%28v=vs.85%29.aspx and types and states for non-themed API at http://msdn.microsoft.com/en-us/library/dd162480%28v=vs.85%29.aspx
Please note that not all controls have non-themed type. I believe that the thumb for the scale should be a button in non themed applications.
Because the links above do not give you the values for the part, states and type values, I suggest getting them from the header files winuser.h and vsstyle.h.
Edit: for scale, in not themed applications I believe you have to use button for thumb. Also, I forgot to mention that this uses non documented API, and it is not portable.