ViewerSpecsImpl.mesa
Copyright Ó 1985, 1986, 1989, 1991 by Xerox Corporation. All rights reserved.
Edited by McGregor on June 9, 1982 4:55 pm
Last Edited by: Maxwell, December 17, 1982 9:58 am
Michael Plass, December 2, 1991 5:14 pm PST
Bier, January 29, 1989 2:44:36 pm PST
Doug Wyatt, April 15, 1985 0:29:55 am PST
Willie-s, October 9, 1991 5:56 pm PDT
DIRECTORY
ViewerPrivate USING [Screen],
ViewerSpecs USING [iconHeight, iconWidth];
ViewerSpecsImpl: CEDAR PROGRAM
EXPORTS ViewerPrivate, ViewerSpecs
~ BEGIN OPEN ViewerSpecs;
Screen: TYPE ~ ViewerPrivate.Screen;
nColumns: PUBLIC NAT ¬ 4; -- Several scattered data structures depend on this, so don't change it dynamically.
bwScreenWidth: PUBLIC NAT ¬ 0;
requestedBWScreenWidth: NAT ¬ 0;
bwScreenHeight: PUBLIC NAT ¬ 0;
requestedBWScreenHeight: NAT ¬ 0;
colorScreenWidth: PUBLIC NAT ¬ 0;
colorScreenHeight: PUBLIC NAT ¬ 0;
windowBorderSize: PUBLIC NAT ¬ 0;
captionHeight: PUBLIC NAT ¬ 0;
menuHeight: PUBLIC NAT ¬ 0;
requestedMenuHeight: NAT ¬ 0;
menuBarHeight: PUBLIC NAT ¬ 0;
scrollBarW: PUBLIC NAT ¬ 0;
messageWindowHeight: PUBLIC NAT ¬ 0;
openLeftLeftX: PUBLIC NAT ¬ 0;
openLeftWidth: PUBLIC NAT ¬ 0;
requestedOpenLeftWidth: NAT ¬ 0;
openRightLeftX: PUBLIC NAT ¬ 0;
openRightWidth: PUBLIC NAT ¬ 0;
openTopY: PUBLIC NAT ¬ 0;
openBottomY: PUBLIC NAT ¬ 0;
requestedOpenBottomY: NAT ¬ 0;
iconLeftX: PUBLIC NAT ¬ 0;
iconAreaWidth: NAT ¬ 0;
iconRightX: PUBLIC NAT ¬ 0;
iconBottomY: PUBLIC NAT ¬ 0;
iconAreaHeight: NAT ¬ 0;
iconTopY: PUBLIC NAT ¬ 0;
iconSpacing: PUBLIC NAT ¬ 0;
iconRowHeight: PUBLIC NAT ¬ 0;
iconRows: PUBLIC NAT ¬ 0;
iconColumnWidth: PUBLIC NAT ¬ 0;
iconColumns: PUBLIC NAT ¬ 0;
SetDefaults: PROC ~ {
requestedBWScreenWidth ¬ bwScreenWidth ¬ 1024;
requestedBWScreenHeight ¬ bwScreenHeight ¬ 808;
windowBorderSize ¬ 1;
requestedMenuHeight ¬ menuHeight ¬ 12;
menuBarHeight ¬ 1;
scrollBarW ¬ 12;
messageWindowHeight ¬ 16;
openLeftLeftX ¬ 0;
requestedOpenLeftWidth ¬ openLeftWidth ¬ 600;
requestedOpenBottomY ¬ openBottomY ¬ iconHeight+4;
iconSpacing ¬ 4; -- should be multiple of 4 for grey background alignment
iconLeftX ¬ <<4>> 0; -- should be multiple of 4 for grey background alignment
iconBottomY ¬ 0;
};
ComputeDependencies: PROC ~ {
ComputeVerticalDependencies[];
ComputeIconDemands[];
ComputeHorizontalDependencies[];
ComputeIconDependencies[];
};
ComputeVerticalDependencies: PROC ~ {
Inputs:
menuHeight, messageWindowHeight, requestedBWScreenHeight, requestedOpenBottomY, iconHeight, iconSpacing, iconBottomY
Outputs:
iconRowHeight, captionHeight, bwScreenHeight, openTopY, openBottomY, iconTopY
Invariants:
captionHeight = menuHeight;
iconRowHeight = iconHeight+iconSpacing;
openTopY >= openBottomY
openTopY - iconBottomY >= iconRowHeight; -- allow for at least one row of icons
bwScreenHeight = openTopY + messageWindowHeight;
Preferences:
openBottomY = requestedOpenBottomY
bwScreenHeight = requestedBWScreenHeight
Preferences are satisfiable if:
requestedBWScreenHeight >= requestedOpenBottomY + messageWindowHeight, and
requestedBWScreenHeight-messageWindowHeight >= iconBottomY + iconRowHeight
Otherwise:
relax the constraint on bwScreenHeight
captionHeight ¬ menuHeight;
iconRowHeight ¬ iconHeight+iconSpacing;
IF requestedBWScreenHeight >= requestedOpenBottomY + messageWindowHeight THEN
bwScreenHeight ¬ requestedBWScreenHeight
ELSE
bwScreenHeight ¬ requestedOpenBottomY + messageWindowHeight;
IF bwScreenHeight < iconBottomY + iconRowHeight + messageWindowHeight
THEN bwScreenHeight ¬ iconBottomY + iconRowHeight + messageWindowHeight;
openBottomY ¬ requestedOpenBottomY;
openTopY ¬ bwScreenHeight-messageWindowHeight;
};
ComputeIconDemands: PROC ~ {
Inputs:
openTopY, iconBottomY, iconRowHeight, iconWidth, iconSpacing
Outputs:
iconRows, iconAreaHeight, iconTopY, iconColumnWidth
Invariants:
iconRows >= 1
iconRows ¬ (openTopY-iconBottomY)/iconRowHeight;
iconAreaHeight ¬ iconRows*iconRowHeight;
iconTopY ¬ iconBottomY+iconAreaHeight;
iconColumnWidth ¬ iconWidth+iconSpacing;
};
ComputeHorizontalDependencies: PROC ~ {
Inputs:
openLeftLeftX, requestedOpenLeftWidth, requestedBWScreenWidth, iconColumnWidth, iconLeftX
Outputs:
openLeftWidth, bwScreenWidth, openRightLeftX, openRightWidth
Invariants:
openLeftWidth >= 0; openRightWidth >= 0; openLeftLeftX >= 0;
openRightLeftX = openLeftLeftX+openLeftWidth;
bwScreenWidth = openLeftLeftX + openLeftWidth+ openRightWidth;
bwScreenWidth >= iconColumnWidth + iconLeftX
Preferences:
bwScreenWidth = requestedBWScreenWidth
openLeftWidth = requestedOpenLeftWidth
Preferences are satisfiable if:
requestedBWScreenWidth >= iconColumnWidth + iconLeftX
requestedBWScreenWidth >= requestedOpenLeftWidth + openLeftLeftX, and
Otherwise:
relax the constraint on requestedBWScreenWidth to satisfy the icon constraint,
then, if there is still a problem, relax the constraint on requestedOpenLeftWidth, letting openLeftWidth = (requestedBWScreenWidth-openLeftLeftX)/2;
IF requestedBWScreenWidth >= iconColumnWidth + iconLeftX THEN
bwScreenWidth ¬ requestedBWScreenWidth
ELSE bwScreenWidth ¬ iconColumnWidth + iconLeftX;
IF bwScreenWidth >= requestedOpenLeftWidth + openLeftLeftX
THEN openLeftWidth ¬ requestedOpenLeftWidth
ELSE {
IF bwScreenWidth < openLeftLeftX THEN bwScreenWidth ¬ openLeftLeftX;
openLeftWidth ¬ (bwScreenWidth-openLeftLeftX)/2;
};
openRightLeftX ¬ openLeftLeftX+openLeftWidth;
openRightWidth ¬ bwScreenWidth-openRightLeftX;
};
ComputeIconDependencies: PROC ~ {
Inputs:
iconLeftX, bwScreenWidth, iconColumnWidth, iconSpacing
Outputs:
iconColumns, iconAreaWidth, iconRightX
Invariants:
iconColumns >= 1
iconColumns ¬ (bwScreenWidth-iconLeftX+iconSpacing)/iconColumnWidth;
iconAreaWidth ¬ iconColumns*iconColumnWidth-iconSpacing;
iconRightX ¬ iconLeftX+iconAreaWidth;
};
SetOpenLeftWidth: PUBLIC PROC [leftColumnWidth: NAT, screen: Screen ¬ main] ~ {
requestedOpenLeftWidth ¬ openLeftWidth ¬ MIN[leftColumnWidth, bwScreenWidth];
ComputeDependencies[];
};
SetOpenBottomY: PUBLIC PROC [bottomY: NAT, screen: Screen ¬ main] ~ {
requestedOpenBottomY ¬ openBottomY ¬ MIN[bottomY, openTopY];
ComputeDependencies[];
};
SetMenuHeight: PUBLIC PROC [height: NAT, screen: Screen ¬ main] ~ {
requestedMenuHeight ¬ menuHeight ¬ MIN[height, 200];
ComputeDependencies[];
};
SetScrollBarWidth: PUBLIC PROC [width: NAT, screen: Screen ¬ main] ~ {
scrollBarW ¬ MIN[width, 200];
ComputeDependencies[];
};
SetWindowBorderSize: PUBLIC PROC [border: NAT, screen: Screen ¬ main] ~ {
windowBorderSize ¬ MIN[border, 200];
ComputeDependencies[];
};
SetBWScreenSize: PUBLIC PROC [w, h: NAT] ~ {
requestedBWScreenWidth ¬ bwScreenWidth ¬ w;
requestedBWScreenHeight ¬ bwScreenHeight ¬ h;
ComputeDependencies[];
};
SetColorScreenSize: PUBLIC PROC [w, h: NAT] ~ {
colorScreenWidth ¬ w; colorScreenHeight ¬ h;
ComputeDependencies[];
};
SetScreenSize: PUBLIC PROC [w, h: NAT, screen: Screen ¬ main] ~ {
requestedBWScreenWidth ¬ bwScreenWidth ¬ w;
requestedBWScreenHeight ¬ bwScreenHeight ¬ h;
ComputeDependencies[];
};
SetDefaults[];
ComputeDependencies[];
END.