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
Last Edited by: Wyatt, September 30, 1983 3:48 pm
DIRECTORY
Rules,
Imager USING [black, Color, IntegerMaskRectangle, SetColor],
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:
BOOL ←
TRUE]
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
x: REF Imager.Color = NARROW[self.data];
IF x = NIL THEN RETURN;
Imager.SetColor[context, x^];
Imager.IntegerMaskRectangle[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.