Re: Choosing a parent class



On Tue, Apr 11, 2006 at 07:35:41PM +0200, Andreas Kotowicz wrote:
I created a composite widget which consists of two frames, one of which
holds a calendar and a second one which has some buttons. I now ask
myself what is the right parent class to choose from. Is it GtkFrame?
Why can't I just choose GtkWidget? are there any rules which classes to
choose from for composite widgets? (I know, the tutorial says you should
use the class which is most similar but that's now very precise).

Inherit from the class the widget actually *is*.  If you
inherit from GtkFoo, your widget will inherit the properties
and methods (this is what inheritance is about) --
gtk_foo_blow_up() can be expected to work with your new
widget too.  Well, life is not that simple, so in practice
not everything inherited makes always sense, but you get the
idea.

If it is a composite, then it *is* a GtkHBox, a GtkVBox,
a GtkTable, ... whatever, and all ther rest is just
contained in (members).  If it is a new type of container
(does not seem likely), inherit from GtkContainer.  If it is
something that just ties a group of separate widgets
together (think GtkSizeGroup), do not inherit from any
widget, but from GtkObject and make the widgets members.

Yeti


--
That's enough.



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