;; 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.21 2006-02-09 22:31:28 espen Exp $
(in-package "GDK")
;;; Cursor
-(defmethod initialize-instance ((cursor cursor) &key type mask fg bg
- (x 0) (y 0) (display (display-get-default)))
- (setf
- (slot-value cursor 'location)
- (etypecase type
- (keyword (%cursor-new-for-display display type))
- (pixbuf (%cursor-new-from-pixbuf display type x y))
- (pixmap (%cursor-new-from-pixmap type mask fg bg x y)))))
+(defmethod allocate-foreign ((cursor cursor) &key type mask fg bg
+ (x 0) (y 0) (display (display-get-default)))
+ (etypecase type
+ (keyword (%cursor-new-for-display display type))
+ (pixbuf (%cursor-new-from-pixbuf display type x y))
+ (pixmap (%cursor-new-from-pixmap type mask fg bg x y))))
(defbinding %cursor-new-for-display () pointer
(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))