QVector translations
src/painter.lisp
Sat Jan 23 20:48:00 CET 2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
* QVector translations
--- old-qt.gui/src/painter.lisp 2014-10-30 07:41:19.000000000 +0100
+++ new-qt.gui/src/painter.lisp 2014-10-30 07:41:19.000000000 +0100
@@ -1,16 +1,22 @@
(in-package :cl-smoke.qt.gui)
-(defmacro qt:with-painter ((painter paint-device) &body body)
+(defmacro qt:with-painter ((painter &optional paint-device) &body body)
"Binds a PAINTER instance for PAINT-DEVICE to PAINTER
- during the evaluation of BODY.
+ during the evaluation of BODY. Or when PAINT-DEVICE is not
+specified, saves and restored the state of PAINTER around BODY.
Makes sure the painter ends after BODY; thus preventing problems with
still active and not yet garbage collected painters in CXX:PAINT-EVENT."
- `(let ((,painter (make-instance 'qt:painter :arg0 ,paint-device)))
- (assert (cxx:is-active ,painter)
- (,painter)
- "Painter ~A for ~A is not active"
- ,painter ,paint-device)
- (unwind-protect
- (progn ,@body)
- (cxx:end ,painter))))
+ (when paint-device
+ `(let ((,painter (make-instance 'qt:painter :arg0 ,paint-device)))
+ (assert (cxx:is-active ,painter)
+ (,painter)
+ "Painter ~A for ~A is not active"
+ ,painter ,paint-device)
+ (unwind-protect
+ (progn ,@body)
+ (cxx:end ,painter)))
+ `(progn (cxx:save ,painter)
+ (unwind-protect
+ (progn ,@body)
+ (cxx:restore ,painter)))))