Widgets OO Enough?



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.)

Does this seem like an issue to anyone else?  I just a beginner with gtk
and not an expert in OOP by any means, but I thought it was worth point
out.  As I said, I have not looked at a lot of the standard widget code,
so forgive me if I am missing something obvious.

Jay

+---------------------------------+------------------------------+
| Jay Bloodworth                  | jay@pathways.sde.state.sc.us |
| Network Technician              | Voice: (803) 734-7000        |
| SC Department of Education      | Fax: (803) 734-4064          |
+---------------------------------+------------------------------+





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