[cairo-commit]
pycairo/examples/cairo_snippets snippets_png.py, 1.6,
1.7 snippets_pdf.py, 1.2, 1.3 snippets_gtk.py, 1.5, 1.6
Steve Chaplin
commit at pdx.freedesktop.org
Sun May 8 17:52:49 PDT 2005
- Previous message: [cairo-commit] pycairo ChangeLog, 1.104, 1.105 configure.ac, 1.19,
1.20
- Next message: [cairo-commit]
pycairo/cairo pycairo-private.h, 1.19, 1.20 pycairo.h,
1.26, 1.27 cairomodule.c, 1.29, 1.30 cairogtkmodule.c, 1.17,
1.18 pycairo-pattern.c, 1.16, 1.17 pycairo-matrix.c, 1.13,
1.14 pycairo-context.c, 1.45, 1.46 pycairo-surface.c, 1.33,
1.34 pycairo-font.c, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/examples/cairo_snippets
In directory gabe:/tmp/cvs-serv27558/examples/cairo_snippets
Modified Files:
snippets_png.py snippets_pdf.py snippets_gtk.py
Log Message:
SC
Index: snippets_png.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_png.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- snippets_png.py 5 May 2005 01:35:13 -0000 1.6
+++ snippets_png.py 9 May 2005 00:52:46 -0000 1.7
@@ -13,13 +13,12 @@
Verbose_mode = True
-def snippet_do_png (snippet):
+def do_snippet (snippet):
if Verbose_mode:
print 'processing %s' % snippet,
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
- cr = cairo.Context()
- cr.set_target_surface(surface)
+ cr = cairo.Context(surface)
cr.save()
try:
@@ -45,4 +44,4 @@
snippet_list = snip_list
for s in snippet_list:
- snippet_do_png (s)
+ do_snippet (s)
Index: snippets_pdf.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_pdf.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- snippets_pdf.py 28 Apr 2005 22:28:36 -0000 1.2
+++ snippets_pdf.py 9 May 2005 00:52:46 -0000 1.3
@@ -22,8 +22,7 @@
file_obj = file('snippets/%s.pdf' % snippet, 'wb')
surface = cairo.PDFSurface (file_obj, X_inches, Y_inches, X_ppi, Y_ppi)
- cr = cairo.Context()
- cr.set_target_surface(surface)
+ cr = cairo.Context(surface)
cr.save()
try:
Index: snippets_gtk.py
===================================================================
RCS file: /cvs/cairo/pycairo/examples/cairo_snippets/snippets_gtk.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- snippets_gtk.py 15 Apr 2005 18:32:02 -0000 1.5
+++ snippets_gtk.py 9 May 2005 00:52:46 -0000 1.6
@@ -25,11 +25,9 @@
gtk.Window.__init__ (self, type)
self.set_default_size (Width, Height)
- self.ctx = cairo.Context()
-
self.da = gtk.DrawingArea()
self.da.connect('expose-event', self.da_expose_event)
- self.da.connect('size-allocate', self.da_size_allocate)
+ self.da.set_double_buffered(False)
def put_in_frame (widget):
frame = gtk.Frame (label=None)
@@ -56,60 +54,25 @@
self.da.realize()
self._bg_rgb = gdkcolor_to_rgb (self.da.style.bg[gtk.STATE_NORMAL])
- self._pixmap = None
- self._draw_pixmap = True
- self._pixmap_width = -1
- self._pixmap_height = -1
-
-
- def da_size_allocate (self, da, allocation):
- self._draw_pixmap = True
-
def da_expose_event (self, da, event, data=None):
- if self._draw_pixmap:
- width = da.allocation.width
- height = da.allocation.height
-
- create_pixmap = False
- if width > self._pixmap_width:
- self._pixmap_width = max (int (self._pixmap_width * 1.1),
- width)
- create_pixmap = True
-
- if height > self._pixmap_height:
- self._pixmap_height = max (int (self._pixmap_height * 1.1),
- height)
- create_pixmap = True
-
- if create_pixmap:
- self._pixmap = gtk.gdk.Pixmap (da.window, self._pixmap_width,
- self._pixmap_height)
- surface = cairo.gtk.surface_create_for_pixmap_with_visual(
- self._pixmap, da.window.get_visual())
- self.ctx.set_target_surface (surface)
+ width = da.allocation.width
+ height = da.allocation.height
- self.ctx.save()
+ cr = cairo.gtk.create_cairo_context(da.window)
- cr = self.ctx # used by snippet
- # set window bg
- cr.set_source_rgb (*self._bg_rgb)
- cr.rectangle(0, 0, width, height)
- cr.fill()
- cr.set_source_rgb (0,0,0) # reset black
+ # set window bg
+ cr.set_source_rgb (*self._bg_rgb)
+ cr.rectangle(0, 0, width, height)
+ cr.fill()
+ cr.set_source_rgb (0,0,0) # reset black
- try:
- exec (self.snippet_str, globals(), locals())
- except:
- exc_type, exc_value = sys.exc_info()[:2]
- print exc_type, exc_value
-
- self.ctx.restore()
+ try:
+ exec (self.snippet_str, globals(), locals())
+ except:
+ exc_type, exc_value = sys.exc_info()[:2]
+ print exc_type, exc_value
- da.window.set_back_pixmap (self._pixmap, False)
- da.window.clear() # draws the pixmap onto the window bg
- self._draw_pixmap = False
-
return True
- Previous message: [cairo-commit] pycairo ChangeLog, 1.104, 1.105 configure.ac, 1.19,
1.20
- Next message: [cairo-commit]
pycairo/cairo pycairo-private.h, 1.19, 1.20 pycairo.h,
1.26, 1.27 cairomodule.c, 1.29, 1.30 cairogtkmodule.c, 1.17,
1.18 pycairo-pattern.c, 1.16, 1.17 pycairo-matrix.c, 1.13,
1.14 pycairo-context.c, 1.45, 1.46 pycairo-surface.c, 1.33,
1.34 pycairo-font.c, 1.12, 1.13
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list