[cairo] pycairo subclass

Behdad Esfahbod behdad at behdad.org
Mon Dec 10 02:01:29 PST 2007


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.

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...

-- 
behdad
http://behdad.org/

...very few phenomena can pull someone out of Deep Hack Mode, with two
noted exceptions: being struck by lightning, or worse, your *computer*
being struck by lightning.  -- Matt Welsh



More information about the cairo mailing list