调用 gdk_get_pixmap 需要什么?
我创建了一个小的绘图区域类,现在需要一个像素图来在公开事件回调期间绘制。但我无法获取我尝试编译的任何参数。以下是代码的相关部分...
类定义...
class set_display_drawing_area : public Gtk::DrawingArea
{
public:
set_display_drawing_area ();
virtual ~set_display_drawing_area ();
protected:
virtual bool on_expose_event(GdkEventExpose* event);
private:
GdkPixmap *pixmap_ptr;
};
以及公开回调...
bool set_display_drawing_area::on_expose_event(GdkEventExpose* event)
{
Glib::RefPtr<Gdk::Window> window = get_window();
if (window)
{
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
pixmap_ptr = gdk_pixmap_new (window, // <-- What is needed here?
width,
height,
-1);
I have created a little drawing area class and now need a pixmap to draw into during the expose event callback. But I can't get any parameter that I have tried to compile. Here are the relevant parts of the code...
The class definition...
class set_display_drawing_area : public Gtk::DrawingArea
{
public:
set_display_drawing_area ();
virtual ~set_display_drawing_area ();
protected:
virtual bool on_expose_event(GdkEventExpose* event);
private:
GdkPixmap *pixmap_ptr;
};
and the expose callback...
bool set_display_drawing_area::on_expose_event(GdkEventExpose* event)
{
Glib::RefPtr<Gdk::Window> window = get_window();
if (window)
{
Gtk::Allocation allocation = get_allocation();
const int width = allocation.get_width();
const int height = allocation.get_height();
pixmap_ptr = gdk_pixmap_new (window, // <-- What is needed here?
width,
height,
-1);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您在这里混合了 gtkmm (C++) 和 gtk (C) 风格的代码。
gdk_pixmap_new
是一个 C 函数,它不了解模板和类(例如Glib::RefPtr
)。您可能还想对您的像素图使用 gtkmm:和
You're mixing gtkmm (C++) and gtk (C) style code here.
gdk_pixmap_new
is a C function which has no idea about templates and classes (such asGlib::RefPtr
). You'll probably want to use gtkmm for your pixmap as well:and