/ src /
/src/painter.lisp
1 (in-package :cl-smoke.qt.gui)
2
3 (defmacro qt:with-painter ((painter &optional paint-device) &body body)
4 "Binds a PAINTER instance for PAINT-DEVICE to PAINTER
5 during the evaluation of BODY. Or when PAINT-DEVICE is not
6 specified, saves and restored the state of PAINTER around BODY.
7
8 Makes sure the painter ends after BODY; thus preventing problems with
9 still active and not yet garbage collected painters in CXX:PAINT-EVENT."
10 (if paint-device
11 `(let ((,painter (make-instance 'qt:painter :arg0 ,paint-device)))
12 (assert (cxx:is-active ,painter)
13 (,painter)
14 "Painter ~A for ~A is not active"
15 ,painter ,paint-device)
16 (unwind-protect
17 (progn ,@body)
18 (cxx:end ,painter)))
19 `(progn (cxx:save ,painter)
20 (unwind-protect
21 (progn ,@body)
22 (cxx:restore ,painter)))))