GriffinMenusInterfaceImpl.mesa
Lets a program click Griffin Menus
Maureen Stone April 16, 1984 4:12:11 pm PST
DIRECTORY
MenuDefs USING [MenuItemHandle, MenuHandle, MenuProc, ForAllMenus, ForAllMenuItems],
GriffinMenusInterface,
PointDefs USING [ObjToScr,ObjPt, ScrPt, X, Y],
ScreenDefs USING [ClipPointToScreen],
ObjectDefs USING [StartObject,PlotOneObject,TokenType,Object, ObjectType, AddToken],
Rope USING [ROPE, Equal];
GriffinMenusInterfaceImpl: PROGRAM
IMPORTS MenuDefs, Rope, ObjectDefs, ScreenDefs, PointDefs
EXPORTS GriffinMenusInterface = {
MenuItemFromRope: PUBLIC PROC [rope: Rope.ROPE] RETURNS [foundItem: MenuDefs.MenuItemHandle] = {
found: BOOLEAN ← FALSE;
searchItems: MenuDefs.MenuProc = {
IF ~found THEN {
found ← Rope.Equal[rope, item.string, FALSE];
IF found THEN foundItem ← item;
};
};
searchMenus: PROCEDURE [menu: MenuDefs.MenuHandle] = {
IF ~found THEN MenuDefs.ForAllMenuItems[menu, searchItems];
};
MenuDefs.ForAllMenus[searchMenus];
};
PlaceScreenCP: PUBLIC PROCEDURE[pt: PointDefs.ScrPt] = {
ObjectDefs.AddToken[ScreenDefs.ClipPointToScreen[pt], CP];
};
PlaceObjectCP: PUBLIC PROCEDURE[pt: PointDefs.ObjPt] = {
scrPt: PointDefs.ScrPt ← PointDefs.ObjToScr[pt];
obj: REF ObjectDefs.Object[token] ← NARROW[ObjectDefs.StartObject[token]];
obj.tl ← [scrPt[PointDefs.X]-4,scrPt[PointDefs.Y]-4];
obj.br ← [scrPt[PointDefs.X]+4,scrPt[PointDefs.Y]+4];
obj.validEncoding ← TRUE;
obj.tokenType ← CP;
obj.p0 ← pt;
obj.isSelected ← NIL;
ObjectDefs.PlotOneObject[obj,write];
};
}.