RulesImpl.mesa; written by Bill Paxton
Edited by McGregor on July 21, 1983 2:51 pm
Last Edited by: Maxwell, January 3, 1983 12:28 pm
DIRECTORY
Rules,
Imager,
ViewerClasses,
ViewerOps;
RulesImpl: CEDAR PROGRAM
IMPORTS Imager, ViewerOps
EXPORTS Rules
SHARES ViewerOps =
BEGIN OPEN ViewerClasses, Rules;
Create: PUBLIC PROC [info: ViewerRec, color: Imager.Color ← Imager.black, paint: BOOLTRUE]
RETURNS [rule: Rule] = BEGIN
IF info.parent=NIL THEN RETURN;
info.data ← NEW[Imager.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 Imager;
x: REF Color = NARROW[self.data];
IF x = NIL THEN RETURN;
SetColor[context, x^];
MaskIntRectangle[context, [0, 0, self.cw, self.ch]];
END;
RuleSet: PRIVATE SetProc = BEGIN
WITH data SELECT FROM
x: REF Imager.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.