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, June 5, 1985 12:20:19 pm PDT
DIRECTORY
CDColors, CDPrivate, CD;
-- ChipNDale interface defining low layer color handling.
-- (semi-public)
CDColorsImpl:
CEDAR
PROGRAM
EXPORTS CDColors =
BEGIN
DisplayType:
TYPE = CDColors.DisplayType;
-- {bw, bit1, bit2, bit4, bit8, bit9};
DisplayMode:
TYPE = CDColors.DisplayMode;
-- {normal, pushedOut};
Brick:
TYPE = CDColors.Brick;
-- ARRAY [0..4) OF CARDINAL;
ColorTable:
TYPE = CDColors.ColorTable;
-- ARRAY CD.Layer 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.Layer,
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 pushedOut 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 {
IF table=globalColors
THEN {
IF display=bit1 THEN display ← bw --color 1 bit/pixel gets same stipples as bw
ELSE IF display=bit9 THEN display ← bit8; --9 bit/pixel uses same stipples as 8 bit/pixel
};
IF table[display]=
NIL
THEN {
table[display] ← NEW[ColorTableSet ← ALL[NIL]];
table[display][normal] ← NEW[ColorTable ← ALL[fullBrick]];
table[display][pushedOut] ← NEW[ColorTable ← ALL[fullBrick]];
};
};
dTable ← table[display];
dTable[mode][lev] ← brick;
IF mode=normal THEN dTable[pushedOut][lev] ← brick;
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: pushedOut];
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: pushedOut];
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: pushedOut];
END.