<<>> <> <> <> <> DIRECTORY IO, ViewerClasses; MouseTrap: CEDAR DEFINITIONS ~ BEGIN <> <> TrapTillMouseUp: PROC [v: Viewer, circle, wrapAround: BOOL]; <> <> Viewer: TYPE ~ ViewerClasses.Viewer; Position: TYPE ~ RECORD [x, y: INTEGER]; MouseTrapSpecs: TYPE ~ RECORD [ enabled: BOOL ¬ FALSE, -- TRUE if trapping desired proc: MouseTrapProc ¬ NIL, -- proc to call with mouse coords data: REF ANY ¬ NIL -- data to pass to proc ]; MouseTrapProc: TYPE ~ PROC [mouse: Position, data: REF ANY] RETURNS [changed: BOOL ¬ FALSE, mouseTo: Position]; <> <> BoxTrapData: TYPE ~ REF BoxTrapDataRep; BoxTrapDataRep: TYPE ~ RECORD [ wrap: {no, x, yes, y} ¬ no, -- wrap mouse at edges, else stick minCorner: Position ¬ [370, 270], -- smallest coordinates in box trap maxCorner: Position ¬ [430, 330] -- largest coordinates in box trap ]; RoundTrapData: TYPE ~ REF RoundTrapDataRep; RoundTrapDataRep: TYPE ~ RECORD [ wrap: {no, yes} ¬ no, -- wrap mouse at edge, else stick center: Position ¬ [400, 300], -- center of circular trap radiusSquared: REAL ¬ 900 -- square of radius of circular trap ]; <> <> <> <> <> <<>> UserToMouseCoords: PROC [self: Viewer, vx, vy: INTEGER ¬ 0] RETURNS [Position]; <> <<>> UserFromMouseCoords: PROC [self: Viewer, mx, my: INTEGER ¬ 0] RETURNS [Position]; <> <> <> <<>> SetTrap: PROC [newSpecs: MouseTrapSpecs] RETURNS [MouseTrapSpecs]; <> <<>> GetTrap: PROC RETURNS [MouseTrapSpecs]; <> <<>> UnsetTrap: PROC RETURNS [MouseTrapSpecs]; <> <<>> StartWatchingMouseTrap: PROC; <> <<>> StopWatchingMouseTrap: PROC; <> <<>> Debug: PROC [out: IO.STREAM]; <> <> MouseUpEscape: PROC RETURNS [BOOL]; <> <<>> BoxTrap: MouseTrapProc; <> <<>> RoundTrap: MouseTrapProc; <> END.