ColorDisplayImpl.mesa
Copyright © 1984, 1985 by Xerox Corporation. All rights reserved.
Created from old ColorDisplay by Mik Lamming and Ken Pier
Last Edited by: Nickell, June 7, 1984 1:12:42 pm PDT
Last Edited by: Beach, August 17, 1984 5:24:14 pm PDT
Last Edited by: Pier, November 19, 1984 3:10:48 pm PST
Doug Wyatt, January 23, 1985 3:01:09 pm PST
Beach, March 3, 1985 4:01:07 pm PST
DIRECTORY
ColorDisplay,
InterminalExtras USING [ColorDisplayOnLeft, SwitchSideOfColorDisplay],
List USING [Car, Cdr, Cons],
MonitorToolDefs USING [StartMonitor],
Rope USING [Equal, ROPE],
Terminal USING [ColorMode, Current, GetColorMode],
UserProfile USING [Number, Token],
ViewerClasses USING [Viewer],
ViewerOps USING [ChangeColumn, CloseViewer, ComputeColumn, EnumerateViewers, EnumProc, OpenIcon],
WindowManager USING [colorDisplayOn, ScreenPos, StartColorViewers, StopColorViewers];
ColorDisplayImpl: CEDAR PROGRAM
IMPORTS InterminalExtras, List, MonitorToolDefs, Rope, Terminal, UserProfile, ViewerOps, WindowManager
EXPORTS ColorDisplay
~ BEGIN
bppLast and sideLast are examined only when the color display is off. This lets the ColorDisplay package know where to default them to when the color display is turned on again. NOTE: Every call to the ColorDisplay package will cause these values to be updated with the actual state of the machine, if it is on.
bppLast: PUBLIC CARDINAL ← 8;
onLeftLast: PUBLIC BOOLEANTRUE;
monitorTypeLast: PUBLIC Rope.ROPE ← "640x480";
DefaultBpp, Bpp: PUBLIC PROC RETURNS [bpp: CARDINAL] ~ {
Has side effect of remembering bpp
IF WindowManager.colorDisplayOn THEN {
colorMode: Terminal.ColorMode ← Terminal.GetColorMode[Terminal.Current[]];
bpp ← (IF colorMode.full THEN 24 ELSE colorMode.bitsPerPixelChannelA);
}
ELSE bpp ← bppLast;
bppLast ← bpp;      --Remember the setting of the screen
};
DefaultOnLeft, OnLeft: PUBLIC PROC RETURNS [onLeft: BOOLEAN] ~ {
onLeft ← IF WindowManager.colorDisplayOn
THEN InterminalExtras.ColorDisplayOnLeft[]
ELSE onLeftLast;
onLeftLast ← onLeft;
};
DefaultOn: PUBLIC PROC RETURNS [BOOLEAN] ~ {
RETURN[WindowManager.colorDisplayOn];
};
DefaultMonitorType: PUBLIC PROC RETURNS [Rope.ROPE] ~ {
RETURN[monitorTypeLast];
};
SetColorDisplayStatus: PUBLIC PROC [on: BOOLEAN ← DefaultOn[],
onLeft: BOOLEAN ← DefaultOnLeft[], bpp: CARDINAL ← DefaultBpp[],
monitorType: Rope.ROPE ← DefaultMonitorType[]] ~ {
SELECT TRUE FROM
Check for nothing changed
(on=WindowManager.colorDisplayOn AND bpp=Bpp[] AND monitorType=monitorTypeLast AND onLeft=OnLeft[]) => RETURN;
Check for just switching sides.
(on=WindowManager.colorDisplayOn AND bpp=Bpp[] AND monitorType=monitorTypeLast AND on) => {
InterminalExtras.SwitchSideOfColorDisplay[];
onLeftLast ← OnLeft[];
};
Otherwise, we need to check the whole ball of wax
ENDCASE => TRUSTED {
colorViewerList, colorIconList: LIST OF REF ANYNIL; --Really only viewers, tho
ListColorViewers: PROC ~ TRUSTED {   --Constructs a list of the color viewers
EnumColorViewers: ViewerOps.EnumProc ~ TRUSTED {
IF v.column=color THEN
IF v.iconic THEN colorIconList ← List.Cons[v,colorIconList]
ELSE colorViewerList ← List.Cons[v,colorViewerList];
};
ViewerOps.EnumerateViewers[enum: EnumColorViewers];
};
ReopenColorViewers: PROC ~ TRUSTED {  --Reopen the listed color viewers
reopenList: LIST OF REF ANY ← colorViewerList;
Reopen the viewers that were OPEN on the color display
WHILE reopenList#NIL DO
v: ViewerClasses.Viewer ← NARROW[List.Car[reopenList]];
reopenList ← NARROW[List.Cdr[reopenList]];
ViewerOps.CloseViewer[v];
ViewerOps.ChangeColumn[v, color];
ViewerOps.OpenIcon[icon: v, paint: FALSE];
ENDLOOP;
ViewerOps.ComputeColumn[color];
Reset the icons that WOULD have been opened on the color display back there
reopenList ← colorIconList;
WHILE reopenList#NIL DO
v: ViewerClasses.Viewer ← NARROW[List.Car[reopenList]];
reopenList ← NARROW[List.Cdr[reopenList]];
ViewerOps.ChangeColumn[v, color];
ENDLOOP;
};
side: WindowManager.ScreenPos ← IF onLeft THEN left ELSE right;
monitorTypeLast ← monitorType;  --Back up the given parameters
onLeftLast ← onLeft;
bppLast ← bpp;
ListColorViewers[];
WindowManager.StopColorViewers[];
IF on THEN {
SELECT TRUE FROM
Rope.Equal[s1: monitorType, s2: "640x480", case: FALSE] =>
MonitorToolDefs.StartMonitor[screenWidth: 640, screenHeight: 480,
refreshRate: 30, bitsPerPixel: bpp, hBlankTime: 9.7, vBlankTime: 1250,
pos: side];
Rope.Equal[s1: monitorType, s2: "1024x768", case: FALSE] =>
MonitorToolDefs.StartMonitor[screenWidth: 1024, screenHeight: 768,
refreshRate: 30, bitsPerPixel: bpp, hBlankTime: 6, vBlankTime: 850,
pos: side];
ENDCASE => WindowManager.StartColorViewers[screenPos: side, bitsPerPixel: bpp];
ReopenColorViewers[];
};
};
};
GetColorDisplayStatus: PUBLIC PROC RETURNS [on, onLeft: BOOLEAN, bpp: CARDINAL, monitorType: Rope.ROPE] ~ {
on ← WindowManager.colorDisplayOn;
onLeft ← OnLeft[];
bpp ← Bpp[];
monitorType ← monitorTypeLast;
};
GetColorDisplayProfile: PUBLIC PROC RETURNS [on, onLeft: BOOLEAN, bpp: CARDINAL, monitorType: Rope.ROPE] ~ {
RightOrLeft: PROC RETURNS[rl: Rope.ROPE] ~ INLINE {
rl ← IF onLeftLast THEN "left" ELSE "right"};
tBpp: INTEGER;   --Temporary bits per pixel
on ← WindowManager.colorDisplayOn;
SELECT tBpp ← UserProfile.Number["ColorDisplay.BitsPerPoint", Bpp[]] FROM
1,2,4,8,24 => bpp ← tBpp;
ENDCASE => bpp ← Bpp[];
onLeft ← Rope.Equal[UserProfile.Token["ColorDisplay.Side", RightOrLeft[]], "left", FALSE];
monitorType ← UserProfile.Token["ColorDisplay.Type", monitorTypeLast];
};
Init: PROC[] RETURNS[] ~ {
Read the user profile to establish the initial back settings...
[,onLeftLast, bppLast, monitorTypeLast] ← GetColorDisplayProfile[];
};
Init[];
END.