Re: Sample simple container.



On 3/30/07, Paul Davis <paul linuxaudiosystems com> wrote:
On Fri, 2007-03-30 at 15:13 -0300, Alexandre Moreira wrote:
> Hello, everyone. I'd like to get a better understanding on how the
> Gtk+ widgets (specially containers) behave.
>
> I tried getting to look at a code for some of the simple containers in
> the lib but they're note that simple. I have to jump back and forward
> between their code and their parent classes and things are not really
> clear to me.

welcome to the world of object oriented programming in a functional
language using macros :)

Hehe, I actually like it. Gives a good idea on what is going on under
the hood... and I can always convert from my UML models to GObject
using Vala.


>
> Does anyone have a simple custom container from scratch already made,
> so I could check on what the methods need to override from GtkWidget
> in order to have a simple Only-One-Child container ?

its called GtkBin

Thanks for your reply.

I know about the Bin, but I guess I didn't made myself clear. I'm
Sorry, I'll try to explain:



I would like to have a way to create composite widgets without
exposing the base Container  methods (Let's say I used a box... it
would have the box's methods and all the GtkContainer methods... and I
wouldn't like client code to call gtk_container_add on a widget that
is not supposed to "mean" a container)

So, I would like to create an as-simple-as-it-gets container that
descended only from GtkWidget  so that it wouldn't really have methods
to act like a container (Its only child widget would be set as a
constructor parameter and overrided by its descendants).

That way I could compose a widget using a table, a box or whatever
layout containers and pack it inside a class, derived from that one I
described above, that would only export the methods needed to the
users (the GtkWidget methods and the specific Widget methods).

Is there a better way to achieve this ? The only thing I could thought
of was this "Basic Dumb Container" but I know it looks really bad. Is
there a way to make a composite widget without exporting all those
nasty GtkContainer and other containers methods ?

Regards,
Alexandre Moreira







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