-- JaMGraphicsTool.mesa -- Last change by Doug Wyatt, 7-Nov-81 14:44:34 DIRECTORY JaMGraphics USING [], JaMTajo, CGScreen USING [Bits], Tool USING [AddThisSW, Create, MakeSWsProc, RegisterSWType, SWType], ToolWindow USING [CreateSubwindow, DisplayProcType, TransitionProcType], UserInput USING [GetMouseAndCursorPosition, KeyPNRType, SetKeyPNR], Window USING [BitmapPlace, DisplayData, Handle, InvalidateBox, Place, Validate]; JaMGraphicsTool: MONITOR IMPORTS CGScreen, Tool, ToolWindow, UserInput, Window, JaMTajo EXPORTS JaMGraphics = BEGIN -- Globals wh: Window.Handle; -- Tool's window swtype: Tool.SWType; -- unique type for subwindow sw: Window.Handle _ NIL; -- subwindow for graphics data: LONG POINTER _ NIL; -- pointer to Cedar screen raster: CARDINAL _ 0; -- screen words per line height: CARDINAL _ 0; -- screen height bugflag: BOOLEAN _ FALSE; bugplace: Window.Place _ [0,0]; Bugged: CONDITION; -- Tool needed routines ClientTransition: ENTRY ToolWindow.TransitionProcType = -- This procedure is called whenever the system determines that this -- Tool's state is undergoing a user invoked transition. BEGIN IF new = inactive THEN sw _ NIL; END; Init: PROCEDURE = BEGIN swtype _ Tool.RegisterSWType[]; [data,raster,height] _ CGScreen.Bits[]; wh _ Tool.Create[initialBox: [[0,408],[400,400]], makeSWsProc: MakeSWs, initialState: default, clientTransition: ClientTransition, name: "JaM Graphics"L]; END; MakeSWs: Tool.MakeSWsProc = BEGIN sw _ ToolWindow.CreateSubwindow[ parent: window, display: MyDisplay, boxesCount: none]; UserInput.SetKeyPNR[sw,redButton,MyButton]; UserInput.SetKeyPNR[sw,blueButton,MyButton]; sw.clearingNotRequired _ TRUE; Tool.AddThisSW[window,sw,swtype]; JaMTajo.AcceptTypeInFrom[sw]; END; MyDisplay: ToolWindow.DisplayProcType = { Window.DisplayData[ window: window, box: [[0,0],[raster*16,height]], data: data, wpl: raster, bbop: replace]; }; SetBug: ENTRY PROC[place: Window.Place] = --INLINE-- { IF sw=NIL THEN RETURN; bugflag _ TRUE; bugplace _ place; NOTIFY Bugged }; GetBug: ENTRY PROC[clr: BOOLEAN _ TRUE] RETURNS[Window.Place] = --INLINE-- { place: Window.Place; IF clr THEN bugflag _ FALSE; UNTIL sw=NIL OR bugflag DO WAIT Bugged ENDLOOP; IF sw=NIL THEN place _ UserInput.GetMouseAndCursorPosition[] ELSE { place _ bugplace; bugflag _ FALSE }; RETURN[place] }; GetPlace: ENTRY PROC RETURNS[Window.Place] = --INLINE-- { place: Window.Place _ UserInput.GetMouseAndCursorPosition[]; IF sw#NIL THEN { w: Window.Place _ Window.BitmapPlace[sw]; place.x _ place.x - w.x; place.y _ place.y - w.y }; RETURN[place] }; MyButton: UserInput.KeyPNRType = { doit: BOOLEAN _ TRUE; button: JaMTajo.Button; IF key=Red AND downUp=down THEN SetBug[place]; SELECT key FROM Red => button _ IF downUp=down THEN rd ELSE ru; Blue => button _ IF downUp=down THEN bd ELSE bu; ENDCASE => doit _ FALSE; JaMTajo.DoButton[button,place.x,place.y]; }; Mouse: PUBLIC PROC[click: BOOLEAN] RETURNS[x,y: INTEGER] = { place: Window.Place; IF click THEN place _ GetBug[] ELSE place _ GetPlace[]; RETURN[place.x, place.y]; }; Update: PUBLIC ENTRY PROC = { IF sw#NIL THEN { w: INTEGER _ raster*16; h: INTEGER _ height; Window.InvalidateBox[sw,[[0,0],[w,h]]]; Window.Validate[sw] }; }; -- Mainline code Init[]; -- this gets string out of global frame END...