NextPrevUpTopContentsIndex

tracking-pinboard-layout

Class
Summary

A pinboard with automatic highlighting.

Package

capi

Superclasses

pinboard-layout

Description

The class tracking-pinboard-layout provides a pinboard which tracks mouse movement by highlighting its objects as the mouse cursor moves over them.

This functionality is implemented via a :motion specification in the input-model . Therefore, you may not specify :motion in the input-model of a tracking-pinboard-layout . See output-pane for a description of input-model .

Example
(defclass my-ellipse (capi:drawn-pinboard-object)
  ((color :initarg :color 
          :initform :red 
          :accessor my-ellipse-color)))
 
(defun draw-my-ellipse 
       (output-pane self x y width height)
       (let ((x-radius (floor width 2))
             (y-radius (floor height 2)))
              (gp:draw-ellipse output-pane
                (+ x x-radius) (+ y y-radius)
                x-radius y-radius
                :foreground 
                (my-ellipse-color self)
                :filled t)))
 
(defun change-ellipse-color (pinboard x y)
  (let ((ellipse 
         (capi:pinboard-object-at-position 
          pinboard x y)))
    (when ellipse
      (let ((color 
             (capi:prompt-for-color 
              "New color" 
              :color 
              (my-ellipse-color ellipse) 
              :owner 
              (capi:convert-to-screen))))
        (when color
          (setf (my-ellipse-color ellipse) color)
          (capi:with-geometry ellipse
            (gp:invalidate-rectangle 
             pinboard 
             capi:%x%
             capi:%y%
             capi:%width%
             capi:%height%)))))))
 
(capi:contain 
 (make-instance 
  'capi:tracking-pinboard-layout
  :description 
  (loop for i below 20 
        collect
        (make-instance 'my-ellipse
                       :x (+ 5 (random 290))
                       :y (+ 5 (random 290)) 
                       :height (+ 10 (random 50)) 
                       :width (+ 10 (random 50)) 
                       :color 
                       (apply 'color:make-rgb 
                        (loop for i below 3 
                              collect (random 1.0)))
                       :display-callback 
                       'draw-my-ellipse))
  :input-model '(((:button-1 :press) 
                  change-ellipse-color))))

LispWorks CAPI Reference Manual - 17 Mar 2008

NextPrevUpTopContentsIndex