使用 cairo 在 gtkentry 上方绘图

发布于 2024-09-02 13:20:53 字数 266 浏览 1 评论 0原文

我想使用 cairo 来增强 gtkentry 的外观。为此,我将回调连接到“expose-event”。在回调中,我调用 gtkentry 的原始暴露事件处理程序。之后,我创建开罗上下文并绘制一些线条并销毁开罗。我返回“TRUE”作为回调函数的返回值,以便暴露事件不会传播。

现在我的问题是,我正在从 (0,0) 到 (100,100) 画线。但线条仅出现在 gtkentry 的边界区域上。文字所在的地方,并没有出现。

请帮忙。

亲切的问候 ——德吉什·奥·米什拉

I want to use cairo to enhance gtkentry look. For this, I have connected a callback to 'expose-event'. In callback, I call gtkentry's original expose-event handler. After that, I create cairo context and draw some lines and destroy the cairo. I return 'TRUE' as return value of callback function so that expose-event does not propagate.

Now my problem is, I am drawing line from (0,0) to (100,100). But line appears only over the border areas of the gtkentry. The place where text is, it does not appear.

Please help.

Kind Regards
-Durgesh O Mishra

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

一个人的夜不怕黑 2024-09-09 13:20:54

GtkEntry 使用额外的 GdkWindow 作为文本区域。它是私有的,但您可以使用以下代码访问它:

GDK_WINDOW (gdk_window_peek_children (GTK_WIDGET (entry)->window)->data);

因此,您可以将此窗口传递给gdk_cairo_create()

如果您在将其应用到代码中时遇到问题,请粘贴代码 - 如果没有任何测试方法,很难猜测要做什么。

GtkEntry uses an additional GdkWindow for the text area. It is sort-of-private, but you could access it using the following code:

GDK_WINDOW (gdk_window_peek_children (GTK_WIDGET (entry)->window)->data);

So, you can pass this window to gdk_cairo_create().

If you have problems applying this to your code, paste the code — it's hard to guess what to do without having any way to test.

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