Next Prev Up Top Contents Index
E.6 Hardcopy Streams in CLIM

CLIM supports hardcopy output through the macro with-output-to-postscript-stream .

with-output-to-postscript-stream[Macro]	

Arguments: (stream-var file-stream &key (:display-device clim::*postscript-device* ) :header-comments :multi-page) &body body

Summary: Within body, stream-var is bound to a stream that produces PostScript code.

The following example writes a PostScript program that draws a square, a circle, and a triangle to a file named icons-of-high-tech.ps .

(defun print-icons-of-high-tech-to-file ()
  (with-open-file
      (file-stream "icons-of-high-tech.ps" :direction :output)
    (clim:with-output-to-postscript-stream
     (stream file-stream)
     (let* ((x1 150) (y 250) (size 100)
            (x2 (+ x1 size))
            (radius (/ size 2))
            (base-y (+ y (/ (* size (sqrt 3)) 2))))
      (clim:draw-rectangle* stream
                            (- x1 size) (- y size)
                            x1 y)
      (clim:draw-circle* stream
                         (+ x2 radius) (- y radius)
                         radius)
      (clim:draw-triangle* stream
                           (+ x1 radius) y
                           x1 base-y
                           x2 base-y)))))

The second example uses multi-page mode to draw a graph of the superclasses of the class window-stream by writing a PostScript program to the file some-pathname .

(with-open-file (file some-pathname :direction :output)
  (clim:with-output-to-postscript-stream
   (stream file :multi-page t)  
   (clim:format-graph-from-root
    (clos:find-class 'clim-internals::window-stream)
    #'(lambda (object s)
       (write-string (string (clos:class-name object)) s))
    #'clos:class-direct-superclasses
    :stream stream)))

Note that with-output-to-postscript-stream is defined in the loadable module "clim-postscript". See 1.5, Loading CLIM for details of how to load CLIM and associated modules.


CommonLisp Interface Manager 2.0 User's Guide - 8 Aug 2003

Next Prev Up Top Contents Index