chiark / gitweb /
Added macro WITH-CARIO-CONTEXT to create temporary cario contexts
authorespen <espen>
Tue, 7 Feb 2006 13:22:14 +0000 (13:22 +0000)
committerespen <espen>
Tue, 7 Feb 2006 13:22:14 +0000 (13:22 +0000)
gdk/gdk.lisp

index 168ec8676c1e9859b5ef42bdec025e631c91d30d..3ea51ac1c444c8df7b2d11371d0e5033dd78e3af 100644 (file)
@@ -20,7 +20,7 @@
 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-;; $Id: gdk.lisp,v 1.18 2005-11-10 09:01:36 espen Exp $
+;; $Id: gdk.lisp,v 1.19 2006-02-07 13:22:14 espen Exp $
 
 
 (in-package "GDK")
@@ -712,6 +712,13 @@ (progn
   (defbinding cairo-create () cairo:context
     (drawable drawable))
 
+  (defmacro with-cairo-context ((cr drawable) &body body)
+    `(let ((,cr (cairo-create ,drawable)))
+       (unwind-protect
+          (progn ,@body)
+        (unreference-foreign 'cairo:context (foreign-location ,cr))
+        (invalidate-instance ,cr))))
+
   (defbinding cairo-set-source-color () nil
     (cr cairo:context)
     (color color))