Re: [gnomemm] Creating a custom Gnome::Canvas::Item



Murray Cumming wrote:
On Wed, 2002-07-17 at 01:59, Michael Babcock wrote:

Does anybody have an example that creates a new Canvas::Item class by derivation in C++?

There is no default constructor,


A default constructor would probably just call g_object_new() without
property values, but I'm not sure whether that would create anything
useful. You could try to simulate it by calling the base cast
constructor, like so:

Thing::Thing(Group& parentx, int something)
: Gnome::Canvas;:Item(GNOME_CANVAS_ITEM(g_object_new(get_type(), 0)))
{
  item_construct(parentx);
}

That's just some code that I copied from line.ccg and modified.

If that is useful then we could add a real default constructor to make
it easier.

Hmmm. I'm not familiar with the internals of how gtkmm wraps gtk (or I try not to be), so tokens like GNOME_CANVAS_ITEM, g_object_new, and get_type don't mean much to me ;)

I looked at line.{h,cc}g but it is also wrapping an existing C type. In the above what does get_type() return, the C equivalent of a Canvas::Item type or of a Canvas::Line type? Do I have to create a new C type?

I was hoping to be able to derive a new C++ Canvas::Item type and have the library handle the conversion issues between the C++ and the Glib object systems, like gtkmm does so that we can derive a new Gtk::Widget.

I guess I have to use the property system in order to get the canvas to properly update my new item when I change it, right? Am I suppose to use the ConstructParams constructor for this? How do I do it?

Thanks again.

--
Michael Babcock
Jim Henson's Creature Shop





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