From: Ciske Busch

Subject: Solution to window-movement (WEIRD!!)

Date: 1999-3-1 16:26

Hi,

don't ask me how but I found a solution to my earlier question regarding the
control of the movement of a window. Since I am not sure if it is based on a
bug and because it really is weird I am posting the code to the mailing
list.

The solution works like this: when the caption-section of the
("master"-)window's frame is clicked a new ("slave"-)pane with a zero-sized
exterior is opened. a call to "mouse-left-down" for the slave turns
mouse-control over to it and it's "move-window" method is used to modify the
exterior of the master.  After releasing the mouse-button conrol is given
back to the "nc-mouse-left-down" method of the master and the slave can be
closed.


;;; ---- begin
code -------------------------------------------------------------

(defclass master-window (non-refreshing-window)
    ())

(defclass slave-pane (non-refreshing-pane)
    ((master :initarg :master :initform nil :accessor master)
     ))

(defmethod move-window ((self slave-pane) position)
   (setf (exterior-top-left (master self))
         (nmake-position #.(make-position 0 0)
           (left (master self))
           (position-y position))
   ))

(defmethod nc-mouse-left-down ((self master-window) bs data
                               (frame-section (eql :caption)))
   (let* ((akt-pos (screen-to-window-units (parent self) data))
          ;;; make a 'zero-exterior slave at the cursor position
          (slave (make-window 'slave
                   :device 'slave-pane
                   :exterior  (nmake-box #.(make-box 0 0 0 0)
                                (position-x akt-pos) (top self)
                                (position-x akt-pos) (top self)
                                )
                   :parent (parent self)
                   :master self
                  ))
          )
      ;;; selection back on - menu-line is blue agein...
      (select-window self)
      ;;; give mouse-control to the save...
      (mouse-left-down slave bs data)
      ;;; after the mouse is released close the slave...
      (close slave)
      )
   )

;;; ------------------------------------------------------------------------
---------
(let ((container
       (make-window :container
         :device 'non-refreshing-window
         :exterior (make-box 100 100 500 700))))
   (make-window :move-it-up-and-down
     :device 'master-window
     :parent (front-window container)
     :exterior (make-box 50 50 350 200))
   )

;;; ---- end code
--------------------------------------------------------------------


The really weird thing is that the slave is *moveable*. if you change it's
box and for example fill it you can see how it is dragged around the parent
window.

As usual comments to this would be appreciated :-)


c.busch


-------------------------------------------------------------------
"Real stupidity beats artificial intelligence every time."
                                               M.Ridcully

Ciske Busch
Lehrstuhl fuer Kuenstliche Intelligenz und Angewandte Informatik
Universitaet Wuerzburg, Germany
http://ki-server.informatik.uni-wuerzburg.de/~ciske/
ICQ: #23765977

Vote against SPAM: http://www.politik-digital.de/spam/
-------------------------------------------------------------------