(FILECREATED "12-Jul-84 18:03:19" {ERIS}<LISPUSERS>MOVE-WINDOWS.;8 16054  

      changes to:  (FNS MOVE.WINDOW.GETREGION MOVE.WINDOWS MOVE.WINDOW MOVE.WINDOW.FIXEDPT 
			MOVE.WINDOW.MOVINGPT MOVE.WINDOW.SETCURSORPOSITION SHAPE.WINDOW.GETREGION 
			MAINWINDOW MOVE.WINDOW.COMPLAIN MOVE.WINDOW.NEWREGIONFN MOVE.WINDOW.CHECKPT 
			MOVE.WINDOW.SETCURSOR)
		   (VARS MOVE-WINDOWSCOMS MOVE.WINDOW.JUMP.TO.BORDER MOVE.WINDOW.WRONG 
			 MOVE.WINDOW.EW.CURSOR MOVE.WINDOW.NWSE.CURSOR MOVE.WINDOW.NS.CURSOR 
			 MOVE.WINDOW.NESW.CURSOR MOVE.WINDOW.CURSOR MOVE.WINDOWS.CURSOR)

      previous date: " 2-Jul-84 12:46:33" {ERIS}<LISPUSERS>MOVE-WINDOWS.;2)


(* Copyright (c) 1984 by Xerox Corporation. All rights reserved.)

(PRETTYCOMPRINT MOVE-WINDOWSCOMS)

