-- File: MagicViewing.mesa -- Written by Martin Newell February 1980 -- Implements viewing part of Magic -- Last edited (Pilot): 29-Oct-81 18:59:51 DIRECTORY CIFUtilitiesDefs: FROM "CIFUtilitiesDefs" USING [DisplayContext, Rectangle, InitCedarGraphics, GetClipRectangle, SetClipRectangle, SetUniformView, TrackBox, GetDisplayContext, Update, WatchKeys], IODefs USING [WriteLine], Graphics: FROM "Graphics" USING [Translate], JaMFnsDefs: FROM "JaMFnsDefs" USING [Register, PopInteger, GetReal, PushReal], Keys: FROM "Keys" USING [KeyName]; MagicViewing: PROGRAM IMPORTS CIFUtilitiesDefs, Graphics, IODefs, JaMFnsDefs = BEGIN OPEN CIFUtilitiesDefs, Graphics, IODefs, JaMFnsDefs, Keys; --Viewing control CallTrackBox: PROCEDURE = BEGIN --expects (REAL) mouseButtons: Keys.KeyName; mouse: INTEGER _ PopInteger[]; y: REAL _ GetReal[]; x: REAL _ GetReal[]; SELECT mouse FROM 4 => mouseButtons _ Red; 2 => mouseButtons _ Yellow; 1 => mouseButtons _ Blue; ENDCASE => RETURN; TrackBox[x,y, mouseButtons]; END; Expand: PROCEDURE = BEGIN --expects (REAL) r: Rectangle _ GetClipRectangle[]; top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; SetUniformView[[MIN[left,right],MIN[bottom,top],MAX[left,right],MAX[bottom,top]], r]; END; Contract: PROCEDURE = BEGIN --expects (REAL) r: Rectangle _ GetClipRectangle[]; top: REAL _ GetReal[]; right: REAL _ GetReal[]; bottom: REAL _ GetReal[]; left: REAL _ GetReal[]; SetUniformView[r, [MIN[left,right],MIN[bottom,top],MAX[left,right],MAX[bottom,top]]]; END; Scroll: PROCEDURE = BEGIN --expects (REAL) dc: DisplayContext _ GetDisplayContext[]; yto: REAL _ GetReal[]; xto: REAL _ GetReal[]; yfrom: REAL _ GetReal[]; xfrom: REAL _ GetReal[]; Translate[dc, xto-xfrom, yto-yfrom]; END; CallSetClipRegion: PROCEDURE = BEGIN --expects (REAL) rt: Rectangle; rt.ury _ GetReal[]; rt.urx _ GetReal[]; rt.lly _ GetReal[]; rt.llx _ GetReal[]; SetClipRectangle[rt]; END; CallGetClipRegion: PROCEDURE = BEGIN --returns (REAL) rt: Rectangle _ GetClipRectangle[]; PushReal[rt.llx]; PushReal[rt.lly]; PushReal[rt.urx]; PushReal[rt.ury]; END; CallUpdate: PROCEDURE = BEGIN Update; END; --*** START Code *** WriteLine["Calling InitCedarGraphics"]; InitCedarGraphics[]; WriteLine["Registering trackbox,expand,contract,scroll,watchkeys"]; --Viewing control Register["trackbox",CallTrackBox]; Register["expand",Expand]; Register["contract",Contract]; Register["scroll",Scroll]; Register["watchkeys",WatchKeys]; Register["setclipregion",CallSetClipRegion]; Register["getclipregion",CallGetClipRegion]; Register["update",CallUpdate]; WriteLine["Start code complete"]; END. (635)\148b9B1171b6B382b8B152b12B270b15B410b10B57b13B247b6B192b6B96b8B56b13B118b12B328b6B294b8B294b6B251b9B267b12B180b17B189b17B182b19B147b21B177b15B293b13B277b15B284b10B345b5B96b7B130b16B