开发者

What is needed in this call to gdk_get_pixmap?

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:
        GdkPix开发者_如何学JAVAmap              *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);


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 as Glib::RefPtr). You'll probably want to use gtkmm for your pixmap as well:

Glib::RefPtr<Gdk::Pixmap> pixmap;

and

pixmap = Gdk::Pixmap::create(window, width, height);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