-- TJaMGraphicsImpl.mesa
-- Last changed by Doug Wyatt, 20-Nov-81 12:36:43
-- Last changed by Bill Paxton, July 8, 1982 8:46 am
-- Last changed by McGregor, June 10, 1982 4:10 pm
DIRECTORY
Graphics,
GraphicsOps,
GraphicsBasic USING [Vec],
CGVector USING [Sub, Cross],
InputFocus USING [CaptureButtons, ReleaseButtons],
Rope USING [Concat, FromRefText],
Spline USING [Ref, New, Knot, Enter],
TIPUser USING [InstantiateNewTIPTable],
Cursors USING [SetCursor],
WindowManager USING [RestoreCursor],
Menus USING [Menu, MenuProc, CreateMenu, InsertMenuEntry],
ViewerClasses USING [Viewer, ViewerClass, ViewerClassRec],
ViewerMenus USING [Destroy, Move, Grow, Close],
ViewerOps USING [DestroyViewer, PaintViewer, RegisterViewerClass, CreateViewer],
JaMBasic USING [Object],
JaMInternal USING [Frame],
JaMOps USING [defaultFrame, PopInteger, PushInteger, PushReal, PopReal, PopString,
PushBoolean, PopBoolean, RegisterExplicit, SetAbort, StringText],
JaMTypeScript USING [GetTypeScript, NotifyBeforeDestroy, SetMouseProc],
JaMGraphics,
TJaMGraphics,
TJaMGraphicsPrivate;
TJaMGraphicsImpl: MONITOR
IMPORTS JaMOps, JaMTypeScript, TJaMGraphics, TJaMGraphicsPrivate,
InputFocus, Graphics, GraphicsOps, CGVector, Menus, Rope, Spline, TIPUser, ViewerMenus, ViewerOps, WindowManager, Cursors
EXPORTS JaMGraphics, TJaMGraphics, TJaMGraphicsPrivate = {
OPEN J: JaMOps, G: Graphics, E: GraphicsOps,
Vector: CGVector, JaMGraphics, TJaMGraphics, TJaMGraphicsPrivate;
jamGraphicsClass: ViewerClasses.ViewerClass ← NEW[ViewerClasses.ViewerClassRec ← [
paint: Paint,
notify: InputNotify,
destroy: AboutToDestroy,
tipTable: TIPUser.InstantiateNewTIPTable["JaMGraphics.TIP"]
]];
JReloadTIP: PROC [frame: Frame] = { ReloadTIP[] };
ReloadTIP: PUBLIC PROC = {
jamGraphicsClass.tipTable ← TIPUser.InstantiateNewTIPTable["JaMGraphics.TIP"] };
Vec: TYPE = GraphicsBasic.Vec;
GetDC: PUBLIC PROCEDURE RETURNS[G.Context] = {
info: Info ← GetInfo[J.defaultFrame];
IF info = NIL THEN RETURN [NIL];
RETURN[info.dc] };
PopString: PROC [info: Info] = {
J.StringText[J.PopString[info.frame.opstk],LOOPHOLE[info.text, LONG STRING]];
};
JGetViewer: PROC [frame: Frame] = {
tool: ViewerClasses.Viewer ← JaMTypeScript.GetTypeScript[frame];
IF tool=NIL THEN RETURN; -- error
[] ← Create[frame,tool];
};
Create: PUBLIC PROC [
frame: Frame, typescript: ViewerClasses.Viewer, iconic: BOOLEAN ← FALSE]
RETURNS [viewer: ViewerClasses.Viewer] = {
info: Info;
menu: Menus.Menu;
{ -- extra block to make info defined in scope of UNWIND
ENABLE UNWIND => -- something went wrong while creating the viewer
IF viewer#NIL THEN DestroyViewer[viewer] ELSE IF info#NIL THEN ForgetInfo[frame];
IF (info ← GetInfo[frame]) # NIL THEN RETURN;
info ← CreateInfo[frame];
info.bitmap ← E.NewBitmap[bmw,bmh];
info.spline ← Spline.New[];
info.font ← E.DefaultFont[];
info.text ← NEW[TEXT[256]];
menu ← Menus.CreateMenu[];
Menus.InsertMenuEntry[menu, "Reset", Reset];
Menus.InsertMenuEntry[menu, "Mouse", CaptureFocusButton];
Menus.InsertMenuEntry[menu, "Interrupt", InterruptButton];
Menus.InsertMenuEntry[menu, "Destroy", ViewerMenus.Destroy];
Menus.InsertMenuEntry[menu, "<-->", ViewerMenus.Move];
Menus.InsertMenuEntry[menu, "Grow", ViewerMenus.Grow];
Menus.InsertMenuEntry[menu, "Close", ViewerMenus.Close];
viewer ← ViewerOps.CreateViewer[flavor: $JaMGraphics, info: [data: info,
name: Rope.Concat[typescript.name,"Graphics "], iconic: iconic, scrollable: FALSE]];
viewer.menu ← menu;
info.viewer ← viewer;
info.typescript ← typescript;
JaMTypeScript.NotifyBeforeDestroy[typescript,JDestroyViewer];
}};
Reset: Menus.MenuProc = {
frame: Frame ← NARROW[viewer.data,Info].frame;
InitDC[frame]; JErase[frame] };
CaptureFocusButton: Menus.MenuProc = {
info: Info ← NARROW[viewer.data];
frame: Frame ← info.frame;
JCaptureButtons[frame] };
InterruptButton: Menus.MenuProc = {
info: Info ← NARROW[viewer.data];
frame: Frame ← info.frame;
J.SetAbort[frame,TRUE];
SetPlace[info,0,0];
SetBug[info,0,0] };
JDestroyViewer: PROCEDURE [frame: Frame] = { -- returns true if already have a viewer for this frame
info: Info ← GetInfo[frame];
IF info = NIL THEN RETURN;
DestroyViewer[info.viewer];
};
DestroyViewer: PROC [viewer: ViewerClasses.Viewer] = {
AboutToDestroy[viewer];
ViewerOps.DestroyViewer[viewer];
};
AboutToDestroy: PROC [self: ViewerClasses.Viewer] = {
info: Info ← NARROW[self.data];
ForgetInfo[info.frame];
};
Paint: ENTRY PROCEDURE [self: ViewerClasses.Viewer, context: G.Context,
whatChanged: REF ANY, clear: BOOLEAN] = {
ENABLE UNWIND => NULL;
info: Info ← NARROW[self.data];
IF whatChanged=NIL THEN { -- reestablish context and erase
info.initdc ← G.CopyContext[context];
InitDC[info.frame];
IF ~clear THEN { -- cannot simply call JErase because of monitor deadlock
mark: G.Mark ← G.Save[info.dc];
G.SetColor[info.dc, G.white];
G.DrawBox[info.dc,G.GetBounds[info.dc]];
G.Restore[info.dc,mark] };
RETURN };
info.proc[info];
};
Painter: PUBLIC PROCEDURE[proc: PROC [Graphics.Context], frame: Frame ← NIL] = {
info: Info;
CallBack: PROC [info: Info] = { proc[info.dc] };
IF frame=NIL THEN frame ← J.defaultFrame;
info ← GetInfo[frame];
info.proc ← CallBack;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
InitDC: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.dc ← G.CopyContext[info.initdc];
};
PushDC: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
[] ← G.Save[info.dc];
};
PopDC: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
G.Restore[info.dc];
};
GetVec: PROCEDURE [frame: Frame] RETURNS[Vec] = {
y: REAL ← J.PopReal[frame.opstk]; x: REAL ← J.PopReal[frame.opstk]; RETURN[[x,y]] };
GetPoint: PROCEDURE [frame: Frame] RETURNS[x,y: REAL] = {
y ← J.PopReal[frame.opstk]; x ← J.PopReal[frame.opstk]; RETURN[x,y] };
PutPoint: PROCEDURE[frame: Frame, x,y: REAL] = {
J.PushReal[frame.opstk,x]; J.PushReal[frame.opstk,y] };
Rect: TYPE = RECORD[xmin,ymin,xmax,ymax: REAL];
GetRect: PROCEDURE [frame: Frame] RETURNS[r: Rect] = {
[r.xmax,r.ymax] ← GetPoint[frame];
[r.xmin,r.ymin] ← GetPoint[frame];
RETURN[r];
};
PutRect: PROCEDURE[frame: Frame, r: Rect] = {
PutPoint[frame,r.xmin,r.ymin];
PutPoint[frame,r.xmax,r.ymax];
};
JSetVw: PROCEDURE [frame: Frame] = {
rt: Rect ← GetRect[frame];
rf: Rect ← GetRect[frame];
-- *** fix this
-- SetView[dc,@rf,@rt];
};
JClipArea: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
G.ClipArea[info.dc];
};
JClipEOArea: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
G.ClipArea[self: info.dc, parityFill: TRUE];
};
JClipXArea: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
G.ClipArea[self: info.dc, exclude: TRUE];
};
JClipBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
box: G.Box ← GetBox[frame];
G.ClipBox[info.dc, box];
};
JClipXBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
box: G.Box ← GetBox[frame];
G.ClipBox[info.dc,box,TRUE];
};
JTranslate: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
tx,ty: REAL; [tx,ty]←GetPoint[frame];
G.Translate[info.dc,tx,ty];
};
JScale: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
sx,sy: REAL; [sx,sy]←GetPoint[frame];
G.Scale[info.dc,sx,sy];
};
JRotate: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
a: REAL ← J.PopReal[frame.opstk];
G.Rotate[info.dc,a];
};
JSixPoint: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
f1,f2,f3,t1,t2,t3,df1,df2,dt1,dt2: Vec;
adet: REAL;
xx,xy,yx,yy,tx,ty: REAL;
t3←GetVec[frame];
t2←GetVec[frame];
t1←GetVec[frame];
f3←GetVec[frame];
f2←GetVec[frame];
f1←GetVec[frame];
[[tx,ty]]←Vector.Sub[t1,f1];
dt1←Vector.Sub[t2,t1];
df1←Vector.Sub[f2,f1];
dt2←Vector.Sub[t3,t1];
df2←Vector.Sub[f3,f1];
adet𡤁.0/Vector.Cross[df1,df2];
xx←(dt1.x*df2.y-dt2.x*df1.y)*adet;
xy←(df1.x*dt2.x-df2.x*dt1.x)*adet;
yx←(dt1.y*df2.y-dt2.y*df1.y)*adet;
yy←(df1.x*dt2.y-df2.x*dt1.y)*adet;
G.Translate[info.dc,tx,ty];
G.Concat[info.dc,xx,xy,yx,yy]
};
JConcat: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
xx,xy,yx,yy: REAL;
yy ← J.PopReal[frame.opstk];
yx ← J.PopReal[frame.opstk];
xy ← J.PopReal[frame.opstk];
xx ← J.PopReal[frame.opstk];
G.Concat[info.dc,xx,xy,yx,yy];
};
JGetPos: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x,y: REAL; [x,y]←G.GetCP[info.dc];
PutPoint[frame,x,y];
};
JMoveTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x,y: REAL; [x,y]←GetPoint[frame];
G.MoveTo[info.dc,x,y];
};
JDrawTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawTo;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawTo: PROC [info: Info] = {
x,y: REAL; [x,y]←GetPoint[info.frame];
G.DrawTo[info.dc,x,y];
-- UpdateViewer[info.frame];
};
JRelMoveTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x,y: REAL; [x,y]←GetPoint[frame];
G.MoveTo[info.dc,x,y,TRUE];
};
JRelDrawTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintRelDrawTo;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintRelDrawTo: PROC [info: Info] = {
x,y: REAL; [x,y]←GetPoint[info.frame];
G.DrawTo[info.dc,x,y,TRUE];
-- UpdateViewer[info.frame];
};
JDrawBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawBox;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawBox: PROC [info: Info] = {
box: G.Box ← GetBox[info.frame];
G.DrawBox[info.dc,box];
-- UpdateViewer[info.frame];
};
JCover: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintCover;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintCover: PROC [info: Info] = {
G.DrawBox[info.dc,G.GetBounds[info.dc]];
-- UpdateViewer[info.frame];
};
JSetInvert: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
[] ← G.SetPaintMode[info.dc, invert];
};
JSetColor: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
i: LONG INTEGER ← J.PopInteger[frame.opstk];
G.SetColor[info.dc, LOOPHOLE[i]];
};
JSetFat: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
b: BOOLEAN ← J.PopBoolean[frame.opstk];
[] ← G.SetFat[info.dc,b];
};
JSetOpaque: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
b: BOOLEAN ← J.PopBoolean[frame.opstk];
[] ← G.SetPaintMode[info.dc,IF b THEN opaque ELSE transparent];
};
JErase: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
mark: G.Mark ← G.Save[info.dc];
G.SetColor[info.dc, G.white];
JCover[frame];
G.Restore[info.dc,mark];
};
JGetTouch: PROCEDURE [frame: Frame] = {
mx,my: REAL;
[mx,my] ← RealViewerMouse[frame,TRUE];
PutPoint[frame,mx,my];
};
JGetMouse: PROCEDURE [frame: Frame] = {
mx,my: REAL;
[mx,my] ← RealViewerMouse[frame,FALSE];
PutPoint[frame,mx,my];
};
MouseToUser: PROCEDURE[frame: Frame, x,y:INTEGER] = {
PutPoint[frame,x,y];
};
JSetFont: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
PopString[info];
info.font ← G.MakeFont[Rope.FromRefText[info.text]];
};
JGetYMode: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
mode: E.YMode ← E.GetYMode[info.dc];
J.PushInteger[frame.opstk, IF mode=topDown THEN 1 ELSE 0];
};
JSetYMode: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
mode: LONG INTEGER ← J.PopInteger[frame.opstk];
E.SetYMode[info.dc,IF mode>0 THEN topDown ELSE bottomUp];
};
JDrawChar: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawChar;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawChar: PROC [info: Info] = { OPEN info;
PopString[info];
IF text.length>0 THEN text.length ← 1;
G.DrawText[self: dc, text: text, font: font];
-- UpdateViewer[frame];
};
JDrawText: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawText;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawText: PROC [info: Info] = { OPEN info;
PopString[info];
G.DrawText[self: dc, text: text, font: font];
-- UpdateViewer[info.frame];
};
JCharBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
PopString[info];
IF info.text.length>0 THEN info.text.length ← 1;
PushTextBox[frame,info.text];
};
JTextBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
PopString[info];
PushTextBox[frame,info.text];
};
JCharWidth: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
PopString[info];
IF info.text.length>0 THEN info.text.length ← 1;
PushTextWidth[frame,info.text];
};
JTextWidth: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
PopString[info];
PushTextWidth[frame,info.text];
};
PushTextBox: PROCEDURE[frame: Frame, text: REF READONLY TEXT] = {
info: Info ← GetInfo[frame];
xmin,xmax,ymin,ymax: REAL;
[xmin: xmin, ymin: ymin, xmax: xmax, ymax: ymax] ← G.TextBox[info.font,info.text];
J.PushReal[frame.opstk,xmin];
J.PushReal[frame.opstk,ymin];
J.PushReal[frame.opstk,xmax];
J.PushReal[frame.opstk,ymax];
};
PushTextWidth: PROCEDURE[frame: Frame, text: REF READONLY TEXT] = {
info: Info ← GetInfo[frame];
xw,yw: REAL;
[xw: xw, yw: yw] ← G.TextWidth[info.font,info.text];
J.PushReal[frame.opstk,xw];
J.PushReal[frame.opstk,yw];
};
JFontBox: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
xmin,xmax,ymin,ymax: REAL;
[xmin: xmin, ymin: ymin, xmax: xmax, ymax: ymax] ← G.FontBox[info.font];
J.PushReal[frame.opstk,xmin];
J.PushReal[frame.opstk,ymin];
J.PushReal[frame.opstk,xmax];
J.PushReal[frame.opstk,ymax];
};
PutBox: PROC[frame: Frame, b: G.Box] = {
PutPoint[frame,b.xmin,b.ymin];
PutPoint[frame,b.xmax,b.ymax];
};
GetBox: PROC [frame: Frame] RETURNS[G.Box] = {
b: G.Box;
[b.xmax,b.ymax] ← GetPoint[frame];
[b.xmin,b.ymin] ← GetPoint[frame];
RETURN[b];
};
JStartBoxing: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
E.BeginBox[info.dc];
};
JStopBoxing: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
b: G.Box ← E.EndBox[info.dc];
PutBox[frame,b];
};
JPushBox: PROCEDURE [frame: Frame] = {
b: G.Box ← GetBox[frame];
-- G.PushClipBox[dc,b];
-- **** temporarily removed ****
};
JPopBox: PROCEDURE [frame: Frame] = {
-- G.PopClipBox[dc];
-- **** temporarily removed ****
};
JVisible: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
J.PushBoolean[frame.opstk,G.Visible[info.dc]];
};
JLineTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x,y: REAL; [x,y]←GetPoint[frame];
G.LineTo[info.dc,x,y];
};
JCurveTo: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x1,y1,x2,y2,x3,y3: REAL;
[x3,y3]←GetPoint[frame];
[x2,y2]←GetPoint[frame];
[x1,y1]←GetPoint[frame];
G.CurveTo[info.dc,x1,y1,x2,y2,x3,y3];
};
JRectangle: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
x0,y0,x1,y1: REAL;
[x1,y1]←GetPoint[frame];
[x0,y0]←GetPoint[frame];
G.Rectangle[info.dc,x0,y0,x1,y1];
};
JClose: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
G.Close[info.dc];
};
JDrawArea: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawArea;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawArea: PROC [info: Info] = {
G.DrawArea[info.dc];
-- UpdateViewer[info.frame];
};
JDrawEOArea: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawEOArea;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawEOArea: PROC [info: Info] = {
G.DrawArea[info.dc,TRUE];
-- UpdateViewer[info.frame];
};
JDrawPath: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintDrawPath;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintDrawPath: PROC [info: Info] = {
width: REAL ← J.PopReal[info.frame.opstk];
G.DrawPath[info.dc,width];
-- UpdateViewer[info.frame];
};
JKnot: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
y: REAL ← J.PopReal[frame.opstk];
x: REAL ← J.PopReal[frame.opstk];
Spline.Knot[info.spline,x,y];
};
JSpline: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
Spline.Enter[info.spline,info.dc,FALSE];
};
JCSpline: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
Spline.Enter[info.spline,info.dc,TRUE];
};
bmw: CARDINAL = 250;
bmh: CARDINAL = 200;
JBitmap: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
info.proc ← PaintBitmap;
ViewerOps.PaintViewer[viewer: info.viewer, hint: client, whatChanged: info, clearClient: FALSE];
};
PaintBitmap: PROC [info: Info] = {
E.DrawBitmap[info.dc,info.bitmap,bmw,bmh,0,0,0,bmh];
-- UpdateViewer[info.frame];
};
JSetTarget: PROC [frame: Frame] = {
info: Info ← GetInfo[frame];
b: BOOLEAN ← J.PopBoolean[frame.opstk];
E.SetTargetBitmap[info.dc,IF b THEN info.bitmap ELSE NIL];
};
JCaptureButtons: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
InputFocus.CaptureButtons[info.viewer.class.notify, info.viewer.tipTable, info.viewer];
info.capturedButtons ← TRUE;
Cursors.SetCursor[textPointer] };
JReleaseButtons: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
InputFocus.ReleaseButtons[];
WindowManager.RestoreCursor;
info.capturedButtons ← FALSE };
JScreenCoords: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
y: REAL ← J.PopReal[frame.opstk];
x: REAL ← J.PopReal[frame.opstk];
[x, y] ← Graphics.UserToWorld[info.dc, x, y]; -- get screen coordinates
J.PushReal[frame.opstk,x];
J.PushReal[frame.opstk,y];
};
JUserCoords: PROCEDURE [frame: Frame] = {
info: Info ← GetInfo[frame];
y: REAL ← J.PopReal[frame.opstk];
x: REAL ← J.PopReal[frame.opstk];
[x, y] ← Graphics.WorldToUser[info.dc, x, y]; -- get user coordinates
J.PushReal[frame.opstk,x];
J.PushReal[frame.opstk,y];
};
-- Initialization starts here
Init: PROC = {
frame: Frame ← J.defaultFrame;
[] ← JaMTypeScript.SetMouseProc[MouseToUser];
ViewerOps.RegisterViewerClass[$JaMGraphics, jamGraphicsClass];
J.RegisterExplicit[frame,".initdc"L,InitDC];
J.RegisterExplicit[frame,".pushdc"L,PushDC];
J.RegisterExplicit[frame,".popdc"L,PopDC];
J.RegisterExplicit[frame,".setview"L,JSetVw];
J.RegisterExplicit[frame,".translate"L,JTranslate];
J.RegisterExplicit[frame,".scale"L,JScale];
J.RegisterExplicit[frame,".rotate"L,JRotate];
J.RegisterExplicit[frame,".sixpoint"L,JSixPoint];
J.RegisterExplicit[frame,".concat"L,JConcat];
J.RegisterExplicit[frame,".getpos"L,JGetPos];
J.RegisterExplicit[frame,".moveto"L,JMoveTo];
J.RegisterExplicit[frame,".rmoveto"L,JRelMoveTo];
J.RegisterExplicit[frame,".drawto"L,JDrawTo];
J.RegisterExplicit[frame,".rdrawto"L,JRelDrawTo];
J.RegisterExplicit[frame,".drawbox"L,JDrawBox];
J.RegisterExplicit[frame,".cover"L,JCover];
J.RegisterExplicit[frame,".setinvert"L,JSetInvert];
J.RegisterExplicit[frame,".setcolor"L,JSetColor];
J.RegisterExplicit[frame,".setfat"L,JSetFat];
J.RegisterExplicit[frame,".setopaque"L,JSetOpaque];
J.RegisterExplicit[frame,".touch"L,JGetTouch];
J.RegisterExplicit[frame,".mouse"L,JGetMouse];
J.RegisterExplicit[frame,".erase"L,JErase];
J.RegisterExplicit[frame,".setfont"L,JSetFont];
J.RegisterExplicit[frame,".drawchar"L,JDrawChar];
J.RegisterExplicit[frame,".drawtext"L,JDrawText];
J.RegisterExplicit[frame,".charbox"L,JCharBox];
J.RegisterExplicit[frame,".textbox"L,JTextBox];
J.RegisterExplicit[frame,".charwidth"L,JCharWidth];
J.RegisterExplicit[frame,".textwidth"L,JTextWidth];
J.RegisterExplicit[frame,".fontbox"L,JFontBox];
J.RegisterExplicit[frame,".initboxer"L,JStartBoxing];
J.RegisterExplicit[frame,".stopboxer"L,JStopBoxing];
J.RegisterExplicit[frame,".pushbox"L,JPushBox];
J.RegisterExplicit[frame,".popbox"L,JPopBox];
J.RegisterExplicit[frame,".visible"L,JVisible];
J.RegisterExplicit[frame,".cliparea"L,JClipArea];
J.RegisterExplicit[frame,".clipbox"L,JClipBox];
J.RegisterExplicit[frame,".lineto"L,JLineTo];
J.RegisterExplicit[frame,".curveto"L,JCurveTo];
J.RegisterExplicit[frame,".rect"L,JRectangle];
J.RegisterExplicit[frame,".close"L,JClose];
J.RegisterExplicit[frame,".drawarea"L,JDrawArea];
J.RegisterExplicit[frame,".draweoarea"L,JDrawEOArea];
J.RegisterExplicit[frame,".drawpath"L,JDrawPath];
J.RegisterExplicit[frame,".knot"L,JKnot];
J.RegisterExplicit[frame,".spline"L,JSpline];
J.RegisterExplicit[frame,".cspline"L,JCSpline];
J.RegisterExplicit[frame,".bitmap"L,JBitmap];
J.RegisterExplicit[frame,".clipeoarea"L,JClipEOArea];
J.RegisterExplicit[frame,".clipxarea"L,JClipXArea];
J.RegisterExplicit[frame,".clipxbox"L,JClipXBox];
J.RegisterExplicit[frame,".getymode"L,JGetYMode];
J.RegisterExplicit[frame,".setymode"L,JSetYMode];
J.RegisterExplicit[frame,".settarget"L,JSetTarget];
J.RegisterExplicit[frame,".destroyviewer"L,JDestroyViewer];
J.RegisterExplicit[frame,".getviewer"L,JGetViewer];
J.RegisterExplicit[frame,".screencoords"L,JScreenCoords];
J.RegisterExplicit[frame,".usercoords"L,JUserCoords];
J.RegisterExplicit[frame,".capturebuttons"L,JCaptureButtons];
J.RegisterExplicit[frame,".releasebuttons"L,JReleaseButtons];
J.RegisterExplicit[frame,".reloadTIP"L,JReloadTIP];
};
Init;
}.