(FILECREATED "28-Oct-85 10:04:29" {SAFE}</C/ONCOCIN/UTILS>REGION.LSP;4 10005  

      changes to:  (FNS REGIONINFN REGIONEVENTFN REGIONOUTFN REGIONMOVEDFN REGIONREPAINTFN)
		   (RECORDS REGIONEVENT)

      previous date: "14-Oct-85 15:41:26" {SAFE}</C/ONCOCIN/UTILS>REGION.LSP;2)


(* Copyright (c) 1984, 1985 by Stanford University. All rights reserved.)

(PRETTYCOMPRINT REGIONCOMS)

(RPAQQ REGIONCOMS ((FNS REGION.INIT ACTIVATEREGIONS DEACTIVATEREGIONS)
		   (MACROS ADDREGIONEVENT)
		   (FNS REGIONEVENTFN REGIONINFN REGIONMOVEDFN REGIONOUTFN REGIONREPAINTFN)
		   (INITVARS DISABLEFLG)
		   (GLOBALVARS DISABLEFLG)
		   (RECORDS REGIONEVENT)))
(DEFINEQ

(REGION.INIT
  [LAMBDA (WINDOW REGIONEVENTLST SAVE?)                      (* cdl "25-Jun-85 09:34")
    (PROG ((REGIONEVENT (create REGIONEVENT
				REGIONREPAINTFN ←(WINDOWPROP WINDOW 'REPAINTFN
							     (FUNCTION REGIONREPAINTFN))
				REGIONOUTFN ←(WINDOWPROP WINDOW 'CURSOROUTFN
							 (FUNCTION REGIONOUTFN))
				REGIONINFN ←(WINDOWPROP WINDOW 'CURSORINFN
							(FUNCTION REGIONINFN))
				REGIONMOVEDFN ←(WINDOWPROP WINDOW 'CURSORMOVEDFN
							   (FUNCTION REGIONMOVEDFN))
				REGIONBUTTONFN ←(WINDOWPROP WINDOW 'BUTTONEVENTFN
							    (FUNCTION REGIONEVENTFN))
				REGIONFLAGS ← SAVE?)))
          (if SAVE?
	      then (push REGIONEVENTLST REGIONEVENT))
          (if REGIONEVENTLST
	      then (WINDOWPROP WINDOW 'REGIONEVENTLST
			       REGIONEVENTLST))
          (RETURN WINDOW])

(ACTIVATEREGIONS
  [LAMBDA (FLAGS WINDOW)                                     (* cdl "25-Jun-85 09:24")
    (for REGIONEVENT in (WINDOWPROP WINDOW 'REGIONEVENTLST)
       when [with REGIONEVENT REGIONEVENT (AND (NOT ACTIVEREGION)
					       (OR (EQ FLAGS T)
						   (for FLAG inside FLAGS thereis (EQMEMB FLAG 
										      REGIONFLAGS]
       do (with REGIONEVENT REGIONEVENT (SETQ ACTIVEREGION T])

(DEACTIVATEREGIONS
  [LAMBDA (FLAGS WINDOW)                                     (* cdl "25-Jun-85 09:23")
    (for REGIONEVENT in (WINDOWPROP WINDOW 'REGIONEVENTLST)
       when [with REGIONEVENT REGIONEVENT (AND ACTIVEREGION (OR (EQ FLAGS T)
								(for FLAG inside FLAGS
								   thereis (EQMEMB FLAG REGIONFLAGS]
       do (with REGIONEVENT REGIONEVENT (SETQ ACTIVEREGION NIL])
)
(DECLARE: EVAL@COMPILE 

(PUTPROPS ADDREGIONEVENT MACRO ((REGIONEVENT WINDOW)
				(WINDOWADDPROP WINDOW 'REGIONEVENTLST
					       REGIONEVENT)))
)
(DEFINEQ

(REGIONEVENTFN
  [LAMBDA (DS)                                               (* cdl "28-Oct-85 10:02")
                                                             (* Applies button function based on position of cursor 
							     in the displaystream)
    (if (OR (NOT DISABLEFLG)
	    (EQMEMB DS DISABLEFLG))
	then (PROG ((REGIONEVENTLST (WINDOWPROP DS 'REGIONEVENTLST))
		    (POSITION (CURSORPOSITION NIL DS)))
	           (if (NULL (bind FLG for REGIONEVENT in REGIONEVENTLST
				when (with REGIONEVENT REGIONEVENT (AND ACTIVEREGION (REGIONP 
										      EVENTREGION)
									(INSIDEP EVENTREGION POSITION)
									))
				do (with REGIONEVENT REGIONEVENT
					 (if REGIONBUTTONFN
					     then (APPLY* REGIONBUTTONFN DS POSITION EVENTREGION 
							  REGIONEVENT)))
				   (SETQ FLG T)
				yield FLG))
		       then (bind (REGION ←(WINDOWPROP DS 'REGION)) for REGIONEVENT in REGIONEVENTLST
			       when [with REGIONEVENT REGIONEVENT (AND ACTIVEREGION
								       (NOT (REGIONP EVENTREGION]
			       do (with REGIONEVENT REGIONEVENT
					(if REGIONBUTTONFN
					    then (APPLY* REGIONBUTTONFN DS POSITION REGION 
							 REGIONEVENT])

(REGIONINFN
  [LAMBDA (DS)                                               (* cdl "28-Oct-85 10:04")
                                                             (* Applies cursor in function based on position of 
							     cursor in the displaystream)
    (if (OR (NOT DISABLEFLG)
	    (EQMEMB DS DISABLEFLG))
	then (PROG ((POSITION (CURSORPOSITION NIL DS))
		    (REGIONEVENTLST (WINDOWPROP DS 'REGIONEVENTLST))
		    LASTREGIONS)
	           (if (NULL (bind FLG for REGIONEVENT in REGIONEVENTLST
				when (with REGIONEVENT REGIONEVENT (AND ACTIVEREGION (REGIONP 
										      EVENTREGION)
									(INSIDEP EVENTREGION POSITION)
									))
				do (with REGIONEVENT REGIONEVENT (if REGIONINFN
								     then (APPLY* REGIONINFN DS 
										  EVENTREGION 
										  REGIONEVENT))
					 (push LASTREGIONS EVENTREGION))
				   (SETQ FLG T)
				yield FLG))
		       then [bind (REGION ←(WINDOWPROP DS 'REGION)) for REGIONEVENT in REGIONEVENTLST
			       when [with REGIONEVENT REGIONEVENT (AND ACTIVEREGION
								       (NOT (REGIONP EVENTREGION]
			       do (with REGIONEVENT REGIONEVENT (if REGIONINFN
								    then (APPLY* REGIONINFN DS REGION 
										 REGIONEVENT]
		     else (WINDOWPROP DS 'LASTEVENTREGIONS
				      LASTREGIONS])

(REGIONMOVEDFN
  [LAMBDA (DS)                                               (* cdl "28-Oct-85 10:01")
                                                             (* Applies cursor moved function based on position of 
							     cursor in the displaystream)
    (if (OR (NULL DISABLEFLG)
	    (EQMEMB DS DISABLEFLG))
	then (PROG ((REGIONEVENTLST (WINDOWPROP DS 'REGIONEVENTLST))
		    (LASTREGIONS (WINDOWPROP DS 'LASTEVENTREGIONS
					     NIL))
		    (POSITION (CURSORPOSITION NIL DS))
		    INFLG OUTFLG MOVEDFLG)
	           [for REGIONEVENT in REGIONEVENTLST
		      do (with REGIONEVENT REGIONEVENT
			       (if (AND (REGIONP EVENTREGION)
					(INSIDEP EVENTREGION POSITION))
				   then (if (FMEMB EVENTREGION LASTREGIONS)
					    then (if (AND ACTIVEREGION REGIONMOVEDFN)
						     then (APPLY* REGIONMOVEDFN DS POSITION 
								  EVENTREGION REGIONEVENT))
						 (SETQ MOVEDFLG T)
					  else (if (AND ACTIVEREGION REGIONINFN)
						   then (APPLY* REGIONINFN DS EVENTREGION REGIONEVENT)
						   )
					       (SETQ INFLG T))
					(WINDOWADDPROP DS 'LASTEVENTREGIONS
						       EVENTREGION)
				 elseif (FMEMB EVENTREGION LASTREGIONS)
				   then (if (AND ACTIVEREGION REGIONOUTFN)
					    then (APPLY* REGIONOUTFN DS EVENTREGION REGIONEVENT))
					(SETQ OUTFLG T]
	           (bind (REGION ←(WINDOWPROP DS 'REGION)) for REGIONEVENT in REGIONEVENTLST
		      when [with REGIONEVENT REGIONEVENT (AND ACTIVEREGION (NOT (REGIONP EVENTREGION]
		      do (with REGIONEVENT REGIONEVENT (if (AND INFLG (NOT OUTFLG)
								REGIONOUTFN)
							   then (APPLY* REGIONOUTFN DS REGION 
									REGIONEVENT)
							 elseif (AND OUTFLG (NOT INFLG)
								     REGIONINFN)
							   then (APPLY* REGIONINFN DS REGION 
									REGIONEVENT)
							 elseif (AND (NOT INFLG)
								     (NOT OUTFLG)
								     (NOT MOVEDFLG)
								     REGIONMOVEDFN)
							   then (APPLY* REGIONMOVEDFN DS POSITION 
									REGION REGIONEVENT])

(REGIONOUTFN
  [LAMBDA (DS)                                               (* cdl "28-Oct-85 09:59")
                                                             (* Applies cursor out function based on position of 
							     cursor in the displaystream)
    (if (OR (NULL DISABLEFLG)
	    (EQMEMB DS DISABLEFLG))
	then (PROG ((REGIONEVENTLST (WINDOWPROP DS 'REGIONEVENTLST))
		    (LASTREGIONS (WINDOWPROP DS 'LASTEVENTREGIONS
					     NIL)))
	           (if LASTREGIONS
		       then [for REGIONEVENT in REGIONEVENTLST when (with REGIONEVENT REGIONEVENT
									  (AND ACTIVEREGION
									       (REGIONP EVENTREGION)
									       (FMEMB EVENTREGION 
										      LASTREGIONS)))
			       do (with REGIONEVENT REGIONEVENT (if REGIONOUTFN
								    then (APPLY* REGIONOUTFN DS 
										 EVENTREGION 
										 REGIONEVENT]
		     else (bind (REGION ←(WINDOWPROP DS 'REGION)) for REGIONEVENT in REGIONEVENTLST
			     when [with REGIONEVENT REGIONEVENT (AND ACTIVEREGION
								     (NOT (REGIONP EVENTREGION]
			     do (with REGIONEVENT REGIONEVENT (if REGIONOUTFN
								  then (APPLY* REGIONOUTFN DS REGION 
									       REGIONEVENT])

(REGIONREPAINTFN
  [LAMBDA (DS)                                               (* cdl "28-Oct-85 10:01")
                                                             (* Applies the various region repaint fns to the 
							     regions in windows region list)
    (bind (REGION ←(WINDOWPROP DS 'REGION)) for REGIONEVENT in (WINDOWPROP DS 'REGIONEVENTLST)
       do (with REGIONEVENT REGIONEVENT (if REGIONREPAINTFN
					    then (APPLY* REGIONREPAINTFN DS (if (REGIONP EVENTREGION)
										then EVENTREGION
									      else REGION)
							 REGIONEVENT])
)

(RPAQ? DISABLEFLG NIL)
(DECLARE: DOEVAL@COMPILE DONTCOPY

(GLOBALVARS DISABLEFLG)
)
[DECLARE: EVAL@COMPILE 

(RECORD REGIONEVENT (EVENTREGION REGIONBUTTONFN REGIONMOVEDFN REGIONINFN REGIONOUTFN REGIONREPAINTFN 
				 ACTIVEREGION REGIONFLAGS REGIONUSERDATA)
		    ACTIVEREGION ← T)
]
(PUTPROPS REGION.LSP COPYRIGHT ("Stanford University" 1984 1985))
(DECLARE: DONTCOPY
  (FILEMAP (NIL (659 2482 (REGION.INIT 669 . 1549) (ACTIVATEREGIONS 1551 . 2027) (DEACTIVATEREGIONS 2029
 . 2480)) (2640 9625 (REGIONEVENTFN 2650 . 3982) (REGIONINFN 3984 . 5431) (REGIONMOVEDFN 5433 . 7668) 
(REGIONOUTFN 7670 . 8992) (REGIONREPAINTFN 8994 . 9623)))))
STOP