CDTipEtcImpl.mesa (part of Chipndale)
Copyright © 1983, 1984 by Xerox Corporation. All rights reserved.
by Christian Jacobi August 11, 1983 11:32 am
last edited by Christian Jacobi October 24, 1984 3:56:44 pm PDT
DIRECTORY
CD,
CDTipEtc,
CDValue,
Icons,
Rope,
RuntimeError,
TerminalIO,
TIPUser;
CDTipEtcImpl: CEDAR PROGRAM
IMPORTS CDValue, Icons, RuntimeError, TerminalIO, TIPUser
EXPORTS CDTipEtc =
BEGIN
-- tip tables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetTipTable: PUBLIC PROC [onto: REF, tipTable: Rope.ROPE] =
BEGIN
ENABLE UNWIND => NULL;
tTable: TIPUser.TIPTable ← NIL;
tTable ← TIPUser.InstantiateNewTIPTable[tipTable !
TIPUser.InvalidTable => {
TerminalIO.WriteRope["Tiptable not installed; "];
TerminalIO.WriteRope[errorMsg];
TerminalIO.WriteLn[];
GOTO NotDone
}
];
CDValue.Store[boundTo: onto, key: $TipTable, value: tTable];
EXITS
NotDone => NULL
END;
GetTipTable: PUBLIC PROC [for: REF] RETURNS [TIPUser.TIPTable] =
BEGIN
WITH CDValue.Fetch[boundTo: for, key: $TipTable, propagation: global] SELECT FROM
ttr: TIPUser.TIPTable => RETURN [ttr];
ENDCASE => RETURN [NIL];
END;
-- Icons ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SetIcon: PUBLIC PROC [onto: REF, file: Rope.ROPE, n: NAT] =
--onto: Design, Technology or global
--only new viewers will get the new icon
BEGIN
icon: REF Icons.IconFlavor = NEW[Icons.IconFlavor←tool];
icon^ ← Icons.NewIconFromFile[file, n ! RuntimeError.UNCAUGHT => GOTO notDone];
CDValue.Store[boundTo: onto, key: $Icon, value: icon];
EXITS notDone => TerminalIO.WriteRope["**Icon not initialized\n"];
END;
GetIcon: PUBLIC PROC [for: REF] RETURNS [Icons.IconFlavor] =
--for: Design, Technology or global
BEGIN
WITH CDValue.Fetch[boundTo: for, key: $Icon, propagation: global] SELECT FROM
ip: REF Icons.IconFlavor => RETURN [ip^];
ENDCASE => RETURN [Icons.IconFlavor[unInit]]
END;
SetPanelIcon: PUBLIC PROC [onto: REF, file: Rope.ROPE, n: NAT] =
--onto: Design, Technology or global
--only new viewers will get the new icon
BEGIN
icon: REF Icons.IconFlavor = NEW[Icons.IconFlavor←tool];
icon^ ← Icons.NewIconFromFile[file, n ! RuntimeError.UNCAUGHT => GOTO notDone];
CDValue.Store[boundTo: onto, key: $PanelIcon, value: icon];
EXITS notDone => TerminalIO.WriteRope["**Panel-Icon not initialized\n"];
END;
GetPanelIcon: PUBLIC PROC [for: REF] RETURNS [Icons.IconFlavor] =
--for: Design, Technology or global
BEGIN
WITH CDValue.Fetch[boundTo: for, key: $PanelIcon, propagation: global] SELECT FROM
ip: REF Icons.IconFlavor => RETURN [ip^];
ENDCASE => RETURN [Icons.IconFlavor[unInit]]
END;
-- init ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Init: PROC [] =
BEGIN
panelIcon: REF Icons.IconFlavor = NEW[Icons.IconFlavor←tool];
designIcon: REF Icons.IconFlavor = NEW[Icons.IconFlavor←tool];
CDValue.EnregisterKey[key: $TipTable];
CDValue.EnregisterKey[key: $Icon];
designIcon^ ← Icons.NewIconFromFile["Chipndale.icons", 0 ! RuntimeError.UNCAUGHT => CONTINUE];
CDValue.Store[boundTo: NIL, key: $Icon, value: designIcon];
CDValue.EnregisterKey[key: $PanelIcon];
panelIcon^ ← Icons.NewIconFromFile["Chipndale.icons", 1 ! RuntimeError.UNCAUGHT => CONTINUE];
CDValue.Store[boundTo: NIL, key: $PanelIcon, value: panelIcon];
END;
Init[];
END.