DIRECTORY Imager USING [Context], Rope USING [ROPE], ViewerClasses USING [MenuEntryDisplayOp, NotifyProc, Viewer]; Menus: CEDAR DEFINITIONS = BEGIN Viewer: TYPE = ViewerClasses.Viewer; ROPE: TYPE = Rope.ROPE; MenuEntryTrigger: TYPE = {leftup, middleup, rightup, shiftleftup, shiftmiddleup, shiftrightup, all, notrigger}; targetNotFound: SIGNAL; Menu: TYPE = RECORD[ name: ROPE, beginsActive: BOOLEAN _ TRUE, breakBefore: BOOLEAN _ TRUE, breakAfter: BOOLEAN _ TRUE, notify: ViewerClasses.NotifyProc _ NIL, entries: LIST OF Entry _ NIL ]; Entry: TYPE = RECORD[ name: ROPE, guarded: BOOLEAN _ FALSE, displayData: REF ANY _ NIL, -- must narrow to Rope.ROPE or DrawingRec actions: LIST OF EntryNotifyRecord _ NIL ]; EntryNotifyRecord: TYPE = RECORD[ trigger: LIST OF MenuEntryTrigger _ NIL, notifyData: LIST OF REF ANY _ NIL, popupDoc: ROPE _ NIL, guardResponse: REF ANY _ NIL, -- must narrow to Rope.ROPE or REF UnGuardRec makeActive: LIST OF ROPE _ NIL, makeInActive: LIST OF ROPE _ NIL, toggle: LIST OF ROPE _ NIL ]; DrawingRec: TYPE = RECORD [ proc: DrawingProc, -- procedure to call to do the drawing data: REF ANY _ NIL -- will be passed as the 'clientData' parm to the procedure ]; UnGuardRec: TYPE = RECORD [ proc: UnGuardProc, -- procedure to call when menu becomes unguarded data: REF ANY _ NIL -- will be passed as the 'clientData' parm to the procedure ]; DrawingProc: TYPE = PROC [op: ViewerClasses.MenuEntryDisplayOp, ctx: Imager.Context _ NIL, clientData: REF ANY _ NIL] RETURNS[width: INTEGER _ 64]; UnGuardProc: TYPE = PROC [clientData: REF ANY _ NIL]; RegisterMenu: PROC [menu: Menu]; AlreadyRegistered: PROC [name: ROPE] RETURNS [registered: BOOLEAN]; ReRegisterMenu: PROC [menu: Menu, paint: BOOL _ TRUE]; GetRegisteredMenu: PROC [name: ROPE] RETURNS [menu: Menu]; ClearMenus: PROC [viewer: Viewer, paint: BOOL _ TRUE]; AddMenu: PROC [viewer: Viewer, name: ROPE, paint: BOOL _ TRUE, addBefore: ROPE _ NIL]; MakeActive: PROC [viewer: Viewer, menu: ROPE, paint: BOOL _ TRUE]; MakeInActive: PROC [viewer: Viewer, menu: ROPE, paint: BOOL _ TRUE]; Toggle: PROC [viewer: Viewer, menu: ROPE, paint: BOOL _ TRUE]; MenuInViewer: PROC [viewer: Viewer, menu: ROPE] RETURNS [exists: BOOLEAN]; ParseDescription: PROC [def: Rope.ROPE, prevlist: LIST OF Menu _ NIL, errorFile: Rope.ROPE _ NIL] RETURNS [LIST OF Menu]; END. φMenus.mesa; Written by Randy Pausch Menus are collections of entries. Entries are selectable regions at the top of viewers that can cause TIP-like actions to be passed to notifyProcs. Menus are useful for manipulating sets of entries as a group. Menus can be created and registered with the viewers package (after which they are refered to by their unique rope "name"), and then attached to viewers. Each viewer has a list of menus associated with it, and at any given time each of them may be "active" in that viewer (visible to the user and ready to have its entries selected), or "inactive", in which case it exists in the viewer's list of menus but is currently not displayed to the user. For example, the standard Tioga viewer has three menus, the "main" one, which is initiallly active, and the "Levels" and "Places" menus, which are initially inactive. Last Edited by: Pausch, August 26, 1983 10:18 am all: LIST OF MenuEntryTrigger = LIST[leftup, middleup, rightup, shiftleftup, shiftmiddleupup, shiftrightup]; notrigger: LIST OF MenuEntryTrigger = LIST[]; Menu entries may specify different user actions as their triggers. Depending on the state of the shift key and which mouse button was used, different results may be obtained from bugging a menu entry. In addition, there is a standard way (holding control down and bugging) for users to request a list of all possible functions for a menu entry. This data type specifies all possible triggers; 'notrigger' means that the function may only be accessed through the general list, 'all' means that all possi ble triggers will produce the action. Some calls require locating entries by their names, a signal is raised if they don't exist: A 'menu' is a set of entries defined and manipulated as a group. A menu is uniquely identified by its name after it is registered with the viewers package. This is all designed for ease in 'passively' describing menus as data structures. If beginsActive is TRUE, the menu will be accessable to the user when the menu is added to a viewer. Each viewer has a list of menus associated with it, and they are "laid out" like text, as many as will fit onto a line. breakBefore and breakAfter can be used to force "line breaks" in the menus. 'notify' is the procedure to call with the input actions for the entries in the menu, when the menu entries are bugged by the user. Menu entries are uniquely identified by name. 'guarded' indicates if the user will have to bug the entry twice in a small period of time to actually cause action to occur. If something other than the name of the entry should be displayed, this can be done by making 'displayData' either a Rope.ROPE (which will be displayed instead of the name), or a REF DrawingRec, which will draw the entry itself. Menus may have more than one action associated with them. Each action has a record with the trigger(s) that causes the action, what to pass to the notify proc, and a ROPE to describe the action for use in the user interface. 'guardResponse' is used after the first mouse hit; the rope associated with the trigger is shown in the message window, or the indicated procedure is called. 'makeActive', 'makeInActive', and 'Toggle' specifiy the menus to affect when the trigger is handled, this makes it easy to describe typical menu actions in the data structure, rather than writing code to handle making menus active and inactive. operations to register menus with the viewers package: The menu data is recorded by the viewers package and associated with the name in the record. All future references may be made through the name alone. returns TRUE iff a menu with the given name has been registered. The previous definition of the menu is forgotten, and the new one takes its place. If 'paint' is true, all viewers containing the menu will be found and repainted with hint=menu. The definition for the menu is returned operations to attach menus to viewers: Any menus that had been associated with the viewer are no longer attached to the viewer. They are still registered with the viewers package, however. If 'paint' is true, the equivalent of a 'PaintViewer[viewer,hint=caption] will be done. The menu registered under the name 'name' is added to the viewer's list of menus. If 'addBefore' is non-NIL, the new menu will be added in the list before the menu with name 'addBefore'. If 'paint' is true, the equivalent of a 'PaintViewer[viewer,hint=caption] will be done. 'menu' is made accessable to the human user. 'menu' is made inaccessable to the human user. If 'menu' is currently active, it is made inactive. Otherwise, it is made active. TRUE is returned if the menu already exists in the menu, FALSE otherwise. operations to parse menu descriptions: the rope is parsed for multiple menu descriptions, as laid out in MenuBNF.tioga. Any errors are written to "errorFile." If 'prevlist' is Non-nil, the returned list will be added to and "layered" on top of 'prevlist'. If 'errorFile' is NIL, errors will be written to "menus.errlog". If any errors are found, NIL will be returned. ΚΦ– "cedar" style˜JšΟc#™#J™J™J™ΎJ™0šΟk ˜ Jšœžœ ˜Jšœžœžœ˜Jšœžœ*˜=J˜—šœžœž œžœ˜!Jšœžœ˜$Jšžœžœžœ˜—J˜šœžœ˜JšœV˜V—Jšœl™lšœ-™-JšœŸ™ŸJ™—šœžœ˜Jšœ[™[—J™šœžœžœ˜Jšœ’™’Jšœžœ˜ Jšœžœžœ˜Jšœ žœžœ˜Jšœ žœžœ˜Jšœ#žœ˜'Jšœ žœžœ ž˜Jšœ˜J˜J˜—šœžœžœ˜Jšœ’™’Jšœžœ˜ Jšœ žœžœ˜Jš œ žœžœžœœ ˜FJšœ žœžœž˜(J˜J˜—šœžœžœ˜!Jšœφ™φJšœ žœžœžœ˜(Jš œ žœžœžœžœžœ˜"Jšœ ž œ˜Jšœžœžœžœ-˜KJš œ žœžœžœžœ˜Jš œžœžœžœžœ˜!Jšœžœžœžœž˜Jšœ˜—J˜šœ žœžœ˜Jšœ&˜9Jšœžœžœžœ;˜PJ˜J˜—šœ žœžœ˜JšœΟn œ0˜CJšœžœžœžœ;˜PJ˜J˜—JšŸ œžœžœ>žœžœžœžœžœžœ˜“J˜Jš Ÿ œžœžœžœžœžœ˜5J˜Jš6™6šŸ œžœ˜ Jšœ—™—J™—š Ÿœžœžœžœžœ˜CJšœ@™@J™—šŸœžœžœžœ˜6J™³J™—šŸœžœžœžœ˜:Jšœ'™'—J™J™&šŸ œžœžœžœ˜6Jšœς™ς—šŸœžœžœ žœžœ žœžœ˜VJšœ–™–—š Ÿ œžœžœ žœžœ˜BJšœ.™.J™—š Ÿ œžœžœ žœžœ˜DJšœ.™.J™—š Ÿœžœžœ žœžœ˜>JšœR™RJ™—š Ÿ œžœžœžœ žœ˜JJšœI™I—J˜J™&šŸœžœ žœ žœžœžœžœžœžœžœ˜yJšœΝ™Ν—J˜Jšžœ˜—…— &!ς