CDSaveButton.mesa
Copyright c 1985 by Xerox Corporation. All rights reserved.
Compile CDSaveButton; run CDSaveButton; AddSaveDesignButtonToCDViewers
Last Edited by Curry, April 10, 1985 6:00:29 pm PST
CDSaveButton:
CEDAR
PROGRAM
IMPORTS CDIO, CDSequencer, CDViewer, Menus, ViewerOps, TerminalIO =
BEGIN
AddSaveDesignButtonToCDViewers: PROC = {
isDesign: BOOL;
design: CD.Design;
rect: CD.DesignRect;
Checker: ViewerOps.EnumProc = {
-- [v: Viewer] RETURNS [BOOL ← TRUE]
IF v.class.flavor#$Chipndale THEN RETURN[TRUE];
[isDesign, design, rect] ← CDViewer.DesignOf[v];
IF NOT isDesign THEN RETURN[TRUE];
IF v.menu=NIL THEN ViewerOps.SetMenu[v, Menus.CreateMenu[] ];
IF Menus.FindEntry[v.menu, "SaveDesign"]=
NIL
THEN
Menus.AppendMenuEntry[
menu: v.menu,
entry: Menus.CreateEntry[
name: "SaveDesign",
proc: SaveDesignMenuProc,
clientData: design,
guarded: TRUE]];
RETURN[TRUE]};
CDSequencer.ImplementCommand[a: $SaveDesign, p: SaveDesign];
ViewerOps.EnumerateViewers[Checker] };
SaveDesignMenuProc: Menus.ClickProc
PROC [parent: REF ANY, clientData: REF ANY ← NIL, mouseButton: MouseButton ← red, shift, control: BOOL ← FALSE]
=
BEGIN
ENABLE TerminalIO.UserAbort =>
GOTO userAbort;
viewer: ViewerClasses.Viewer ← NARROW[parent];
design: CD.Design ← NARROW[clientData];
comm: CDSequencer.Command ←
NEW[CDSequencer.CommandRec ← [design: design, a: $SaveDesign]];
CDSequencer.ExecuteCommand[comm: comm];
EXITS
userAbort => {TerminalIO.WriteRope["discarded\n"]}
END;
SaveDesign:
PROC [comm: CDSequencer.Command] = {
name:
IO.
ROPE ←
CDIO.MakeName
[comm.design.name, "dale", CDIO.GetWorkingDirectory[comm.design]];
TerminalIO.WriteRope["Saving: "];
TerminalIO.WriteRope[name];
TerminalIO.WriteRope[" . . . "];
[ ] ← CDIO.WriteDesign[comm.design, name];
TerminalIO.WriteRope["done\n"];
};
AddSaveDesignButtonToCDViewers[];
END.