A Windows-Driven Menu Driver
In Stephen B. Jaffe’s paper at the APL86 Congress in Manchester a ‘menudriven menudriver’ was discussed. The driver consisted of a character matrix containing the menus and menu items, a pointer, pointing to the successive menu items and two functions, one of them displaying the correct menu items, and the other one pointing to the next ‘group’ of items or executing the lowest level menu item.
Now to do the same for Windows, we need to convert the same character array and menu pointers into a Window driven device. Suppose we have an application on making quotations for mortgages in our workspace MORTGAGE. The menu items with their pointers are as follows:
Row Menu(item) Pointer MENU IMENU (variable name) 01 MORTGAGES 0 02 Quotation 1 03 Output 1 04 Linear 2 05 Annuity 2 06 Others 2 07 Print 3 08 Screen 3 09 File 3 10 Spreadsheet 3 11 Life Insurance 6 12 Variable rate 6 13 Low rate incremental 6
For instance Linear, Annuity and Others point to Quotation, etc. In this example Quotation is a MENU and Linear and Annuity are MENUITEMs. Others is a MENU itself, because it is pointed to by Life Insurance, Variable rate and Low rate incremental. The latter are MENUITEMs in their turn. Now, we want to convert the list of items in a convenient Windows menu. MENUDRIVER is doing this, regardless of depth of pointer levels, using Dyalog APL/W.
Our first menu display looks like this:
If we click on Quotation our display becomes
and we may click further on Other:
and also the Output MENU, etc.
Close gives control to the workspace in a development environment and to Windows Program Manager in a Runtime application.
Help is generated by the MENUDRIVER function. The Help Window looks like this, and is editable by the user. It uses an external file for saving, so it can be used in Runtime applications.
This Window-driven menudriver is generated by
- a function MENUDRIVER (see Appendix)
- a character array with the names of the MENUs and MENUITEMs
- a pointer controlling the relation of MENUs and MENUITEMs
The MENUDRIVER function takes any character array and pointers with the appropriate names. So, the only thing you have to do is edit these variables. This is done by a function EDITMENU, which takes the result of MENULIST as a character array as shown above. The last item in any relation (which is a MENUITEM in the terminology of Dyalog) should carry the name of a cover (callback-) function and clicking should take care of execution.
MENULIST and EDITMENU are simple functions which need no further explanation. BLANKOUT is a function published and explained in the quoted reference. SORT is an ambivalent function which sorts a list of variables in the right argument, according to the key formed by the variables in that argument or an optional list of variables in the left argument.
- Jaffe, S.B. Building better user interfaces. APL86 Conference Proceedings (ACM 1986)
(webpage generated: 30 August 2007, 16:53)