Generic Function | Package: cg | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version

## draw-on-printer

Arguments: object printer-stream &key left top

Prints object on printer-stream at left, top from printer-physical-offset of the printer.

Currently the controls implement methods for this generic function, so that they may be drawn in high resolution at an arbitrary position in printed output. Other windows or widgets could be copied directly from the screen to a printer stream by calling copy-stream-area (or get-pixmap followed by copy-to-stream), but that would simply copy the screen pixels rather than redrawing the object at the typically higher resolution of the printer. If an application implements a custom control (by defining a subclass of lisp-widget and supplying lisp code for drawing it and handling mouse clicks and so on), then a draw-on-printer method could be written for the control.

## Example

The following example will draw the Employee Grid example from the Navigator Dialog on a printer, using the printer's high resolution. First run the Employee Grid example and then evaluate the following form to print it.

    (let* ((dialog (find-window :employee-chart))
           grid)
      (unless dialog
        (error "Run the Employee Grid-Widget example first."))
      (setq grid (find-component :employee-grid dialog))

      ;; Open a printer stream at 100 stream units per inch,
      ;; which approximates the resolution of a computer screen,
      ;; and find the usable drawing area between the margins.
      (with-output-to-printer (out :units-per-inch 100)
        (let* ((left-margin (left-margin out))
               (right-margin (right-margin out))
               (top-margin (top-margin out))
               (bottom-margin (bottom-margin out)))

          ;; Draw a horizontally centered title.
          (with-font (out (make-font-ex nil "Arial" 24))
            (draw-string-in-box
             out "Employee Information" nil nil
             (make-box left-margin top-margin right-margin
                       (+ top-margin 30))
             :center :top))

          ;; Draw the employee grid centered horizontally, and
          ;; a little below the title.
          (draw-on-printer grid out
                           :left (+ left-margin
                                    (floor (- right-margin left-margin
                                              (width grid))
                                           2))
                           :top (+ top-margin 100)))))

Copyright (c) 1998-2019, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 8.2 page.
Created 2012.5.30.

|  | ToC | DocOverview | CGDoc | RelNotes | FAQ | Index | PermutedIndex
| Allegro CL version 9.0 Unrevised from 8.2 to 9.0. 8.2 version