ViewerMenusImpl.mesa; Written by S. McGregor
Edited by McGregor on July 14, 1983 1:22 pm
Last Edited by: Maxwell, June 6, 1983 12:11 pm
Last Edited by: Pausch, August 12, 1983 12:21 pm
DIRECTORY
Menus USING [Menu, MenuEntryTrigger],
MessageWindow USING [Append, Blink],
ViewerClasses USING [Column, NotifyProc, Viewer],
ViewerOps,
ViewerSpecs,
WindowManager USING [colorDisplayOn];
ViewerMenusImpl: CEDAR PROGRAM
IMPORTS MessageWindow, ViewerOps, WindowManager
SHARES ViewerClasses, ViewerOps =
BEGIN
windowDestroyMenu: Menu =
[name: "windowDestroyMenu",
beginsActive: TRUE,
breakBefore: FALSE,
breakAfter: FALSE,
notify: ViewerMenuNotifier,
entries: LIST[
["Destroy", FALSE, "Destroy", LIST [
[LIST[all],LIST[$DestroyViewer],"Destroy the Viewer", "", NIL,NIL,NIL]
] ];
windowGuardedDestroyMenu: Menu =
[name: "windowGuardedDestroyMenu",
beginsActive: TRUE,
breakBefore: FALSE,
breakAfter: FALSE,
notify: ViewerMenuNotifier,
entries: LIST[
["Destroy", TRUE, "Destroy", LIST [
[LIST[all],LIST[$DestroyViewer],"Destroy the Viewer", "Edits will be discarded...", NIL,NIL,NIL]
] ];
windowMovementMenu: Menu =
[name: windowMovementMenu",
beginsActive: TRUE,
breakBefore: FALSE,
breakAfter: FALSE,
notify: ViewerMenuNotifier,
entries: LIST[
["Adjust", FALSE, "Adjust", LIST[
[LIST[all], LIST[$AdjustViewerSticky], "Adjust Viewer Size", "", NIL, NIL, NIL]
] ],
["Top", FALSE, "Top", LIST[
[LIST[all], LIST[$MoveViewerToTop], "Move Viewer To Top Of Column", "", NIL, NIL, NIL]
] ],
["Left", FALSE, "—", LIST[
[LIST[shiftleftup, shiftmiddleupup, shiftrightup],
LIST[$MoveViewerToLeftColumn, $GrowViewer], "Move To Left Column and Grow ", "", NIL, NIL, NIL],
[LIST[all], LIST[$MoveViewerToLeft], "Move Viewer To Left Column", "", NIL, NIL, NIL]
] ],
["Right", FALSE, "—", LIST[
[LIST[shiftleftup, shiftmiddleupup, shiftrightup],
LIST[$MoveViewerToRightColumn, $GrowViewer], "Move To Right Column and Grow ", "", NIL, NIL, NIL],
[LIST[all], LIST[$MoveViewerToRight], "Move Viewer To Right Column", "", NIL, NIL, NIL]
] ]
]
];
windowColorMenu: Menu =
[name: "windowColorMenu",
beginsActive: FALSE,
breakBefore: FALSE,
breakAfter: FALSE,
notify: ViewerMenuNotifier,
entries: LIST[
["Color", FALSE, "Color", LIST[
[LIST[shiftleftup, shiftmiddleupup, shiftrightup],
LIST[$MoveViewerToColorColumnAndGrow], "Move To Color Display and Grow ", "", NIL, NIL, NIL],
[LIST[all], LIST[$MoveViewerToColorColumn], "Move Viewer To Color Display", "", NIL, NIL, NIL]
] ]
]
];
windowSizeMenu: Menu =
[name: "windowSizeMenu",
beginsActive: FALSE,
breakBefore: FALSE,
breakAfter: FALSE,
notify: ViewerMenuNotifier,
entries: LIST[
["Grow", FALSE, "Grow", LIST[
[LIST[all],LIST[$GrowViewer],"Grow the Viewer", "", NIL,NIL,NIL]
] ],
["Close", FALSE, "Close", LIST[
[LIST[all],LIST[$CloseViewer],"Close the Viewer", "", NIL,NIL,NIL]
] ],
]
];
ViewerMenuNotifier: ViewerClasses.NotifyProc = {
[self: Viewer, input: LIST OF REF ANY]
FOR current: LIST OF REF ANY ← input, current.rest UNTIL current = NIL DO
SELECT current.first FROM
$DestroyViewer => Destroy[self];
$CloseViewer => ViewerOps.CloseViewer[self];
$GrowViewer => ViewerOps.GrowViewer[self];
$MoveViewerToTop => ViewerOps.TopViewer[self];
$AdjustViewer => ViewerOps.Adjust[self];
$MoveViewerToLeftColumn => ViewerOps.ChangeColumn[self, left];
$MoveViewerToRightColumn => ViewerOps.ChangeColumn[self, right];
$MoveViewerToColorColumn => MoveToColorColumn[viewer: self, doGrow: FALSE];
$MoveViewerToColorColumnAndGrow => MoveToColorColumn[viewer: self, doGrow:TRUE];
ENDCASE => ERROR;
ENDLOOP;
};
Destroy: PROC[viewer: ViewerClasses.Viewer] = {
IF ~viewer.inhibitDestroy THEN ViewerOps.DestroyViewer[viewer]
ELSE {MessageWindow.Append["Sorry, this viewer can not be destroyed.", TRUE];
MessageWindow.Blink[]};
};
MoveToColorColumn: PRIVATE PROC[viewer: ViewerClasses.Viewer, doGrow: BOOLFALSE] = {
IF WindowManager.colorDisplayOn THEN {
ViewerOps.ChangeColumn[viewer, color];
IF doGrow THEN ViewerOps.GrowViewer[viewer]}
ELSE BEGIN
MessageWindow.Append["Sorry, the color display is not available.", TRUE];
MessageWindow.Blink[];
END;
};
END.