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

Re: Usiing Off-screen drawing with trap calls

On Mon Jul 18, Doug Soo writes:
          I am currently working on trying to use off screen drawing in MCL usin
          offscreen graphics worlds, e.g. NewGWorld and related traps.  I was wo
          if you had any sample code that I could see implementing this.  Any he
lp is
          much appreciated.

Here's an example of a macro (executed within the ccl: package) that saves
and restores a gworld:

(defmacro with-saved-gworld (&rest body)
  ;; Saves the gworld, executes the body of the code and then restores the 
  ;; upon termination (normal or abnormal)
  (let ((saved-port (gensym))
        (saved-device (gensym)))
    `(with-macptrs (,saved-port ,saved-device)       ; from Bill StClair at 
       (ccl::get-gworld ,saved-port ,saved-device)
       (flet ((restore-gworld ()
                (ccl::set-gworld ,saved-port ,saved-device)))
           (progn ,@body
           (restore-gworld)   ; from Bill StClair at Apple

For a complete example that uses an existing gworld (namely the printer,
see the print-u.lisp.hqx code in the contrib directly in the pub/MCL2/contrib
directory available by anonymous ftp from cambridge.apple.com. The code
in menu-enhancements.sit.hqx in the oou-utils.lisp file also contains
an example of saving and restoring a portion of the main screen.