tags:

views:

33

answers:

1

I have a dialogue which contains a drawing area. I wish to redraw the contents of the drawing area if the dialogue is enlarged or shrunk or buried and exposed, as is normal and natural with drawing areas. To this end, I created a method

bool on_expose_event (GdkEventExpose *event);

in the class. But the presence of this event stops all the other widgets on the dialogue from being drawn correctly; presumably it is also being invoked when they are exposed. How do I create a function to refresh the drawing area only, and leave all the other widgets to take care of themselves?

A: 

You should really sub-class the Gtk::DrawingArea class and implement the on_expose_event() function from that class.

jonner
I was hoping to avoid having two classes as the coupling between them will be undesirably large. But if that's what I've got to have, then that's what I've got to have.
Brian Hooper
well, you don't *have* to subclass the drawing area, it's just usually the cleaner solution. If you really want to do it without subclassing, just implement a function that's not the same name as a virtual function of the dialog (call it e.g. expose_drawing_area() instead of on_expose_event()) and then connect it to drawingarea.signal_expose_event()
jonner
Thank you, jonner; I'll certainly give that a try.
Brian Hooper