Text preview for : Menus.mesa_Oct77.pdf part of xerox Menus.mesa Oct77 xerox mesa 3.0_1977 listing Menus.mesa_Oct77.pdf
Back to : Menus.mesa_Oct77.pdf | Home
menus.mESA 24-0CT-77 18:38:25 Page 1
-- File: menus.mesa Edited by: Johnsson, September 27, 1977 11:33 AM
DIRECTORY
InlineDefs: FROM "inlinedefs",
WindowDefs: FROM "windowdefs",
StringDefs: FROM "stringdefs",
StreamDefs: FROM "streamdefs",
SystemDefs: FROM "systemdefs".
MenuDefs: FROM "menudefs",
RectangleDefs: FROM "rectangledefs";
DEFINITIONS FROM WindowDefs, MenuDefs, RectangleDefs,
StreamOefs;
Menus: PROGRAM
IMPORTS RectangleDefs. StreamDefs. StringDefs. SystemDefs. WindowDefs
EXPORTS MenuDefs. RectangleDefs. WindowDefs SHARES MenuDefs. RectangleDefs
BEGIN
-- GLOBAL Data
defaultpfont: FAptr ~ NIL;
defaultlineheight: INTEGER;
nullindex: StreamIndex = StreamIndex[O.-l];
originindex: StreamIndex = StreamIndex[O.O]:
bbTable: ARRAY[O .. SIZE[BBTable] + 1] OF WORD:
bbptr: BBptr ~ LOOPHOLE[@bbTable];
CR: CHARACTER = 15C;
-- Mesa Display Menu Routines
CreateMenu: PUBLIC PROCEDURE [array: MenuArray]
RETURNS[MenuHandle]
BEGIN
-- declare locals
i. j: CARDINAL:
menu: MenuH~,dle:
width. widest: xCoord:
-- compute width of widest command word
[defaultpfont. defaultlineheight] ~ GetDefaultFont[]:
widest .. 0:
FOR i IN [O .. LENGTH[array]) DO
width" 0;
FOR j IN [O .. array[i).keyword.length) DO
width ~ width + ComputeCharWidth[array[i).keyword[j]. defaultpfont];
ENDLOOP;
IF width> widest THEN widest ~ width:
ENDLOOP:
now create menu object and init it
widest .. widest + menuleftmargin*2:
menu" SystemDefs.AllocateHeapNode[SIZE[MenuObject));
menut .. MenuObject[NIL. -1. widest, NIL. NIL. NIL. array];
RETURN[menu] ;
END;
D~stroyMenu: PUBLIC PROCEDURE [menu: MenuHandle]
BEGIN
-- NOTE: need to unlink from menu list later
SystemDefs.FreelleapNode[menu]:
ENO;
DisplayMenu: PUBLIC PROCEDURE
[menu: MenuHandle. mapdata: BMHandle. x: xCoord, y: yCoord]=
BfGIN
-- declarr locals
i: CARDINAL;
ex: INTfG[R .. MAX[O. x-(menu.width+2)];
cy: INTrG[R;
18ng th: CARDINAl = I fNGTII[menu. array];
clearwords: GrayArray" [0. O. O. 0];
clear: GrayPtr = @clearwords;
[defaultpfont. defaultl ineheight] .. GetDefaultront[];
-- save data first then clear it
If menu. Index = -[ TIlEN
cy." y-(defau1l1 ineheightl2)
[[ S[
menus.mESA 24-0CT-77 18:38:25 Page 2
cy ~ y-(menu.index*defaultlinehaight+(defaultlinaheight/2