RulesImpl.mesa
Copyright Ó 1985, 1986, 1991 by Xerox Corporation. All rights reserved.
Edited by McGregor on June 2, 1982 1:55 pm
Last Edited by: Maxwell, January 3, 1983 12:28 pm
Bier, November 30, 1988 12:54:29 pm PST
Doug Wyatt, March 29, 1985 5:20:01 pm PST
DIRECTORY
Imager USING [black, Color, MaskBox, SetColor],
Rules USING [Rule],
ViewerClasses USING [PaintProc, SetProc, ViewerClass, ViewerClassRec, ViewerRec],
ViewerOps USING [CreateViewer, DestroyViewer, PaintViewer, RegisterViewerClass];
RulesImpl: CEDAR PROGRAM
IMPORTS Imager, ViewerOps
EXPORTS Rules
SHARES ViewerOps
= BEGIN OPEN ViewerClasses, Rules;
Create:
PUBLIC
PROC [info: ViewerRec, color: Imager.Color ¬
NIL, paint:
BOOL ¬
TRUE]
RETURNS [rule: Rule] = {
IF info.parent=NIL THEN RETURN;
info.data ¬ color;
info.border ¬ FALSE; -- we did promise uniform color
RETURN[ViewerOps.CreateViewer[flavor: $Rule, info: info, paint: paint]];
};
Destroy: PUBLIC PROC [rule: Rule] = {ViewerOps.DestroyViewer[rule]};
SetColor:
PUBLIC
PROC [rule: Rule, color: Imager.Color, paint:
BOOL ¬
TRUE] = {
rule.class.set[rule, color, paint];
};
RulePaint: PaintProc = {
WITH self.data
SELECT
FROM
color: Imager.Color => Imager.SetColor[context, color];
ENDCASE => Imager.SetColor[context, Imager.black];
Imager.MaskBox[context, [0, 0, self.cw, self.ch]];
};
RuleSet: SetProc = {
WITH data
SELECT
FROM
color: Imager.Color => self.data ¬ color;
ENDCASE;
IF finalise THEN ViewerOps.PaintViewer[self, client --, FALSE ??? --];
};
Initialization
ruleClass: ViewerClasses.ViewerClass ¬
NEW[ViewerClasses.ViewerClassRec ¬ [
paint: RulePaint,
set: RuleSet
]];
ViewerOps.RegisterViewerClass[$Rule, ruleClass]; -- plug in to Viewers
END.