9.3 Creating graphical objects
drawn-pinboard-object
is provided, which is a pinboard-object that accepts a display-callback to display itself. The following example uses this class to create a new class of pinboard-object that displays an ellipse.(defun draw-ellipse-pane (gp pane x y width height) (with-geometry pane (let ((x-radius (floor %width% 2)) (y-radius (floor %height% 2))) (gp:draw-ellipse gp (+ %x% x-radius) (+ %y% y-radius) x-radius y-radius))))(defclass ellipse-pane (drawn-pinboard-object) () (:default-initargs :display-callback 'draw-ellipse-pane :min-width 50 :min-height 50))
(contain (make-instance 'ellipse-pane))
Figure 9.7 An ellipse-pane class
The Now that you have a new ellipse-pane class, you can create instances of them and place them inside layouts. For instance, the example below creates nine ellipse panes and place them in a three by three grid.
Figure 9.8 Nine ellipse-pane classes in a layout Generated with Harlequin WebMakerwith-geometry
macro is used to set the size and position, or geometry, of the ellipse drawn by thedraw-ellipse-pane
function. See the
(contain
(make-instance
'grid-layout
:description
(loop for i below 9
collect
(make-instance 'ellipse-pane))
:columns 3))
CAPI User Guide, Liquid Common Lisp Version 5.0 - 2 OCT 1997