[cairo] Can't draw more

Gerdus van Zyl gerdusvanzyl at gmail.com
Mon Nov 26 03:02:01 PST 2007


Maybe I am misunderstanding you but why don't you just:

1. Create an image cairo surface
----
surfb = cairo.ImageSurface(cairo.FORMAT_ARGB32, self.width,self.height)
or
surfb = self.bkgrndSurface = cairo.ImageSurface.create_from_png(...
or
ts = ctx.get_target()
surfb = ts.create_similar(cairo.CONTENT_COLOR_ALPHA,self.width,self.height)
---
ctxb = cairo.Context(surfb)
self.context = ctxb
2. On mouse move draw the current position to the image surface
3. On Expose event just blit/draw the imagesurface to window using the
gtk context?

~Gerdus


On Nov 25, 2007 10:10 PM, Gary Jaffe <gfj555 at gmail.com> wrote:
>
>
> Kalle Vahlman wrote:
> [snip...]
> >
> > ...but it sounds like it is. What happens here is that you create a
> > context in the configure event for the *real* window, and then
> > anything you draw on it is wiped out by GTK+ in preparation for the
> > expose handler. In general, you should never store the context for a
> > GTK+ window outside the expose handler (since it likely will not be
> > for the surface you actually want to draw on) but instead always
> > create it inside it.
> >
>
> I'm beginning to understand that (finally).  So I have to do everything
> in my expose_event method.
>
> Since I want to allow the user to draw on the background that I already
> displayed, I guess I'll have to keep track of every little bit of the
> user's drawing as he is drawing it and call my expose_event with each
> bit that comes back to me with the motion_notify_event hint I get back.
>   Then the expose_event will draw the background and each of the bits
> that have been collected up to that point.
>
> Is that a good strategy, or am I barking up the wrong tree with cairo?
>
> Gary
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>


More information about the cairo mailing list