--Interface to low level display stuff
--M. Stone February 17, 1983 3:10 pm
-- Last Edited by: Pier, February 13, 1984 3:22:14 pm PST

DIRECTORY
 Graphics USING[ PaintMode, Color, Context],
 Font USING[FONT],
 PointDefs USING[ScrPt];

ScreenDefs: DEFINITIONS =
BEGIN OPEN PointDefs;

Context: TYPE = Graphics.Context;

BlockPtr: TYPE = REF Block;
Block: TYPE = RECORD [ --mostly for source blocks like tokens
 base: LONG POINTER,
 raster: CARDINAL,
 lx,ty,w,h: INTEGER--since usually source, not really a screen point
 ];

GreyType: TYPE = Graphics.Color;
JunctionType: TYPE = {round,square,angled};
EndType: TYPE = RECORD
 [type: SELECT xx: * FROM
  round,flat => NULL,
  angled => [From,To: ScrPt], --clipping edge, keep on right
  ENDCASE
 ];

--routines exported by ScreenFns
ScreenFns: PROGRAM;
SetViewport: PROCEDURE [width,height: INTEGER];
ClearScreen: PROCEDURE[dc: Context]; 
SetClipEdges: PROCEDURE [tl,br: ScrPt];
--return a box clipped to screen
ClipToScreen: PROCEDURE [tl,br: ScrPt] RETURNS [ScrPt, ScrPt];
ClipPointToScreen: PUBLIC PROC [pt: ScrPt] RETURNS [ScrPt];
ResetClipEdges: PROCEDURE;--changes clipping edges of current screen to size at init

--clip options are because someone higher up might do some culling
ClipperState: TYPE = {clip,cull,inside};
PrimeClipper: PROC [tl,br: PointDefs.ScrPt] RETURNS [ClipperState];
ClipOn: PROCEDURE; --resets PrimeClipper

Function: TYPE = Graphics.PaintMode;
SetFunction: PROCEDURE [fnc: Function];

--All of these assume the current Display state
SetLineParms: PROCEDURE [width: INTEGER, grey: GreyType];
StartChain: PROCEDURE[pt: ScrPt, dc: Context];
NextChainPoint: PROCEDURE[dx,dy: INTEGER, dc: Context];
EndChain: PROCEDURE[dc: Context];
BLTBlockInScreen: PROCEDURE
 [src: BlockPtr,
 tl: PointDefs.ScrPt,
 fnc: Function,
 dc: Context
 ];

DrawChar: PROCEDURE
 [font: Font.FONT,
 origin: PointDefs.ScrPt,
 char: CHAR,
 dc: Context
 ];

MoveScreenBox: PROCEDURE[tl,br: ScrPt,dx,dy: INTEGER];
EraseBox: PUBLIC PROCEDURE[tl,br: ScrPt, dc: Context];
InvertBox: PUBLIC PROCEDURE[tl,br: ScrPt, dc: Context];

--for areas.
SetFillParms: PROCEDURE [grey: GreyType];
--for scan conversion. Gets scanline and offset in CGDevice coordinates
--routine in Encoding calls these paired procedures in order, and does translate for NextScanLine

StartArea: PUBLIC PROCEDURE[y: INTEGER, dc: Context] RETURNS[yScan,xOffset: INTEGER];
--These parameters are in CGDevice coordinates
NextScanLine
: PROCEDURE[y,lx,rx: INTEGER, dc: Context];

--These parameters are in ScrPt coordinates
BoxFill
: PROCEDURE[tl,br: ScrPt, dc: Context];

GetGridParameters: PROCEDURE
RETURNS[center: ScrPt,hgridlx,hgridrx,vgridty,vgridby,gridt: INTEGER];
BltVGrid: PROCEDURE[lx: INTEGER, dc: Context];
BltHGrid: PROCEDURE[ty: INTEGER, dc: Context];
END.