Re: subclassing textitem
- From: Damon Chaplin <damon karuna eclipse co uk>
- To: control H <control h gmail com>
- Cc: goocanvas-list gnome org
- Subject: Re: subclassing textitem
- Date: Fri, 14 Oct 2011 11:31:44 +0100
On Thu, 2011-10-13 at 22:58 +0200, control H wrote:
> Dear Damon, dear list,
>
> I try to create a new canvas item which is subclassed from
> goocanvastext. This new type implements amongst other things the paint
> and is_item_at methods. What I want to do is that I reuse the methods
> from the parent class. For example in the paint method, I want first
> to use the paint from goocanvastext, and then I use the cr to paint
> some extra things. But how can I access the parents methods? I have
> unsuccessfully tried things like this:
>
> my_text_paint (GooCanvasItemSimple *simple,
> cairo_t *cr,
> const GooCanvasBounds *bounds)
> {
>
> GooCanvasTextClass *text_class = GOO_CANVAS_TEXT_GET_CLASS(text);
> //text_class->goo_canvas_text_paint(simple,cr,bounds); /* does not compile */
> text_class->paint(simple,cr,bounds); /* does not compile either */
> ...
> paint_something_extra(cr);
> }
I think this should work:
GOO_CANVAS_ITEM_SIMPLE_CLASS (my_text_parent_class)->simple_paint
(simple, cr, bounds);
The my_text_parent_class variable is set up automatically by the
G_DEFINE_TYPE macros, and depends on the prefix you used there.
Damon
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]