on_expose_event and drawingarea redrawing issues



I have a drawing area consisting of a background image, and I'm using
the function below to redraw the image on resize or any other expose
event. The MainMenu class inherits from
Gtk::Window. The issue I'm having is that the image does not redraw
properly until the window is iconified and deiconified. If the window is
the image will become progressively darker and darker until it is nearly
black. If a menu is drawn on top of the area either the problem above
will happen or the area under will become blank (white). Once the window
gets iconified and deiconified the DrawingArea has a normal appearance.
My background image is compiled directly into a library at runtime
rather than reading in from disk. I believe it was originally a PNG with
alpha transparency. I have noticed that if I use another transparent XPM
and create the pixbuf from a file statically this does not occur - the
redrawing works perfectly.

I am not using the DrawingArea anywhere else in the program except for
the constructor and this function. There are no signals bound to the
DrawingArea or image. I've tried binding the signal like so:
da->signal_expose_event().connect(sigc::mem_fun(*this,&MainMenu::on_expose_event));

and it doesn't appear to change anything.

//da is a Gtk::DrawingArea, image is a Glib::RefPtr<Gdk::Pixbuf>
//MainMenu inherits from Gtk::Window

bool MainMenu::on_expose_event(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Pixbuf> tmpimage =
image->scale_simple(da->get_width(),
            da->get_height(),Gdk::INTERP_BILINEAR);
   tmpimage->render_to_drawable(da->get_window(),
da->get_style()->get_white_gc(),   
        0, 0, 0, 0,
da->get_width(),da->get_height(),Gdk::RGB_DITHER_NONE, 0, 0);
    Gtk::Window::on_expose_event(event);
    return true;
}

I also tried using the full scale() function and got the same result. So
my question is, does the problem lie in my on_expose_event function, or
the compiled image i'm using, or somewhere else? My coworker who
originally created the image library thinks it could be a bug in gtkmm
or possibly the window manager or something more fundamental than my
program.

Thanks,

Will Megee
Software Engineer
Fiscal Systems
will fis-cal com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]