Appendix F Common Lisp Streams

F.6 Hardcopy Streams in CLIM

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

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

(stream-var file-stream&key (:display-device clim::*postscript-device*) :header-comments :multi-page)&body body
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

(defun print-icons-of-high-tech-to-file ()
      (file-stream "" :direction :output)
     (stream file-stream)
     (let* ((x1 150) (y 250) (size 100)
            (x2 (+ x1 size))
            (radius (/ size2))
            (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)
      (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)
   (stream file :multi-page t)  
    (clos:find-class 'clim::window-stream)
    #'(lambda (object s)
       (write-string (string (clos:class-name object)) s))
    :stream stream)))

CLIM 2.0 User's Guide - OCT 1998

Generated with Harlequin WebMaker