-- Compiler GriffinMain/n
-- m.stone November 14, 1980 1:44 PM
-- Tiberi December 12, 1979 12:00 PM
-- Last Edited by: Stone, November 14, 1983 3:11 pm
DIRECTORY
GriffinDefs: FROM "GriffinDefs",
PointDefs: FROM "PointDefs",
RefreshDefs: FROM "RefreshDefs",
MenuDefs: FROM "MenuDefs",
GriffinMenusInterface,
Rope USING[ROPE, Equal];
GriffinMain: PROGRAM
IMPORTS GriffinDefs, MenuDefs, RefreshDefs, Rope
EXPORTS GriffinDefs, GriffinMenusInterface =
BEGIN OPEN GriffinDefs, PointDefs,RefreshDefs;
X: CARDINAL = PointDefs.X;
Y: CARDINAL = PointDefs.Y;
ROPE: TYPE=Rope.ROPE;
topMenu: PUBLIC MenuDefs.MenuHandle←NIL;
messageMenu: MenuDefs.MenuHandle←NIL;
messageItem: MenuDefs.MenuItemHandle←NIL;
ToggleShowMenu: PUBLIC MenuDefs.MenuProc =
BEGIN OPEN MenuDefs, GriffinDefs;
UpdateMenu: PROCEDURE[menu: MenuHandle, show: BOOLEAN] =
BEGIN
IF show THEN BEGIN
ShowMenu[menu];
END
ELSE BEGIN
HideMenu[menu];
END;
END;
UpdateItem: PROCEDURE[item: MenuItemHandle] =
BEGIN
IF IsSelected[item] THEN Deselect[item] ELSE Select[item];
END;
UpdateBoth: PROCEDURE[menu: MenuHandle, item: MenuItemHandle] =
BEGIN
UpdateItem[item];
UpdateMenu[menu, IsSelected[item]];
END;
string: ROPE = MenuString[item];
SELECT TRUE FROM
Rope.Equal[string, "Edit"] =>
BEGIN
IF IsSelected[item] THEN BEGIN
item: MenuItemHandle;
item ← FindItemByString[editMenu,"Spline Type"];
IF IsSelected[item] THEN BugItem[item];
END;
UpdateItem[item];
UpdateMenu[editMenu, IsSelected[item]];
UpdateMenu[shapeMenu, IsSelected[item]];
END;
Rope.Equal[string, "Objects"] =>
UpdateBoth[objectMenu, item];
Rope.Equal[string, "Style"] =>
BEGIN
IF IsSelected[item] THEN BEGIN
item: MenuItemHandle;
item ← FindItemByString[GriffinDefs.styleMenu,"Text Style"];
IF IsSelected[item] THEN BugItem[item];
item ← FindItemByString[GriffinDefs.styleMenu,"Color Style"];
IF IsSelected[item] THEN BugItem[item];
item ← FindItemByString[GriffinDefs.styleMenu,"Shape Style"];
IF IsSelected[item] THEN BugItem[item];
END;
UpdateBoth[styleMenu, item];
END;
Rope.Equal[string, "Files"] =>
UpdateBoth[filesMenu, item];
Rope.Equal[string, "Transform"] =>
UpdateBoth[xformMenu, item];
Rope.Equal[string, "Overlap"] =>
UpdateBoth[overlapMenu, item];
Rope.Equal[string, "View"] =>
UpdateBoth[viewMenu, item];
ENDCASE=> ERROR;
RestoreScreen[];
END;
FindItemByString: PROCEDURE[menu: MenuDefs.MenuHandle,string: ROPE] RETURNS [mitem: MenuDefs.MenuItemHandle]=
BEGIN OPEN MenuDefs;
IsItem: MenuProc = BEGIN
IF Rope.Equal[MenuString[item],string] THEN mitem ← item;
END;
ForAllMenuItems[menu,IsItem];
END;
UserMessage: PUBLIC SIGNAL [string: ROPE] = CODE;
HideMessage: MenuDefs.MenuProc = {
MenuDefs.HideMenu[messageMenu];
RestoreScreen[];
};
ShowUserMessage: PUBLIC PROCEDURE[string: ROPE] =
BEGIN
MenuDefs.SetMenuString[messageItem, string];
MenuDefs.ShowMenu[messageMenu];
MenuDefs.HighlightMenuItem[messageItem];
RestoreScreen[];
END;
--Procedure so can catch all init errors
StartMainMenus: PUBLIC PROCEDURE =
BEGIN
topMenu ← MenuDefs.CreateMenu[horizontal, [100,30], NIL];
[]←MenuDefs.AddMenuItem[topMenu,"Edit",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"Objects",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"Style",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"Files",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"Transform",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"Overlap",ToggleShowMenu];
[]←MenuDefs.AddMenuItem[topMenu,"View",ToggleShowMenu];
messageMenu ← MenuDefs.CreateMenu[vertical, [150, 400], NIL];
messageItem ← MenuDefs.AddMenuItem[messageMenu, "Aborted.", HideMessage];
topMenu.visible ← TRUE;
END;
END.