RulesImpl.mesa;
Edited by McGregor on June 2, 1982 1:55 pm
Last Edited by: Maxwell, January 3, 1983 12:28 pm
DIRECTORY
Rules,
Graphics,
ViewerClasses,
ViewerOps;
RulesImpl: CEDAR PROGRAM
IMPORTS Graphics, ViewerOps
EXPORTS Rules
SHARES ViewerOps =
BEGIN OPEN ViewerClasses, Rules;
Create:
PUBLIC
PROC [info: ViewerRec, color: Graphics.Color ← Graphics.black, paint:
BOOL ←
TRUE]
RETURNS [rule: Rule] = BEGIN
IF info.parent=NIL THEN RETURN;
info.data ← NEW[Graphics.Color ← color];
info.border ← FALSE; -- we did promise uniform color
RETURN[ViewerOps.CreateViewer[flavor: $Rule, info: info, paint: paint]];
END;
RulePaint:
PRIVATE PaintProc =
BEGIN
OPEN Graphics;
x: REF Color = NARROW[self.data];
IF x = NIL THEN RETURN;
SetColor[context, x^];
DrawBox[context, [0, 0, self.cw, self.ch]];
END;
RuleSet:
PRIVATE SetProc =
BEGIN
WITH data
SELECT
FROM
x: REF Graphics.Color => self.data ← data;
ENDCASE => ERROR;
IF finalise THEN ViewerOps.PaintViewer[self, client, FALSE];
END;
ruleClass: ViewerClasses.ViewerClass ←
NEW[ViewerClasses.ViewerClassRec ← [
paint: RulePaint,
set: RuleSet
]];
ViewerOps.RegisterViewerClass[$Rule, ruleClass]; -- plug in to Viewers
END.