(FILECREATED "18-Dec-85 20:43:38" {FLOPPY}ACTIVEREGIONS2.;1 8773   

      changes to:  (VARS ACTIVEREGIONS2COMS)

      previous date: "18-Dec-85 20:40:48" {DSK}<USERFILES>LISPUSERS>ACTIVEREGIONS2.;1)


(PRETTYCOMPRINT ACTIVEREGIONS2COMS)

(RPAQQ ACTIVEREGIONS2COMS ((* * public part)
			   (RECORDS ACTIVEREGION)
			   (FNS SETACTIVEREGIONS UNSETACTIVEREGIONS ADDACTIVEREGION ADDACTIVEREGIONS 
				DELETEACTIVEREGION FINDACTIVEREGION SETPICKREGION GETPICKREGION)
			   (* * private part)
			   (FNS ACTIVEREGIONS/BUTTONEVENTFN ACTIVEREGIONS/CHECKPOSITION 
				ACTIVEREGIONS/DOHIGHLIGHT ACTIVEREGIONS/DOLOWLIGHT 
				ACTIVEREGIONS/DEFAULTHIGHLIGHTFN)))
(* * public part)

[DECLARE: EVAL@COMPILE 

(RECORD ACTIVEREGION (REGION HELPSTRING DOWNFN UPFN HIGHLIGHTFN LOWLIGHTFN DATA))
]
(DEFINEQ

(SETACTIVEREGIONS
  [LAMBDA (Window Regionlist Highlightfn Lowlightfn Downfn Upfn)
                                                             (* M.Model "11-Oct-85 13:32")
                                                             (*)
                                                             (* DRB: " 1-SEP-82 15:28")

          (* Changed so WINDOWPROPs are done even with null Regionlist. -
	  Use UNSETACTIVEREGIONS to turn off active regions. -
	  SETACTIVEREGIONS saves the windows buttonfn in OLDBUTTONEVENTFN; UNSETACTIVEREGIONS restores it.
	  -
	  Added Downfn and Upfn and changed ACTIVEREGIONS/BUTTONEVENTFN and SETPICKREGION accordingly.
	  -
	  Set PICKREGION to NIL in case this used to be an activeregions window and it is being reset without having been 
	  unset (problem is old pickregion will be inverted inappropriately when the first selection is made after this 
	  SETACTIVEREGIONS) -
	  M.Model)


    (COND
      ((NOT (WINDOWP Window))
	(ERROR "SETACTIVEREGIONS: ARG NOT WINDOW" Window))
      (T (WINDOWPROP Window (QUOTE ACTIVEREGIONS)
		     Regionlist)
	 (WINDOWPROP Window (QUOTE PICKREGION)
		     NIL)
	 (WINDOWPROP Window (QUOTE HIGHLIGHTFN)
		     (OR Highlightfn (FUNCTION ACTIVEREGIONS/DEFAULTHIGHLIGHTFN)))
	 (WINDOWPROP Window (QUOTE LOWLIGHTFN)
		     (OR Lowlightfn Highlightfn (FUNCTION ACTIVEREGIONS/DEFAULTHIGHLIGHTFN)))
	 (WINDOWPROP Window (QUOTE DOWNFN)
		     Downfn)
	 (WINDOWPROP Window (QUOTE UPFN)
		     Upfn)
	 (WINDOWPROP Window (QUOTE OLDBUTTONEVENTFN)
		     (WINDOWPROP Window (QUOTE BUTTONEVENTFN)))
	 (WINDOWPROP Window (QUOTE BUTTONEVENTFN)
		     (FUNCTION ACTIVEREGIONS/BUTTONEVENTFN))
	 (WINDOWPROP Window (QUOTE PICKREGION)
		     NIL])

(UNSETACTIVEREGIONS
  [LAMBDA (WIN)                                              (* M.Model " 2-DEC-83 14:54")
    (WINDOWPROP WIN (QUOTE ACTIVEREGIONS)
		NIL)
    (WINDOWPROP WIN (QUOTE PICKREGION)
		NIL)
    (WINDOWPROP WIN (QUOTE BUTTONEVENTFN)
		(WINDOWPROP WIN (QUOTE OLDBUTTONEVENTFN])

(ADDACTIVEREGION
  [LAMBDA (Window Activeregion)                              (* DRB: " 1-SEP-82 15:17")
    (COND
      ((NOT (WINDOWP Window))
	(ERROR "ADDACTIVEREGION: ARG NOT WINDOW" Window)
	NIL)
      (T (WINDOWPROP Window (QUOTE ACTIVEREGIONS)
		     (CONS Activeregion (WINDOWPROP Window (QUOTE ACTIVEREGIONS])

(ADDACTIVEREGIONS
  [LAMBDA (Window Activeregions)                             (* M.Model " 3-MAR-84 01:42")
    (COND
      ((NOT (WINDOWP Window))
	(ERROR "ADDACTIVEREGION: ARG NOT WINDOW" Window)
	NIL)
      (T (WINDOWPROP Window (QUOTE ACTIVEREGIONS)
		     (APPEND Activeregions (WINDOWPROP Window (QUOTE ACTIVEREGIONS])

(DELETEACTIVEREGION
  [LAMBDA (Window Activeregion)                              (* DRB: " 1-SEP-82 15:21")
    (COND
      ((NOT (WINDOWP Window))
	(ERROR "DELETEACTIVEREGION: ARG NOT WINDOW" Window)
	NIL)
      (T (AND (EQ Activeregion (GETPICKREGION Window))
	      (SETPICKREGION Window NIL))
	 (WINDOWPROP Window (QUOTE ACTIVEREGIONS)
		     (DREMOVE Activeregion (WINDOWPROP Window (QUOTE ACTIVEREGIONS])

(FINDACTIVEREGION
  [LAMBDA (Window Xcoord Ycoord Regionlist/optional)         (* DRB: " 1-SEP-82 15:11")
    (COND
      ((NOT (WINDOWP Window))
	(ERROR "FINDACTIVEREGION: ARG NOT WINDOW" Window)
	NIL)
      (T (for X in (OR Regionlist/optional (WINDOWPROP Window (QUOTE ACTIVEREGIONS)))
	    thereis (ACTIVEREGIONS/CHECKPOSITION X:ACTIVEREGION.REGION Xcoord Ycoord])

(SETPICKREGION
  [LAMBDA (Window Activeregion Oldregion/local)              (* M.Model " 7-MAR-84 14:08")
                                                             (*)
                                                             (* DRB: " 2-SEP-82 15:12")
                                                             (* MLM: Added DOWNFN windowprop.)
    (COND
      ((NOT (WINDOWP Window))
	(ERROR "SETPICKREGION: ARG NOT WINDOW" Window)
	NIL)
      ((NEQ Activeregion (SETQ Oldregion/local (GETPICKREGION Window)))
	(AND Oldregion/local (ACTIVEREGIONS/DOLOWLIGHT Window Oldregion/local))
	(AND Activeregion (PROGN (APPLY* (OR Activeregion:ACTIVEREGION.DOWNFN (WINDOWPROP
					       Window
					       (QUOTE DOWNFN))
					     (FUNCTION NILL))
					 Window Activeregion:ACTIVEREGION.REGION 
					 Activeregion:ACTIVEREGION.DATA)
				 (MOUSESTATE LEFT))
	     (PROGN (ACTIVEREGIONS/DOHIGHLIGHT Window Activeregion)
		    Activeregion)))
      (T Activeregion])

(GETPICKREGION
  [LAMBDA (Window)                                           (* DRB: " 1-SEP-82 10:43")
    (WINDOWPROP Window (QUOTE PICKREGION])
)
(* * private part)

(DEFINEQ

(ACTIVEREGIONS/BUTTONEVENTFN
  [LAMBDA (Window)                                           (* M.Model " 3-JAN-84 12:14")
                                                             (*)
                                                             (* DRB: " 2-SEP-82 14:09")
                                                             (* MLM: Left button for selection, middle to execute 
							     MIDDLEBUTTONEVENTFN of window.
							     Added default UPFN.)
    (COND
      [(MOUSESTATE LEFT)
	(while (MOUSESTATE LEFT)
	   bind (PLACELIST ←(WINDOWPROP Window (QUOTE ACTIVEREGIONS)))
		(LASTPLACE ←(GETPICKREGION Window))
	   do (SETQ LASTPLACE (SETPICKREGION Window (FINDACTIVEREGION Window (LASTMOUSEX Window)
								      (LASTMOUSEY Window)
								      PLACELIST)))
	   finally (PROGN (AND LASTPLACE (APPLY* (OR LASTPLACE:ACTIVEREGION.UPFN (WINDOWPROP
						       Window
						       (QUOTE UPFN))
						     (FUNCTION NILL))
						 Window LASTPLACE:ACTIVEREGION.REGION 
						 LASTPLACE:ACTIVEREGION.DATA))
			  (RETURN LASTPLACE]
      ((MOUSESTATE MIDDLE)
	(AND (WINDOWPROP Window (QUOTE MIDDLEBUTTONEVENTFN))
	     (APPLY* (WINDOWPROP Window (QUOTE MIDDLEBUTTONEVENTFN))
		     Window])

(ACTIVEREGIONS/CHECKPOSITION
  [LAMBDA (Region Xcoord Ycoord)                             (* DRB: " 1-SEP-82 09:44")
                                                             (* Returns NIL unless (Xcoord Ycoord) is within Region)
    (AND (IGEQ Xcoord Region:REGION.LEFT)
	 (ILEQ Xcoord Region:REGION.RIGHT)
	 (IGEQ Ycoord Region:REGION.BOTTOM)
	 (ILEQ Ycoord Region:REGION.TOP])

(ACTIVEREGIONS/DOHIGHLIGHT
  [LAMBDA (Window Activeregion)                              (* DRB: " 2-SEP-82 15:10")
    (APPLY* (OR Activeregion:ACTIVEREGION.HIGHLIGHTFN (WINDOWPROP Window (QUOTE HIGHLIGHTFN))
		(FUNCTION NILL))
	    Window Activeregion)
    (WINDOWPROP Window (QUOTE PICKREGION)
		Activeregion])

(ACTIVEREGIONS/DOLOWLIGHT
  [LAMBDA (Window Activeregion)                              (* DRB: " 2-SEP-82 15:11")
    (APPLY* (OR Activeregion:ACTIVEREGION.LOWLIGHTFN (WINDOWPROP Window (QUOTE LOWLIGHTFN))
		(FUNCTION NILL))
	    Window Activeregion)
    (WINDOWPROP Window (QUOTE PICKREGION)
		NIL])

(ACTIVEREGIONS/DEFAULTHIGHLIGHTFN
  [LAMBDA (Window Activeregion)                              (* ejs: "12-OCT-82 23:58")
    (PROG ((WC (DSPCLIPPINGREGION NIL Window)))
          (BITBLT NIL NIL NIL Window WC:REGION.LEFT WC:REGION.BOTTOM WC:REGION.WIDTH WC:REGION.HEIGHT
		  (QUOTE TEXTURE)
		  (QUOTE INVERT)
		  BLACKSHADE Activeregion:ACTIVEREGION.REGION])
)
(DECLARE: DONTCOPY
  (FILEMAP (NIL (801 5879 (SETACTIVEREGIONS 811 . 2693) (UNSETACTIVEREGIONS 2695 . 3026) (
ADDACTIVEREGION 3028 . 3390) (ADDACTIVEREGIONS 3392 . 3761) (DELETEACTIVEREGION 3763 . 4233) (
FINDACTIVEREGION 4235 . 4655) (SETPICKREGION 4657 . 5714) (GETPICKREGION 5716 . 5877)) (5905 8751 (
ACTIVEREGIONS/BUTTONEVENTFN 5915 . 7254) (ACTIVEREGIONS/CHECKPOSITION 7256 . 7671) (
ACTIVEREGIONS/DOHIGHLIGHT 7673 . 8021) (ACTIVEREGIONS/DOLOWLIGHT 8023 . 8359) (
ACTIVEREGIONS/DEFAULTHIGHLIGHTFN 8361 . 8749)))))
STOP