[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: window-deactivate??



Omn Friday 28 Jan, Paul Meurer writes:
  I have to perform some action on a (dialog) window when it is *getting*
  deactivated, for example when I activate another window. Is there a method
  similar to window-select which lets me do that? I didn't find anything in
  the manual.
There are two handlers that are invoked when a view is activated or deactivated.
Each of the actions (activate/deactivate) is an event.

For example, consider a scroll-bar-dialog-item.
When the view is deactivated (i.e. the window ceases to be the front-window)
the handler erases the thumb, arrow, and scroll regions. Similarly, when
the view becomes active, another hndler redraws the arrow, thumb, and bar.

The view-activate-event-handler is called when the view is activated.
Similarly, the view-deactivate event-handler is called when the view is
deactivated.

The end of this message contains the active/deactivate event handlers for
a scroll-bar-dialog-item. The source code is in the library folder in the
file scroll-bar-dialog-items.lisp. Since a window is a subclass of view,
you can specify handlers for your particular class of window.

mark


---> start of code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;view-deactivate-event-handler
;;
;;this function is called whenever the scrollbar needs to be deactivated
;;

(defmethod view-deactivate-event-handler ((item scroll-bar-dialog-item))
  (let ((handle (dialog-item-handle item))
        (container (view-container item)))
    (when handle
      (with-focused-view container
        (unless (window-active-p (view-window item))
          (multiple-value-bind (tl br) (scroll-bar-and-splitter-corners item)
            (rlet ((rect :rect
                         :topLeft (add-points tl #@(1 1))
                         :botRight (subtract-points br #@(1 1))))
              (with-clip-rect rect
                ; #_HideControl invals outside of the clip rect.  Naughty, 
naughty.
                (let* ((wptr (href handle :controlRecord.ContrlOwner))
                       (update-rgn (pref wptr :windowRecord.updateRgn))
                       (temp-rgn *temp-rgn*))
                  (declare (dynamic-extent wptr update-rgn)
                           (type macptr wptr update-rgn))
                  (#_CopyRgn update-rgn temp-rgn)
                  (#_HideControl handle)
                  (#_CopyRgn temp-rgn update-rgn))
                (#_EraseRect rect)
                (validate-corners container tl br))))))
      (#_hilitecontrol handle 255))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;view-activate-event-handler
;;
;;this function is called whenever the scrollbar needs to be activated
;;

(defmethod view-activate-event-handler ((item scroll-bar-dialog-item))
  (when (let ((w (view-window item)))
          (and w (window-active-p w)))
    (let ((handle (dialog-item-handle item))
          (container (view-container item)))
      (with-focused-view container
        (when (dialog-item-enabled-p item)
          (#_hilitecontrol handle 0))
        (unless (neq 0 (rref handle :controlRecord.ContrlVis))
          ; #_ShowControl is similarly naughty
          (let* ((wptr (href handle :controlRecord.ContrlOwner))
                 (update-rgn (pref wptr :windowRecord.updateRgn))
                 (temp-rgn *temp-rgn*))
            (declare (dynamic-extent wptr update-rgn)
                     (type macptr wptr update-rgn))
            (#_CopyRgn update-rgn temp-rgn)
            (#_ShowControl handle)
            (#_CopyRgn temp-rgn update-rgn))
          (let ((splitter (pane-splitter item)))
            (when splitter (view-draw-contents splitter)))
          (multiple-value-bind (tl br) (scroll-bar-and-splitter-corners item)
            (validate-corners container tl br)))))))