滚动 GtkDrawingArea
(C 语言,GTK 库)
在我的表单上,我有一个 GtkDrawingArea 小部件,我在其中使用 Cairo 绘制 GdkPixbufs (从文件加载)。我想要完成的是能够使用滚动条滚动绘图区域,同时窗口大小保持固定(绘制的图像大于窗口)。我怎样才能做到这一点?将 GtkDrawingArea 放入 ScrolledWindow 容器中不起作用(或者也许我做错了什么 - 我是 GTK 的新手)。
解决方案越简单越好。 干杯!
(C language, GTK library)
On my form, I have a GtkDrawingArea widget on which I draw GdkPixbufs (loaded from files) with Cairo. What I'd like to accomplish is to be able to scroll the drawing area with scrollbars while window size remains fixed (the image drawn is larger than the window). How can I do that? Putting GtkDrawingArea in ScrolledWindow container didn't work (or maybe I have done something wrong - I'm new to GTK).
The simpler solution the better.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有些小部件没有滚动功能。
GtkDrawingArea
就是其中之一。您可以通过先将这些小部件放入GtkViewport
中,然后放入GtkScrolledWindow
在 GTK 3.8 之前的版本gtk_scrolled_window_add_with_viewport
是执行此操作的一种便捷方法。在更高版本中,它由
gtk_container_add
。Some widgets don't have scrolling capability.
GtkDrawingArea
is one of them. You can adapt these widgets by putting them first inside aGtkViewport
then into aGtkScrolledWindow
In versions before GTK 3.8gtk_scrolled_window_add_with_viewport
is a convenience method to do this.In later versions it is done automatically by
gtk_container_add
.