tags:

views:

8

answers:

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);
+2  A: 

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);
Matti Virkkunen
Thank you. That's done the trick.
Brian Hooper