(RPAQQ MOVE-WINDOWSCOMS ([P (COND ((NOT (BOUNDP (QUOTE BACKGROUNDBUTTONEVENTFN)))
				   (PRINTOUT T T "System too old for this package:" T 3 
					     "BACKGROUNDBUTTONEVENTFN mechanism not present"))
				  (T (SETQ BACKGROUNDBUTTONEVENTFN (QUOTE MOVE.WINDOWS]
			 (FNS MAINWINDOW MOVE.WINDOW MOVE.WINDOW.CHECKPT MOVE.WINDOW.COMPLAIN 
			      MOVE.WINDOW.FIXEDPT MOVE.WINDOW.GETREGION MOVE.WINDOW.MOVINGPT 
			      MOVE.WINDOW.SETCURSORPOSITION MOVE.WINDOWS SHAPE.WINDOW.GETREGION)
			 (UGLYVARS MOVE.WINDOW.EW.CURSOR MOVE.WINDOW.NESW.CURSOR 
				   MOVE.WINDOW.NS.CURSOR MOVE.WINDOW.NWSE.CURSOR MOVE.WINDOWS.CURSOR 
				   MOVE.WINDOW.WRONG)
			 (VARS (MOVE.WINDOW.JUMP.TO.BORDER T))))
[COND ((NOT (BOUNDP (QUOTE BACKGROUNDBUTTONEVENTFN)))
       (PRINTOUT T T "System too old for this package:" T 3 
		 "BACKGROUNDBUTTONEVENTFN mechanism not present"))
      (T (SETQ BACKGROUNDBUTTONEVENTFN (QUOTE MOVE.WINDOWS]
(DEFINEQ

(MAINWINDOW
  [LAMBDA (WINDOW)                                           (* edited: " 2-Jul-84 17:51")
    (PROG (ATTACHED.WINDOW)
          (SETQ ATTACHED.WINDOW (WINDOWPROP WINDOW (QUOTE MAINWINDOW)))
          (RETURN (COND
		    ((NULL ATTACHED.WINDOW)
		      WINDOW)
		    (T (MAINWINDOW ATTACHED.WINDOW])

(MOVE.WINDOW
  [LAMBDA (WINDOW)                                           (* edited: "12-Jul-84 17:37")
    (PROG (REGION DX X1 X2 DY Y1 Y2 DIRECTION NEW.REGION)
          (SETQ REGION (WINDOWREGION WINDOW))
          (SETQ DX (IQUOTIENT (fetch (REGION WIDTH) of REGION)
			      3))
          (SETQ X1 (IPLUS (fetch (REGION LEFT) of REGION)
			  DX))
          (SETQ X2 (IPLUS X1 DX))
          (SETQ DY (IQUOTIENT (fetch (REGION HEIGHT) of REGION)
			      3))
          (SETQ Y1 (IPLUS (fetch (REGION BOTTOM) of REGION)
			  DY))
          (SETQ Y2 (IPLUS Y1 DY))
          [SETQ DIRECTION (COND
	      [(IGREATERP LASTMOUSEX X2)
		(COND
		  ((IGREATERP LASTMOUSEY Y2)
		    (QUOTE NE))
		  ((IGREATERP LASTMOUSEY Y1)
		    (QUOTE E))
		  (T (QUOTE SE]
	      [(IGREATERP LASTMOUSEX X1)
		(COND
		  ((IGREATERP LASTMOUSEY Y2)
		    (QUOTE N))
		  ((IGREATERP LASTMOUSEY Y1)
		    (QUOTE CENTER))
		  (T (QUOTE S]
	      (T (COND
		   ((IGREATERP LASTMOUSEY Y2)
		     (QUOTE NW))
		   ((IGREATERP LASTMOUSEY Y1)
		     (QUOTE W))
		   (T (QUOTE SW]
          [COND
	    [(EQ DIRECTION (QUOTE CENTER))
	      (COND
		((\USERFNISDON'T (WINDOWPROP WINDOW (QUOTE MOVEFN)))
		  (MOVE.WINDOW.COMPLAIN "moved"))
		(T (SETQ NEW.REGION (MOVE.WINDOW.GETREGION (WINDOWPROP WINDOW (QUOTE MINWIDTH))
							   (WINDOWPROP WINDOW (QUOTE MINWIDTH))
							   REGION))
		   (MOVEW WINDOW NEW.REGION]
	    (T (COND
		 ((\USERFNISDON'T (WINDOWPROP WINDOW (QUOTE RESHAPEFN)))
		   (MOVE.WINDOW.COMPLAIN "reshaped"))
		 (T (SETQ NEW.REGION (SHAPE.WINDOW.GETREGION (WINDOWPROP WINDOW (QUOTE MINWIDTH))
							     (WINDOWPROP WINDOW (QUOTE MINWIDTH))
							     REGION DIRECTION))
		    (SHAPEW WINDOW NEW.REGION]
          (RETURN])

(MOVE.WINDOW.CHECKPT
  [LAMBDA (MINWID MINHGHT BASEPT OPPT)                       (* edited: " 2-Jul-84 09:55")

          (* called by MOVE.WINDOW.GETREGION to check the constraints imposed by the minimum sizes. It assumes BASEPT and 
	  OPPT are POSITIONs set to the fixed corner BASEPT and moving corner OPPT.)


    (PROG ((BASEX (fetch (POSITION XCOORD) of BASEPT))
	   (BASEY (fetch (POSITION YCOORD) of BASEPT))
	   (OPPX (fetch (POSITION XCOORD) of OPPT))
	   (OPPY (fetch (POSITION YCOORD) of OPPT))
	   USERPT)                                           (* check for minimum height and width constraints.)
          (AND [COND
		 [(IGREATERP BASEX OPPX)
		   (COND
		     ((ILESSP (IDIFFERENCE BASEX OPPX)
			      MINWID)
		       (SETQ OPPX (IDIFFERENCE BASEX MINWID]
		 ((ILESSP (IDIFFERENCE OPPX BASEX)
			  MINWID)
		   (SETQ OPPX (IPLUS BASEX MINWID]
	       (replace (POSITION XCOORD) of OPPT with OPPX))
          (AND [COND
		 [(IGREATERP BASEY OPPY)
		   (COND
		     ((ILESSP (IDIFFERENCE BASEY OPPY)
			      MINHGHT)
		       (SETQ OPPY (IDIFFERENCE BASEY MINHGHT]
		 ((ILESSP (IDIFFERENCE OPPY BASEY)
			  MINHGHT)
		   (SETQ OPPY (IPLUS BASEY MINHGHT]
	       (replace (POSITION YCOORD) of OPPT with OPPY])

(MOVE.WINDOW.COMPLAIN
  [LAMBDA (OPERATION)                                        (* edited: " 2-Jul-84 16:10")
    (RESETFORM (CURSOR MOVE.WINDOW.WRONG)
	       (CLEARW PROMPTWINDOW)
	       (printout PROMPTWINDOW "This window cannot be " OPERATION)
	       (until (MOUSESTATE UP) do NIL])

(MOVE.WINDOW.FIXEDPT
  [LAMBDA (REGION DIRECTION BASEPT)                          (* edited: "12-Jul-84 16:48")
    (replace (POSITION XCOORD) of BASEPT with (SELECTQ DIRECTION
						       ((N NE E SE)
							 (fetch (REGION LEFT) of REGION))
						       ((S SW W NW)
							 (fetch (REGION RIGHT) of REGION))
						       (SHOULDNT)))
    (replace (POSITION YCOORD) of BASEPT with (SELECTQ DIRECTION
						       ((NW N NE E)
							 (fetch (REGION BOTTOM) of REGION))
						       ((SE S SW W)
							 (fetch (REGION TOP) of REGION))
						       (SHOULDNT])

(MOVE.WINDOW.GETREGION
  [LAMBDA (MINWIDTH MINHEIGHT REGION)                        (* edited: "12-Jul-84 17:58")
                                                             (* accepts region from the user.)
    (RESETFORM (CURSOR BOXCURSOR)
	       (PROG (BASEX BASEY OPPX OPPY OLDMOUSEX OLDMOUSEY NEWMOUSEX NEWMOUSEY DOWNFLG 
			    HALF.WIDTH HALF.HEIGHT)
		     (SETQ HALF.WIDTH (IQUOTIENT (fetch (REGION WIDTH) of REGION)
						 2))
		     (SETQ HALF.HEIGHT (IQUOTIENT (fetch (REGION HEIGHT) of REGION)
						  2))
		     (COND
		       (MOVE.WINDOW.JUMP.TO.BORDER (SETQ NEWMOUSEX (IPLUS (fetch (REGION LEFT)
									     of REGION)
									  HALF.WIDTH))
						   (SETQ NEWMOUSEY (IPLUS (fetch (REGION BOTTOM)
									     of REGION)
									  HALF.HEIGHT)))
		       (T (GETMOUSESTATE)
			  (SETQ NEWMOUSEX LASTMOUSEX)
			  (SETQ NEWMOUSEY LASTMOUSEY)))      (* Now draw the initial box)
		     (SETQ BASEX (IDIFFERENCE NEWMOUSEX HALF.WIDTH))
		     (SETQ BASEY (IDIFFERENCE NEWMOUSEY HALF.HEIGHT))
		     (SETQ OPPX (IPLUS NEWMOUSEX HALF.WIDTH))
		     (SETQ OPPY (IPLUS NEWMOUSEY HALF.HEIGHT))
		     (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
		     (\SETCURSORPOSITION NEWMOUSEX NEWMOUSEY)
		     (COND
		       [[ERSETQ (until (PROGN (GETMOUSESTATE)
					      (LASTMOUSESTATE UP))
				   do (COND
					((OR (NEQ LASTMOUSEX OLDMOUSEX)
					     (NEQ LASTMOUSEY OLDMOUSEY))
                                                             (* the cursor has moved, check user constraints.)
					  (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
					  (SETQ OLDMOUSEX LASTMOUSEX)
					  (SETQ OLDMOUSEY LASTMOUSEY)
					  (SETQ BASEX (IDIFFERENCE LASTMOUSEX HALF.WIDTH))
					  (SETQ BASEY (IDIFFERENCE LASTMOUSEY HALF.HEIGHT))
					  (SETQ OPPX (IPLUS LASTMOUSEX HALF.WIDTH))
					  (SETQ OPPY (IPLUS LASTMOUSEY HALF.HEIGHT))
					  (DRAWGRAYBOX BASEX BASEY OPPX OPPY]
                                                             (* erase box image.)
			 (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
			 (RETURN (create REGION
					 LEFT ← BASEX
					 BOTTOM ← BASEY
					 WIDTH ←(IDIFFERENCE OPPX BASEX)
					 HEIGHT ←(IDIFFERENCE OPPY BASEY]
		       (T                                    (* ↑E take down box.)
			  (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
			  (ERROR!])

(MOVE.WINDOW.MOVINGPT
  [LAMBDA (REGION DIRECTION OPPT SECOND.POINT)               (* edited: "12-Jul-84 16:49")
    (replace (POSITION XCOORD) of OPPT with (SELECTQ DIRECTION
						     (N (fetch (REGION RIGHT) of REGION))
						     (S (fetch (REGION LEFT) of REGION))
						     [(NE E SE)
						       (COND
							 (SECOND.POINT (fetch (REGION RIGHT)
									  of REGION))
							 (T (IMAX (fetch (REGION LEFT) of REGION)
								  (fetch (POSITION XCOORD)
								     of OPPT]
						     [(SW W NW)
						       (COND
							 (SECOND.POINT (fetch (REGION LEFT)
									  of REGION))
							 (T (IMIN (fetch (REGION RIGHT) of REGION)
								  (fetch (POSITION XCOORD)
								     of OPPT]
						     (SHOULDNT)))
    (replace (POSITION YCOORD) of OPPT with (SELECTQ DIRECTION
						     (E (fetch (REGION TOP) of REGION))
						     (W (fetch (REGION BOTTOM) of REGION))
						     [(NW N NE)
						       (COND
							 (SECOND.POINT (fetch (REGION TOP)
									  of REGION))
							 (T (IMAX (fetch (REGION BOTTOM)
								     of REGION)
								  (fetch (POSITION YCOORD)
								     of OPPT]
						     [(SE S SW)
						       (COND
							 (SECOND.POINT (fetch (REGION BOTTOM)
									  of REGION))
							 (T (IMIN (fetch (REGION TOP) of REGION)
								  (fetch (POSITION YCOORD)
								     of OPPT]
						     (SHOULDNT])

(MOVE.WINDOW.SETCURSORPOSITION
  [LAMBDA (REGION DIRECTION OPPT BASEPT)                     (* edited: "12-Jul-84 16:47")
    (\SETCURSORPOSITION (SELECTQ DIRECTION
				 ((N S)
				   (IPLUS (fetch (REGION LEFT) of REGION)
					  (IQUOTIENT (fetch (REGION WIDTH) of REGION)
						     2)))
				 ((NE E SE)
				   (IMAX (fetch (REGION LEFT) of REGION)
					 (fetch (POSITION XCOORD) of OPPT)))
				 ((SW W NW)
				   (IMIN (fetch (REGION RIGHT) of REGION)
					 (fetch (POSITION XCOORD) of OPPT)))
				 (SHOULDNT))
			(SELECTQ DIRECTION
				 ((E W)
				   (IPLUS (fetch (REGION BOTTOM) of REGION)
					  (IQUOTIENT (fetch (REGION HEIGHT) of REGION)
						     2)))
				 ((NW N NE)
				   (IMAX (fetch (REGION BOTTOM) of REGION)
					 (fetch (POSITION YCOORD) of OPPT)))
				 ((SE S SW)
				   (IMIN (fetch (REGION TOP) of REGION)
					 (fetch (POSITION YCOORD) of OPPT)))
				 (SHOULDNT])

(MOVE.WINDOWS
  [LAMBDA NIL                                                (* edited: "12-Jul-84 17:51")
    (PROG (WINDOW DONE)
          (RESETFORM (CURSOR MOVE.WINDOWS.CURSOR)
		     (until (MOUSESTATE UP) do NIL)
		     (until DONE
			do (GETMOUSESTATE)
			   [COND
			     ((LASTMOUSESTATE UP))
			     (T (SETQ WINDOW (WHICHW))
				(COND
				  ((NULL WINDOW)
				    (SETQ DONE T))
				  (T (SETQ WINDOW (MAINWINDOW WINDOW))
				     (TOTOPW WINDOW)
				     (COND
				       ((LASTMOUSESTATE (ONLY RIGHT))
					 (DOWINDOWCOM WINDOW))
				       [NIL (LASTMOUSESTATE (ONLY MIDDLE))
					    (COND
					      ((\USERFNISDON'T (WINDOWPROP WINDOW (QUOTE CLOSEFN)))
						(MOVE.WINDOW.COMPLAIN "closed"))
					      (T (until (MOUSESTATE UP) do NIL)
						 (COND
						   ((MOUSECONFIRM "Close inverted window?")
						     (CLOSEW WINDOW)))
						 (until (MOUSESTATE UP) do NIL]
				       (T (MOVE.WINDOW WINDOW)
					  (until (MOUSESTATE UP) do NIL]
			   (BLOCK 10)))
          (until (MOUSESTATE UP) do NIL])

(SHAPE.WINDOW.GETREGION
  [LAMBDA (MINWIDTH MINHEIGHT REGION DIRECTION)              (* edited: "12-Jul-84 16:49")
                                                             (* accepts region from the user.)
    (RESETFORM (CURSOR (SELECTQ DIRECTION
				((N S)
				  MOVE.WINDOW.NS.CURSOR)
				((E W)
				  MOVE.WINDOW.EW.CURSOR)
				((NE SW)
				  MOVE.WINDOW.NESW.CURSOR)
				((NW SE)
				  MOVE.WINDOW.NWSE.CURSOR)
				(SHOULDNT)))
	       (PROG [BASEX BASEY OPPX OPPY OLDMOUSEX OLDMOUSEY (BASEPT (create POSITION))
			    (OPPT (create POSITION))
			    NEWMOUSEX NEWMOUSEY DOWNFLG (MINWIDTH (COND
								    ((FIXP MINWIDTH))
								    (T 0)))
			    (MINHEIGHT (COND
					 ((FIXP MINHEIGHT))
					 (T 0]
		     (MOVE.WINDOW.FIXEDPT REGION DIRECTION BASEPT)
		     (COND
		       (MOVE.WINDOW.JUMP.TO.BORDER (MOVE.WINDOW.MOVINGPT REGION DIRECTION OPPT T))
		       (T (GETMOUSESTATE)
			  (replace (POSITION XCOORD) of OPPT with LASTMOUSEX)
			  (replace (POSITION YCOORD) of OPPT with LASTMOUSEY)
			  (MOVE.WINDOW.CHECKPT MINWIDTH MINHEIGHT BASEPT OPPT)
			  (MOVE.WINDOW.MOVINGPT REGION DIRECTION OPPT)))
		     (SETQ BASEX (fetch (POSITION XCOORD) of BASEPT))
		     (SETQ BASEY (fetch (POSITION YCOORD) of BASEPT))
		     (SETQ OPPX (fetch (POSITION XCOORD) of OPPT))
		     (SETQ OPPY (fetch (POSITION YCOORD) of OPPT))
                                                             (* Now draw the initial box)
		     (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
		     (MOVE.WINDOW.SETCURSORPOSITION REGION DIRECTION OPPT BASEPT)
		     (COND
		       [[ERSETQ (until (PROGN (GETMOUSESTATE)
					      (LASTMOUSESTATE UP))
				   do (COND
					((OR (NEQ LASTMOUSEX OLDMOUSEX)
					     (NEQ LASTMOUSEY OLDMOUSEY))
                                                             (* the cursor has moved, check user constraints.)
					  (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
					  (replace (POSITION XCOORD) of OPPT with (SETQ OLDMOUSEX 
										    LASTMOUSEX))
					  (replace (POSITION YCOORD) of OPPT with (SETQ OLDMOUSEY 
										    LASTMOUSEY))
					  (MOVE.WINDOW.CHECKPT MINWIDTH MINHEIGHT BASEPT OPPT)
					  (MOVE.WINDOW.MOVINGPT REGION DIRECTION OPPT)
					  (SETQ OPPX (fetch (POSITION XCOORD) of OPPT))
					  (SETQ OPPY (fetch (POSITION YCOORD) of OPPT))
					  (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
					  (MOVE.WINDOW.SETCURSORPOSITION REGION DIRECTION OPPT]
                                                             (* erase box image.)
			 (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
			 (RETURN (create REGION
					 LEFT ←(IMIN BASEX OPPX)
					 BOTTOM ←(IMIN BASEY OPPY)
					 WIDTH ←(IABS (IDIFFERENCE OPPX BASEX))
					 HEIGHT ←(IABS (IDIFFERENCE BASEY OPPY]
		       (T                                    (* ↑E take down box.)
			  (DRAWGRAYBOX BASEX BASEY OPPX OPPY)
			  (ERROR!])
)
(READVARS MOVE.WINDOW.EW.CURSOR MOVE.WINDOW.NESW.CURSOR MOVE.WINDOW.NS.CURSOR MOVE.WINDOW.NWSE.CURSOR 
	  MOVE.WINDOWS.CURSOR MOVE.WINDOW.WRONG)
(({(READBITMAP)(16 16
"@@@@"
"@@@@"
"@DB@"
"@LC@"
"AHAH"
"C@@L"
"F@@F"
"OOOO"
"OOOO"
"F@@F"
"C@@L"
"AHAH"
"@LC@"
"@DB@"
"@@@@"
"@@@@")} 7 . 8)  ({(READBITMAP)(16 16
"@@OO"
"@@GO"
"@@@O"
"@@AO"
"@@CK"
"@@GC"
"@@NC"
"@ALA"
"HCH@"
"LG@@"
"LN@@"
"ML@@"
"OH@@"
"O@@@"
"ON@@"
"OO@@")} 7 . 8)  ({(READBITMAP)(16 16
"@AH@"
"@CL@"
"@GN@"
"@MK@"
"AIIH"
"CAHL"
"@AH@"
"@AH@"
"@AH@"
"@AH@"
"CAHL"
"AIIH"
"@MK@"
"@GN@"
"@CL@"
"@AH@")} 7 . 8)  ({(READBITMAP)(16 16
"OO@@"
"ON@@"
"O@@@"
"OH@@"
"ML@@"
"LN@@"
"LG@@"
"HCH@"
"@ALA"
"@@NC"
"@@GC"
"@@CK"
"@@AO"
"@@@O"
"@@GO"
"@@OO")} 7 . 8)  ({(READBITMAP)(16 16
"OAHO"
"HBDA"
"H@@A"
"IOOI"
"AOOH"
"A@@H"
"EBDJ"
"IAHI"
"IAHI"
"EBDJ"
"A@@H"
"A@@H"
"IOOI"
"H@@A"
"HBDA"
"OAHO")} 7 . 8)  ({(READBITMAP)(16 16
"L@@C"
"N@@G"
"G@@N"
"CHAL"
"ALCH"
"@NG@"
"@GN@"
"@CL@"
"@CL@"
"@GN@"
"@NG@"
"ALCH"
"CHAL"
"G@@N"
"N@@G"
"L@@C")} 7 . 8))

(RPAQQ MOVE.WINDOW.JUMP.TO.BORDER T)
(PUTPROPS MOVE-WINDOWS COPYRIGHT ("Xerox Corporation" 1984))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (1675 14925 (MAINWINDOW 1685 . 2008) (MOVE.WINDOW 2010 . 3782) (MOVE.WINDOW.CHECKPT 3784
 . 5090) (MOVE.WINDOW.COMPLAIN 5092 . 5403) (MOVE.WINDOW.FIXEDPT 5405 . 6031) (MOVE.WINDOW.GETREGION 
6033 . 8357) (MOVE.WINDOW.MOVINGPT 8359 . 9863) (MOVE.WINDOW.SETCURSORPOSITION 9865 . 10856) (
MOVE.WINDOWS 10858 . 11941) (SHAPE.WINDOW.GETREGION 11943 . 14923)))))
STOP