[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

some help for CopyBitzers



In response to the recent flurry of CopyBits q's, here's a couple
defn's which should clean your code up a bit:

(defmacro with-wptr-XMapPtr ((wptr PixMap-or-BitMap-Ptr) &body body)
    (let ((fn (gensym)))
      `(flet ((,fn (,PixMap-or-BitMap-Ptr) ,@body))
         (declare (dynamic-extent #',fn))
         (call-with-wptr-XMapPtr #',fn ,wptr ))))

(defun call-with-wptr-XMapPtr (fn wptr)
    (if (wptr-color-p wptr)
      (ccl::with-macptrs ((pixMap_h (pref wptr :CGrafPort.portPixMap)))
        (with-dereferenced-handles ((pixMap_p pixMap_h))
          (funcall fn pixMap_p)))
      (ccl::with-macptrs ((bitMap_p (pref wptr :GrafPort.portBits)))
        (funcall fn bitMap_p))))

The with- macro executes body with the symbol you pass in for
PixMap-or-BitMap-Ptr bound to either a BitMapPtr or a PixMapPtr This is
what CopyBits & related calls want. These macros should handle all
your worries about whether you're in a color window or not.

-ME