Re: [gtk-list] Widgets OO Enough?




Jay Bloodworth <jay@pathways.sde.state.sc.us> writes:

> I tinkering with gtk for a project that will most likely require that I
> write a couple of new widgets.  There is an existing widget that does 90%
> of what I need, so I would like to be able to derive my widget from it.
> Most of what I need to change is in the gtk_*_draw function;  ideally I'd
> be able to simply add a couple of data items to the widget structure and
> replace this one function.  However, the draw function is called by hand
> from many of the other display functions (update, realize, etc.) and thus
> I will actually have to duplicate a lot of that code and do a serach and
> replace to use the new draw function.  It seems to me that since a pointer
> to the draw function is stored in the widget->class structure, it would be
> good to use that pointer to call the function; that way a derived widget
> need only change the pointer in the structure to point at it's version of
> the function to get the correct behavior.  As it stands, we seem to have
> the infrastructure in place to do these kinds of virtual functions but the
> widget code is not using it (Actually, most of these comments refer
> specifically to one specific 'third party' widget, but I think I have seen
> widget code in the main distribution that suffers from the same problem.)

Without knowning exactly what widget you're referring to, it's
a bit hard to say, but in general, gtk_XXX_draw should never be
called if XXX != widget. Not only will gtk_widget_draw call 
the correct derived function, it does some preprocessing as well.

So either the widget you are looking at is broken, or you aren't
actually talking about gtk_*_draw functions. The process of
drawing on the screen (frequently done by _paint functions) isn't
always sufficiently virtualized.

Regards,
                                        Owen



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