[cairo] pycairo subclass
Steven Chaplin
stevech1097 at yahoo.com.au
Mon Dec 10 07:48:11 PST 2007
On Mon, 2007-12-10 at 05:01 -0500, Behdad Esfahbod wrote:
> On Sun, 2007-12-09 at 20:25 -0500, Steven Chaplin wrote:
> >
> > The cairo bindings doc 'Memory Management' page describes why its not a
> > good idea to subclass cairo surfaces. So should cairo.Context be kept
> > consistent with cairo surfaces, and not allow subclassing, or is
> > cairo.Context a special case which should allow subclassing?
> > How useful would subclassing cairo.Context be?
>
> As you said both pango and gdk subclass cairo.Context, for good. So
> that one should stay like that.
>
> One reason that subclassing cairo.Surface doesn't make sense, other than
> the issues pointed out in the Memory Management page, is that you can't
> override its methods. That's a real limitation. For example,
> subclassing the show_page() method can be quite useful.
I'm not sure I understand. Do you mean that because cairo itself is not
object-oriented there is little point subclassing a surface because you
won't be able to override cairo's show_page() function?
> For cairo.Context this is less of an issue because no other cairo object
> takes a cairo_t and work on it, but it's not true about the other cairo
> types. It still is a problem with for example pango. That is, I can't
> subclass a pango.CairoContext and override its stroke() method and have
> pango underlines use my brand new stroke implementation...
I've thought about it a bit more. Since pango and gdk subclass
cairo.Context I think we should allow subclassing from Python too to be
consistent. It took ages to find out how to get it working, but all the
required code was already there, I just had to change one 'NULL' to
'type'! I've updated pycairo in CVS, so the next version of pycairo
should allow subclassing cairo.Context from Python.
regards,
Steve
More information about the cairo
mailing list