home *** CD-ROM | disk | FTP | other *** search
- (in-package :oou)
- (oou-provide :button-dim)
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; button-dim.Lisp
- ;;
- ;; Copyright ⌐ 1991 Northwestern University Institute for the Learning Sciences
- ;; All Rights Reserved
- ;;
- ;; author: Michael S. Engber
- ;;
- ;; Dialog item mixin for button behavior.
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (oou-dependencies
- :simple-view-ce)
-
- (export '(button-dim button-hilite))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (defclass button-dim () ())
-
- (defmethod view-click-event-handler ((di button-dim) where)
- (when (with-focused-view (view-container di) (button-track di where))
- (call-next-method)))
-
- (defmethod button-hilite ((di button-dim) hilite-flag)
- (hilite-view di hilite-flag))
-
- (defmethod point-in-button-p ((di button-dim) where)
- (point-in-click-region-p di where))
-
- (defmethod button-track ((di button-dim) initial-mouse-position)
- ;;returns t or nil indicating if the mouse was realeased in the button
- (let ((inverted (point-in-button-p di initial-mouse-position)))
- (when inverted (button-hilite di t))
- (loop
- (unless (#_WaitMouseUp)
- (when inverted (button-hilite di nil))
- (return inverted))
- (if (point-in-button-p di (view-mouse-position (view-container di)))
- (unless inverted (button-hilite di t) (setf inverted t))
- (when inverted (button-hilite di nil) (setf inverted nil))))))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
- ;alternate handler to allow event processing during button tracking
- (defmethod view-click-event-handler ((di button-dim) where)
- (eval-enqueue
- `(when (with-focused-view (view-container ,di) (button-track ,di ,where))
- (dialog-item-action ,di))))
- |#
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- #|
-
- ;;; a modest example - adding button behavior to static text dialog items
-
- (defclass sttxt-but (button-dim static-text-dialog-item) ())
-
- (setf *test-w*
- (make-instance 'dialog
- :window-type :document
- :view-position :centered
- :view-size #@(200 100)
- :window-title "rect-button-dim demo"
- :close-box-p t
- :color-p t
- :view-subviews
- (list (make-dialog-item 'sttxt-but
- #@(20 20)
- #@(160 18)
- "I'm static text + a mixin"
- #'(lambda (item) (declare (ignore item)) (ed-beep))
- ))))
-
- |#