Re: Gnome2::Canvas



* john knops <jknops goulburn net au>:

1. Why  is it called Gnome2::Canvas. Isn't Gnome built with Gtk so wouldn't 
Gtk2::Canvas be a better name?

Because the library name is libgnomecanvas. Sounds strange, now, but the
Canvas widget started as a project for GNOME; later, it became
GNOME-agnostic, but retained the name. So, it falls under the Gnome2::*
namespace.

2. Where does it fit in the Gtk hierarchy tree?

Near the start of the hierarchy root: it's parent class is GtkObject.

3. When creating a canvas item why the call to $root?
eg. my $root =$canvas->root;
my $item = Gnome2::Canvas::Item->new ($root,
                                    'Gnome2::Canvas::Ellipse');
Am I correct in thinking that no other widget makes this sort of call so why 
does this one need it?

Because a Gnome2::Canvas is a collection of items (of type
Gnome2::Canvas::Group). So, just like a container with its children,
you need to specify which root object you are inserting the item into
(in your examples, the root Gnome2::Canvas::Group inside a
Gnome2::Canvas object).  You may have multiple Groups, with multiple
Items in them, inside one Canvas.

As it has been written inside the gnome-canvas.h file:

/* GnomeCanvasGroup - a group of canvas items
 *
 * A group is a node in the hierarchical tree of groups/items inside a canvas.
 * Groups serve to give a logical structure to the items.
 *
 * Consider a circuit editor application that uses the canvas for its schematic
 * display.  Hierarchically, there would be canvas groups that contain all the
 * components needed for an "adder", for example -- this includes some logic
 * gates as well as wires.  You can move stuff around in a convenient way by
 * doing a gnome_canvas_item_move() of the hierarchical groups -- to move an
 * adder, simply move the group that represents the adder.
[...]
 */

Regards,
 Emmanuele.

-- 
Emmanuele Bassi (Zefram)                 [ http://www.emmanuelebassi.net ]
GnuPG Key fingerprint = 4DD0 C90D 4070 F071 5738  08BD 8ECC DB8F A432 0FF4



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