On Wed, Aug 10, 2005 at 13:56:18 -0400, James Muir wrote:
Hi All, I'm trying to subclass Gnome2::Canvas::Shape to get a rounded rectangle. No success yet. I need to set the Bpath for the shape. As far as I can tell the pathdef can not be set up in INIT_INSTANCE as this is too soon and the properties have not been passed in. I'm not sure if it's OK to
So set it up in SET_PROPERTY. Whenever some of the properties affecting the shape is set, look whether all the others are defined, and if they are, set the shape. SET_PROPERY /is/ called for default values if not explicitly specified, so you can be sure all the properties will be set before the object is shown.
instantiate a pathdef inside my RoundedRect or not, and I'm not sure how to call set_path_def. I've seen in the Mup::ColorButton example that an event is used to set the button color for the first time. I tried something similar but without success.
The problem is, that Gnome2::Canvas::Shape is NOT a Gtk2::Widget, so it does not have realize nor map signals. The SET_PROPERTY approach should be better and has the added benefit that the shape is reset when the properties are changed later. I think the code you have shown is mostly ok. Just place the shape generation in SET_PROPERTY. You can also look in the code for GnomeCanvasRect and GnomeCanvasRE (if you know C) how they do it. In fact, you may even be able to derive from GnomeCanvasRE, depending on how it is implemented. ------------------------------------------------------------------------------- Jan 'Bulb' Hudec <bulb ucw cz>
Attachment:
signature.asc
Description: Digital signature