CDColorsImpl.mesa (Viewer definitions for Chipndale)
Copyright © 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi September 19, 1984 6:00:17 pm PDT
last edited by Christian Jacobi October 22, 1984 2:49:39 pm PDT
DIRECTORY
CDColors, CDPrivate, CD;
-- chipndale interface defining low level color handling.
-- (semi-public)
CDColorsImpl:
CEDAR
PROGRAM
EXPORTS CDColors =
BEGIN
DisplayType:
TYPE = CDColors.DisplayType;
-- {bw, bit4, bit8};
DisplayMode:
TYPE = CDColors.DisplayMode;
-- {normal, back, grey};
Brick:
TYPE = CDColors.Brick;
-- ARRAY [0..4) OF CARDINAL;
ColorTable:
TYPE = CDColors.ColorTable;
-- ARRAY CD.Level OF REF Brick;
ColorTableSet:
TYPE = CDColors.ColorTableSet;
-- ARRAY DisplayMode OF REF ColorTable;
ColorDefinition:
TYPE = CDColors.ColorDefinition;
-- ARRAY DisplayType OF REF ColorTableSet;
globalColors: PUBLIC REF ColorDefinition ← NEW[ColorDefinition←ALL[NIL]];
emptyBrick: REF Brick = NEW[Brick←ALL[0]];
fullBrick: REF Brick = NEW[Brick←ALL[LAST[CARDINAL]]];
DefineColor:
PUBLIC
PROC[
lev: CD.Level,
brick: REF Brick ← NIL, -- do no more change the values
display: DisplayType ← bw,
mode: DisplayMode ← normal,
table: REF ColorDefinition ← NIL --NIL uses the global table
] =
--Defining a brick with mode normal also clears the back and the grey brick.
--A NIL brick makes a reasonable default.
--The procedure may exchange bricks if they have the same values.
BEGIN
dTable: REF ColorTableSet;
IF table=NIL THEN table ← globalColors;
IF brick=NIL THEN brick ← fullBrick
ELSE IF brick^=fullBrick^ THEN brick ← fullBrick -- reuse fullbrick; reduce swapping
ELSE IF brick^=emptyBrick^ THEN brick ← emptyBrick;
IF table[display]=
NIL
THEN {
table[display] ← NEW[ColorTableSet←ALL[NIL]];
table[display][normal] ← NEW[ColorTable←ALL[fullBrick]];
table[display][back] ← NEW[ColorTable←ALL[fullBrick]];
table[display][grey] ← NEW[ColorTable←ALL[emptyBrick]];
};
dTable ← table[display];
dTable[mode][lev] ← brick;
IF mode=normal
THEN {
dTable[back][lev] ← brick;
dTable[grey][lev] ← emptyBrick;
}
END;
DefineColor[lev: 0, display: bw];
DefineColor[lev: 0, display: bit4];
DefineColor[lev: 0, display: bit8];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[257,0,0,0]], display: bw];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[257,0,0,0]], display: bw, mode: back];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[0,10,0,11*256]], display: bit4];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[0,10,0,11*256]], display: bit4, mode: back];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[0,1,256,0]], display: bit8];
DefineColor[lev: CD.backGround, brick: NEW[Brick←[0,1,256,0]], display: bit8, mode: back];
END.