88 lines
79 KiB
Plaintext
88 lines
79 KiB
Plaintext
Free Menus
|
||
1
|
||
|
||
Free Menus are powerful and flexible menus that are useful for (APPLICATION% MENUS NIL Application% Menus NIL (D) 1)applications needing menus with different types of items, including command items, state items, and items that can be edited. A Free Menu is part of a window. It can can be opened and closed as desired, or attached as a control menu to the application window.
|
||
Making a Free Menu
|
||
A Free Menu is built from a description of the contents and layout of the menu. As a Free Menu(FREE% MENU NIL Free% Menu NIL (D) 1 SUBNAME HOW% TO% MAKE% A% SUBTEXT How% to% make% a% ) is simply a group of items, a Free Menu Description is simply a specification of a group of items. Each group has properties associated with it, as does each Free Menu Item. These properties specify the format of the items in the group, and the behavior of each item. The function FREEMENU takes a Free Menu Description, and returns a closed window with the Free Menu in it.
|
||
The easiest way to make a Free Menu is to define a specific function which calls FREEMENU with the Free Menu Description in the function. This function can then also set up the Free Menu window as required by the application. The Free Menu Description is saved as part of the specific function when the application is saved. Alternately, the Free Menu Description can be saved as a variable in your file; then just call FREEMENU with the name of the variable. This may be a more difficult alternative if the backquote facility is used to build the Free Menu Description.
|
||
Free Menu Formatting
|
||
|
||
A Free Menu can be formatted in one of four ways. The items in any group can be automatically laid out(LAYOUT NIL Layout NIL (D) 1 SUBNAME OF% FREE% MENU% SUBTEXT of% Free% Menu% ) in rows, in columns, or in a table, or else the application can specify the exact location of each item in the group. Free Menu(FREE% MENU% LAYOUT% NIL Free% Menu% layout% NIL (D) 1) keeps track of the region that a group of items occupies, and items can be justified within that region. This way an item can be automatically positioned at one of the nine justification locations, top-left, top-center, top-right, middle-left, etc.
|
||
Free Menu Description
|
||
A Free Menu Description, (SPECIFYING% FREE% MENU% ITEMS NIL Specifying% Free% Menu% Items NIL (D) 2)specifying a group of items, is a list structure. The first entry in the list is an optional list of the properties for this group of items. This entry is in the form:
|
||
(PROPS <PROP> <VALUE> <PROP> <VALUE> ...)
|
||
The keyword PROPS determines whether or not the optional group properties list is specified..
|
||
One important group property is FORMAT. The four types of formatting, ROW, TABLE, COLUMN, or EXPLICIT, determine the syntax of the rest of the Free Menu Description. When using EXPLICIT (FREE% MENU% FORMAT NIL Free% Menu% format NIL (D) 2)formatting, the rest of the description is any number of Item Descriptions which have LEFT and BOTTOM properties specifying the position of the item in the menu. The syntax is:
|
||
|
||
((PROPS FORMAT EXPLICIT ...)
|
||
<ITEM DESCRIPTION>
|
||
<ITEM DESCRIPTION> ...)
|
||
When using ROW or TABLE formatting, the rest of the description is any number of item groups, each group corresponding to a row in the menu. These groups are identical in syntax to an EXPLICIT group description. The groups have an optional PROPS list and any number of Item Descriptions. The items need not have LEFT and BOTTOM properties, as the location of each item is determined by the formatter. However, the order of the rows and items is important. The menu is laid out top to bottom by row, and left to right within each row. The syntax is:
|
||
|
||
((PROPS FORMAT ROW ...) ; props of this group
|
||
(<ITEM DESCRIPTION> ; items in first row
|
||
<ITEM DESCRIPTION> ...)
|
||
((PROPS ...) ; props of second row
|
||
<ITEM DESCRIPTION> ; items in second row
|
||
<ITEM DESCRIPTION> ...))
|
||
(The comments above only describe the syntax.)
|
||
For COLUMN formatting, the syntax is identical to that of ROW formatting. However, each group of items corresponds to a column in the menu, rather than a row. The menu is laid out left to right by column, top to bottom within each column.
|
||
Finally, a Free Menu Description can have recursively nested groups. Anywhere the description can take an Item Description, it can take a group, marked by the keyword GROUP. A (NESTING% FREE% MENU% GROUPS NIL Nesting% Free% Menu% Groups% NIL (D) 2)nested group inherits all of the properties of its mother group, by default. However, any of these properties can be overridden in the nested groups PROPS list, including the FORMAT. The syntax is:
|
||
( ; no PROPS list, default row format
|
||
(<ITEM DESCRIPTION> ; first in row
|
||
(GROUP ; nested group, second in row
|
||
(PROPS FORMAT COLUMN ...) ; optional props
|
||
(<ITEM DESCRIPTION> ...) ; first column
|
||
(<ITEM DESCRIPTION> ...))
|
||
<ITEM DESCRIPTION>)) ; third in row
|
||
Here is an example of a simple Free Menu Description for a menu which might provide access to a simple data base:
|
||
|
||
(((LABEL LOOKUP SELECTEDFN MYLOOKUPFN)
|
||
(LABEL EXIT SELECTEDFN MYEXITFN))
|
||
((LABEL Name: TYPE DISPLAY) (LABEL "" TYPE EDIT ID NAME))
|
||
((LABEL Address: TYPE DISPLAY) (LABEL "" TYPE EDIT ID ADDRESS))
|
||
((LABEL Phone: TYPE DISPLAY)
|
||
(LABEL "" TYPE EDIT LIMITCHARS MYPHONEP ID PHONE)))
|
||
This menu has two command buttons, LOOKUP and EXIT, and three edit fields, with IDs NAME, PHONE, and ADDRESS. The Edit items are initialized to the empty string, as in this example they need no other initial value. The user could select the Name: prompt, type a person's name, and then press the LOOKUP button. The function MYLOOKUPFN would be called. That function would look at the NAME Edit item, look up that name in the data base, and fill in the rest of the fields appropriately. The PHONE item has MYPHONEP as a (LIMITCHARS (FreeMenu Item Property) LIMITCHARS% NIL (D) 3)LIMITCHARS function. This function would be called when editing the phone number, in order to restrict input to a valid phone number. After looking up Perry, the Free Menu might look like:
|
||
|