(in-package "CLIM-USER")

(defparameter *ink* +red+)

(define-application-frame test ()
  ()
  (:pane :application))
 
(define-test-command (rubberband :menu t) ()
  (let ((x1 0)
        (y1 0)
        (x2 0)
        (y2 0)
        (mouse-button-press nil) ;; set to T when mouse button has
        ;; press to select pivot
        (stream (frame-standard-output *application-frame*)))
    (tracking-pointer
     (stream)
     (:pointer-button-press
      (&key event x y)
      (setf x1 x
            y1 y
            x2 x
            y2 y)
      (setf mouse-button-press t))
     (:pointer-motion
      (&key window x y)
      (when mouse-button-press
	(updating-output (stream :unique-id :rubberband)
          (draw-rectangle* stream x1 y1 x y :ink *ink* :filled nil))))
     (:pointer-button-release
      (&key event x y)
      (when mouse-button-press
	;(clouseau:inspect event)
	(return-from rubberband (list x1 y1 x2 y2)))))))

;;(define-test-command (com-exit :menu "EXEUNT" :keystroke #-)
(define-test-command (com-exit :menu "EXEUNT" :keystroke #\-)
    ()
  (frame-exit *application-frame*))

(let ((frame (make-application-frame 'test)))
  (run-frame-top-level frame))
