11.01.2015 Views

CLIM 2 User Guide

CLIM 2 User Guide

CLIM 2 User Guide

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

pixmap-depth<br />

Arguments: pixmap<br />

■ Returns the depth of the pixmap pixmap.<br />

with-output-to-pixmap<br />

[Generic function]<br />

[Macro]<br />

Arguments:<br />

(medium-var medium &key width height) &body body<br />

■ Binds medium-var to a pixmap medium, that is, a medium that does output to a pixmap with<br />

the characteristics appropriate to the medium medium, and then evaluates body in that context. All<br />

the output done to the medium designated by medium-var inside of body is drawn on the pixmap<br />

stream. <strong>CLIM</strong> implementations are permitted, but not required, to have pixmap mediums support the<br />

stream output protocol (write-char and write-string).<br />

medium-var must be a symbol; it is not evaluated.<br />

■ width and height are integers that give the width and height of the pixmap. If they are unsupplied,<br />

the with-output-to-output-record is called to determine the size and then the output<br />

record is replayed on the pixmap stream. As a consequence, operations such as window-clear<br />

will operate on the wrong stream. Specify width and height if this is a problem.<br />

■ The returned value is a pixmap that can be drawn onto medium using copy-from-pixmap.<br />

3.5.1 Example of Using <strong>CLIM</strong> Pixmaps<br />

If you run the following code, it will wait for you to input a rectangular region, then it will copy the region<br />

into a pixmap. It will then wait for you to indicate another spot on the window stream, and will copy the<br />

pixmap out into the new place.<br />

(defun test-copy-area (&optional (function boole-1) (stream *standard-output*))<br />

(let ((medium (clim:sheet-medium stream)))<br />

(multiple-value-bind (left top right bottom)<br />

(clim:pointer-input-rectangle* :stream stream)<br />

(let ((pixmap (clim:copy-to-pixmap<br />

medium left top (- right left) (- bottom top))))<br />

(multiple-value-bind (x y)<br />

(block get-position<br />

(clim:tracking-pointer (stream)<br />

(:pointer-button-press (x y)<br />

(return-from get-position (values x y)))))<br />

(clim:copy-from-pixmap pixmap 0 0 (- right left) (- bottom top)<br />

medium x y function))))))<br />

The next example creates a pixmap using with-output-to-pixmap, and then displays the result at<br />

the place you click on.<br />

(defun test-pixmaps (&optional (stream *standard-output*))<br />

(let ((medium (clim:sheet-medium stream)))<br />

(let ((pixmap (clim:with-output-to-pixmap (mv medium)<br />

(clim:formatting-table (mv)<br />

(dotimes (i 5)<br />

(clim:formatting-row (mv)<br />

(clim:formatting-cell (mv) (princ i mv))<br />

(clim:formatting-cell (mv) (princ (* i 2) mv)))))<br />

(clim:draw-circle* mv 50 50 20 :filled t)<br />

42 <strong>CLIM</strong> 2.2 <strong>User</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!