(DEFINE-FILE-INFO READTABLE "INTERLISP" PACKAGE "INTERLISP")
(FILECREATED " 4-Sep-87 12:22:04" |{MCS:MCS:STANFORD}<LANE>REGION.;1| 13780  

      changes to%:  (VARS REGIONCOMS))


(* "
Copyright (c) 1984, 1985, 1986, 1987 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 COPYRIGHT ("Stanford University" 1984 1985 1986 1987))
(DECLARE%: DONTCOPY
  (FILEMAP (NIL (647 2917 (REGION.INIT 657 . 1802) (ACTIVATEREGIONS 1804 . 2370) (DEACTIVATEREGIONS 2372
 . 2915)) (3083 13356 (REGIONEVENTFN 3093 . 5153) (REGIONINFN 5155 . 7250) (REGIONMOVEDFN 7252 . 10684
) (REGIONOUTFN 10686 . 12558) (REGIONREPAINTFN 12560 . 13354)))))
STOP