如何获取 SWT 小部件的皮肤?

发布于 2024-11-04 07:07:57 字数 148 浏览 0 评论 0原文

我想创建一个带有两个/多个拇指的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

无风消散 2024-11-11 07:07:58

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.).

方觉久 2024-11-11 07:07:58

看看 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

痕至 2024-11-11 07:07:58

虽然 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.

橘和柠 2024-11-11 07:07:58

在Windows上,在SWT实现绘图控件的API之前:
首先检查应用程序是否有主题,然后使用一个或另一个绘图 API:

public void paintTheme(GC gc, Shell shell, Rectangle bounds)
    RECT rect = new RECT();
    rect.left = bounds.x;
    rect.right = bounds.x + bounds.width;
    rect.top = bounds.y;
    rect.bottom = bounds.y + bounds.height;
    if (OS.IsAppThemed()) {
        int theme = OS.OpenThemeData(shell.handle, className);
        OS.DrawThemeBackground(theme, gc.handle, partId, stateId, rect, null);
        OS.CloseThemeData(theme);
    } else {
        OS.DrawFrameControl(gc.handle, rect, uType, uState);
    }
}

您可以在 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.hvsstyle.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:

public void paintTheme(GC gc, Shell shell, Rectangle bounds)
    RECT rect = new RECT();
    rect.left = bounds.x;
    rect.right = bounds.x + bounds.width;
    rect.top = bounds.y;
    rect.bottom = bounds.y + bounds.height;
    if (OS.IsAppThemed()) {
        int theme = OS.OpenThemeData(shell.handle, className);
        OS.DrawThemeBackground(theme, gc.handle, partId, stateId, rect, null);
        OS.CloseThemeData(theme);
    } else {
        OS.DrawFrameControl(gc.handle, rect, uType, uState);
    }
}

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文