RE: multiple widget inheritance



> I am making a library of data-bound widgets, and right now each widget
> is a subclass of a different GTK/GNOME widget class (GtkVBox,
> GnomeDialog, GtkEntry...). But I would like to have a base class for all
> of these widgets for common properties and signals. Is there any way of
> having all widget classes subclassing this base class, and then each of
> them subclassing another GTK/GNOME class without losing the
> object-oriented design? I guess there isn't, but I ask just in case
> somebody has found a good way of doing it.


You are thinking of something like this?

struct baseclass_one {
	void * foo;
};
struct baseclass_sec {
	void * bar;
};
struct derieved {
	struct baseclass_one head;
	struct baseclass_sec member;
};

If you have made "struct baseclass_sec" independent, then this should solve
your problem.
You will run into problems if you wan't to cast from a "baseclass_sec"
pointer, to a "derieved" pointer, so try not to be dependent of that.

One way around this problem would be that any communication from the "second
base" to the "derieved" class should be done with gtk's signal handlers.
( Or you can do some pointer-magic :)

// Liss



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