home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-10-27 | 2.0 KB | 69 lines | [TEXT/CCL ] |
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;;
- ;;Select-Rectangle.Lisp
- ;;
- ;;Copyright © 1987, Coral Software Corp
- ;;
- ;;
- ;; This file has some examples of making trap calls and using window.
- ;;
- ;; It implements a function for dragging out a gray rectangle.
- ;; Then it shows how to use this function to create a new class of windows.
-
- (eval-when (eval compile)
- (require 'traps)
- (require 'records))
-
- ;;;;;;;;;;;;;;;;;;
- ;;
- ;;select-rectangle
- ;;
- ;; returns multiple values giving the two corner points of the
- ;; selected rectangle.
- ;;
- (defobfun (select-rectangle *window*) ()
- (declare (object-variable wptr))
- (let* ((anchor-point (window-mouse-position))
- (old-mouse (window-mouse-position))
- (new-mouse old-mouse))
- (rlet ((r :rect)
- (old-pen-state :penstate))
- (with-port wptr
- (_GetPenState :ptr old-pen-state)
- (_PenMode :word (position :patxor *pen-modes*))
- (rset wptr window.pnPat *gray-pattern*)
- (_FrameRect :ptr r)
- (loop
- (unless (mouse-down-p) (return)) ;return when the mouse lets up
- (unless (eq old-mouse new-mouse)
- (_FrameRect :ptr r)
- (_pt2rect :long anchor-point
- :long new-mouse
- :ptr r)
- (_FrameRect :ptr r)
- (sleep 1/60)
- (setq old-mouse new-mouse))
- (setq new-mouse (window-mouse-position)))
- (_FrameRect :ptr r)
- (_SetPenState :ptr old-pen-state)
- (values (rref r rect.topleft)
- (rref r rect.bottomright))))))
-
-
- ;;;;;;;;;;;;;;;;;;;;
- ;;
- ;; *rect-window*
- ;;
- ;; a class of windows that lets you draw rectangle pictures
-
- (defobject *mondrian-window* *window*)
-
- (defobfun (window-click-event-handler *mondrian-window*) (where)
- (declare (ignore where))
- (multiple-value-bind (topleft bottomright) (select-rectangle)
- (rlet ((my-rect :rect))
- (rset my-rect rect.topleft topleft)
- (rset my-rect rect.bottomright bottomright)
- (_InverRect :ptr my-rect))))
-
- (oneof *mondrian-window*)