DIRECTORY HerculesGraphics, Graphics, GraphicsOps, ViewerClasses, GraphicsToPress, Rope, Terminal, VFonts, IO, Atom, Real, MessageWindow, GraphicsToPressPrivate, SirPress; HerculesGraphicsImpl: PROGRAM IMPORTS Graphics, GraphicsOps, GraphicsToPress, VFonts, Rope, MessageWindow, GraphicsToPressPrivate, SirPress, Real EXPORTS HerculesGraphics = BEGIN bm: GraphicsOps.BitmapRef _ GraphicsOps.NewBitmap [width: 1024, height: 808]; screenContext: Graphics.Context _ GraphicsOps.NewContextFromBitmap [bm]; pressContext: Graphics.Context; dc: Graphics.Context _ screenContext; -- dc = screenContext except when making a press file, when dc = pressContext. screenwidth: CARDINAL _ 1024; screenheight: CARDINAL _ 808; viewerChanged: PUBLIC BOOLEAN _ TRUE; halfX, halfY: REAL _ 404.0; -- 404 = 808 (default screenheight) / 2 cursorOffsetY: PUBLIC REAL _ 0; currentFont: PUBLIC Rope.ROPE _ "Helvetica"; currentPointSize: PUBLIC INT _ 16; currentBold: PUBLIC BOOL _ FALSE; currentItalic: PUBLIC BOOL _ FALSE; myfont: PUBLIC Graphics.FontRef _ VFonts.GraphicsFont[VFonts.EstablishFont[currentFont, currentPointSize]]; fontHeight : PUBLIC INTEGER _ VFonts.FontHeight[VFonts.EstablishFont[currentFont,currentPointSize]]; bitmap: GraphicsOps.BitmapRef = GraphicsOps.NewBitmap[16, 16]; sirPressHandle: SirPress.PressHandle; DcGetsPressContext: PUBLIC PROC[filename: Rope.ROPE] = { pressContext _ GraphicsToPress.NewContext[filename]; sirPressHandle _ GraphicsToPressPrivate.SirPressHandle[pressContext]; [] _ Graphics.SetPaintMode[pressContext, opaque]; [] _ Graphics.SetFat[pressContext, TRUE]; dc _ pressContext}; DcGetsScreenContext: PUBLIC PROC = {GraphicsToPress.Close[pressContext]; dc _ screenContext}; SetPaintMode: PUBLIC PROC [mode: Graphics.PaintMode] = { [] _ Graphics.SetPaintMode[screenContext, mode] }; GetNewFont: PUBLIC PROC = { myfont _ VFonts.GraphicsFont[VFonts.EstablishFont[currentFont, currentPointSize, currentBold, currentItalic]]; fontHeight _ VFonts.FontHeight[VFonts.EstablishFont[currentFont,currentPointSize]]}; DrawPattern: PUBLIC PROC[p:Terminal.BWCursorBitmap, x, y: REAL] = {LOOPHOLE[bitmap.base, LONG POINTER TO Terminal.BWCursorBitmap]^ _ p; Graphics.SetCP[dc, x, y]; GraphicsOps.DrawBitmap[dc, bitmap, 16, 16]; viewerChanged _ TRUE}; Hylite: PUBLIC PROC[x,y: INTEGER, d:INTEGER] = {SELECT d FROM 0 => {Graphics.DrawBox[dc, [x - 5, y+4, x+4, y+5]]; Graphics.DrawBox[dc, [x+4, y-4, x+5, y+5]]; Graphics.DrawBox[dc, [x-4, y-5, x+5, y-4]]; Graphics.DrawBox[dc, [x-5, y-5, x-4, y+4]]}; 1 => {Graphics.DrawBox[dc, [x - 1, y - 5, x + 1, y + 5]]; Graphics.DrawBox[dc, [x - 5, y - 1, x + 5, y + 1]]}; > 1 => {p: Graphics.Path _ Graphics.NewPath[]; Graphics.MoveTo[p, x - 1, y]; Graphics.LineTo[p, x-5, y+4]; Graphics.LineTo[p, x-4, y+5]; Graphics.LineTo[p, x, y+1]; Graphics.LineTo[p, x+4, y+5]; Graphics.LineTo[p, x+5, y+4]; Graphics.LineTo[p, x+1,y]; Graphics.LineTo[p, x+5,y-4]; Graphics.LineTo[p, x+4,y-5]; Graphics.LineTo[p, x,y-1]; Graphics.LineTo[p, x-4,y-5]; Graphics.LineTo[p, x-5,y-4]; Graphics.DrawArea[dc, p]}; ENDCASE => ERROR; viewerChanged _ TRUE}; RopeBox: PUBLIC PROC[myRope: Rope.ROPE] RETURNS [REAL, REAL, REAL, REAL] = { xmin, ymin, xmax, ymax: REAL; [xmin, ymin, xmax, ymax] _ Graphics.RopeBox [myfont, myRope]; RETURN[xmin, ymin, xmax, ymax] }; CharWidth: PUBLIC PROC[char: CHAR] RETURNS [REAL, REAL] = { xw, yw: REAL; [xw, yw] _ Graphics.CharWidth [myfont, char]; RETURN[xw, yw] }; DrawChar: PUBLIC PROC [char: CHAR, x, y: REAL] = { Graphics.SetCP[dc, x, y]; Graphics.DrawChar [dc, char, myfont]; viewerChanged _ TRUE}; DrawRope: PUBLIC PROC [myRope: Rope.ROPE, x, y: REAL] = { Graphics.SetCP[dc, x, y]; Graphics.DrawRope [self: dc, rope: myRope, font: myfont]; viewerChanged _ TRUE}; PaintMe: PUBLIC ViewerClasses.PaintProc -- self: Viewer, -- context: Graphics.Context, -- whatChanged: REF ANY, -- clear: BOOL = TRUSTED {box: Graphics.Box = Graphics.GetBounds[context]; halfX _ (box.xmax - box.xmin) / 2.0; halfY _ (box.ymax - box.ymin) / 2.0; cursorOffsetY _ halfY - (screenheight/2); IF self.iconic THEN RETURN; [ ] _ Graphics.SetPaintMode[self: context, mode: opaque]; Graphics.SetCP[self: context, x: 0, y: halfY ]; GraphicsOps.DrawBitmap [self: context, bitmap: bm, w: screenwidth, h: screenheight, x: 0, y: 0, xorigin: 0, yorigin: screenheight/2] }; Whiten: PUBLIC PROC = { IF dc = screenContext THEN {[] _ Graphics.SetPaintMode[dc, opaque]; Graphics.SetColor[dc, Graphics.white]; Graphics.DrawBox[dc, [0, 0, 1200, 808]]; Graphics.SetColor[dc, Graphics.black]; [] _ Graphics.SetPaintMode[dc, invert]; } }; DrawPoint: PUBLIC PROC[x, y: REAL] = {IF dc = screenContext THEN {p: Graphics.Path _ Graphics.NewPath[]; Graphics.MoveTo[p, x - 1, y - 1]; Graphics.LineTo[p, x - 1, y + 1]; Graphics.LineTo[p, x + 1, y + 1]; Graphics.LineTo[p, x + 1, y - 1]; Graphics.DrawArea[dc, p]; viewerChanged _ TRUE} }; DrawEdge: PUBLIC PROC[x1, y1, x2, y2: REAL] = {p: Graphics.Path _ Graphics.NewPath[]; Graphics.MoveTo[p, x1, y1]; Graphics.LineTo[p, x2, y2]; Graphics.DrawStroke[dc, p, 1, FALSE, round]; viewerChanged _ TRUE}; DrawArc: PUBLIC PROC[x1, y1, x2, y2, x3, y3, x4, y4: REAL] = {p: Graphics.Path _ Graphics.NewPath[]; Graphics.MoveTo[p, x1, y1]; Graphics.CurveTo[p, x2, y2, x3, y3, x4, y4]; Graphics.DrawStroke[dc, p, 1, FALSE, round]; viewerChanged _ TRUE}; DrawString: PUBLIC PROC[x3, y3: REAL, myRope: Rope.ROPE, stringFont: Graphics.FontRef _ myfont, fontName: Rope.ROPE, fontSize: INT, bold, italic: BOOL] = {Ord: PROC[b: BOOL] RETURNS [INT] = {IF b THEN RETURN[1] ELSE RETURN[0]}; IF dc = screenContext THEN {Graphics.SetCP[dc, x3, y3]; IF stringFont = NIL THEN stringFont _ VFonts.GraphicsFont[VFonts.EstablishFont[fontName, fontSize, bold, italic]]; Graphics.DrawRope[self: dc, rope: myRope, font: stringFont]; RETURN}; -- dc = pressContext SirPress.SetFont[sirPressHandle, fontName, fontSize, Ord[italic] + 2 * Ord[bold]]; SirPress.PutText[sirPressHandle, myRope, Real.RoundLI[x3 * SirPress.pt], Real.RoundLI[y3 * SirPress.pt], 1]}; Error: PUBLIC PROC[item1, item2, item3, item4, item5: Rope.ROPE _ NIL] = {Blink[item1, item2, item3, item4, item5]; ERROR}; Blink: PUBLIC PROC[item1, item2, item3, item4, item5: Rope.ROPE _ NIL] = {errMsg: Rope.ROPE _ Rope.Cat[item1, item2, item3, item4, item5, "\n"]; -- the last rope concatenated is a carriage return MessageWindow.Clear[]; MessageWindow.Append[errMsg]; MessageWindow.Blink[]}; p:Graphics.Path _ Graphics.NewPath[]; pathEmpty: BOOL; colorStack: LIST OF Graphics.Color _ NIL; color: Graphics.Color _ Graphics.black; endsStack: LIST OF Graphics.StrokeEnds _ NIL; ends: Graphics.StrokeEnds _ round; widthStack: LIST OF REAL _ NIL; width: REAL _ 0; BeginStroke: PUBLIC PROC = {Graphics.FlushPath[p]; pathEmpty _ TRUE}; EdgeStroke: PUBLIC PROC[x1, y1, x2, y2: REAL] = {IF pathEmpty THEN {Graphics.MoveTo[p, x1, y1]; pathEmpty _ FALSE}; Graphics.LineTo[p, x2, y2]}; ArcStroke: PUBLIC PROC[x1, y1, x2, y2, x3, y3, x4, y4: REAL] = {IF pathEmpty THEN {Graphics.MoveTo[p, x1, y1]; pathEmpty _ FALSE}; Graphics.CurveTo[p, x2, y2, x3, y3, x4, y4]}; DrawStroke: PUBLIC PROC = {Graphics.DrawStroke[dc, p, width, FALSE, ends]}; DrawArea: PUBLIC PROC = {Graphics.DrawArea[dc, p, FALSE]}; PushColor: PUBLIC PROC[newColor: Graphics.Color] = {colorStack _ CONS[color, colorStack]; color _ newColor; Graphics.SetColor[dc, color]}; PopColor: PUBLIC PROC = {color _ colorStack.first; Graphics.SetColor[dc, color]; colorStack _ colorStack.rest}; PushEnds: PUBLIC PROC[newEnds: Graphics.StrokeEnds] = {endsStack _ CONS[ends, endsStack]; ends _ newEnds}; PopEnds: PUBLIC PROC = {ends _ endsStack.first; endsStack _ endsStack.rest}; PushWidth: PUBLIC PROC[r: REAL] = {widthStack _ CONS[width, widthStack]; width _ r}; PopWidth: PUBLIC PROC = {width _ widthStack.first; widthStack _ widthStack.rest}; END. ôHerculesGraphicsImpl (ex JunoGraphicsImpl) Coded July 1982 by Donna M. Auguste & Greg Nelson These are procedures which directly affect the Juno bitmap. Last Edited by: Gnelson, June 27, 1983 3:51 pm Last Edited by: Stolfi, February 13, 1984 8:26 pm Edited on January 26, 1984 8:00 pm, by Stolfi changes to: PushColor (changed parameter to Graphics.Color), PushEnds (changed parameter to Graphics.StrokeEnds), LookUpColor, LookUpEnds (moved to JunoAlgebraImplB) , DcGetsPressContext (added SetFat) Edited on February 7, 1984 7:30 pm, by Stolfi -- Renamed HerculesGraphicsImpl.mesa changes to: Edited on February 10, 1984 0:08 am, by Stolfi changes to: Error (new), DrawPoint (parameters are REAL), NewGraphicsPoint (deleted - not used?) Ê’˜Jšœ+™+Jšœ2™2Jšœ<™˜RJš Ÿ œœœœœ#˜XJšŸœœœB˜WJšœ˜™-Jšœ Ïr œ œ œ  œ   œ  œ  œ œ™É—J™™-Jšœ&™&Jšœ™J™—™.Jšœ  œ  œ œ™`——…—" *’