我创建了一个小的绘图区域类,现在需要在expose事件回调期间绘制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);
答案 0 :(得分:2)
这里混合使用gtkmm(C ++)和gtk(C)样式代码。 gdk_pixmap_new
是一个C函数,它不知道模板和类(例如Glib::RefPtr
)。您可能也希望将gtkmm用于pixmap:
Glib::RefPtr<Gdk::Pixmap> pixmap;
和
pixmap = Gdk::Pixmap::create(window, width, height);