3 lines
18 KiB
HTML
3 lines
18 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>20-FREE-MENUS</title><link href="navigation.css" rel="stylesheet" type="text/css"/><link href="document.css" rel="stylesheet" type="text/css"/></head><body><p class="top_nav"><a href="part22.htm">< Previous</a><span> | </span><a href="../Medley-Primer.html">Contents</a><span> | </span><a href="part24.htm">Next ></a></p><h1 style="padding-top: 3pt;padding-left: 35pt;text-indent: 0pt;text-align: left;"><a name="bookmark22">20. FREE MENUS</a></h1><p style="padding-left: 35pt;text-indent: 0pt;line-height: 6pt;text-align: left;"><span><img width="640" height="8" alt="image" src="Image_139.png"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 15pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Free Menu is a library package that is even more flexible than the regular menu package. It allows you to create menus with different types of items in them, and</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">format s them as you require. Free menus are particularly useful when you want a "fill in the form" type interaction with the user.</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Each menu item is described with a list of properties and values. The following example will give you an idea of the structure of the description list, and some of your options.</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">The most commonly used properties, and each type of menu item will be described in the Parts of a Free Menu Item and Types of Free Menu Items section below.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Free Menu Example </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Free menus can be created and formatted automatically! It is done with the function</p><p class="s3" style="padding-left: 107pt;text-indent: 0pt;text-align: left;">FM.FORMATMENU<span class="p">. This function takes one argument, a description of the menu. The</span></p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">description is a list of lists; each internal list describes one row of the free menu. A free menu row can have more than one item in it, so there are really lists of lists of lists! It really isn’t hard, though, as you can see from the following example:</p><p class="s3" style="padding-top: 7pt;padding-left: 167pt;text-indent: -24pt;line-height: 88%;text-align: left;">(SETQ ExampleMenu (FM.FORMATMENU</p><p class="s3" style="padding-left: 215pt;text-indent: -24pt;line-height: 88%;text-align: left;">’(((TYPE TITLE LABEL TitlesDoNothing) TYPE 3STATE LABEL Example3State))</p><p class="s3" style="padding-left: 203pt;text-indent: 0pt;line-height: 10pt;text-align: left;">((TYPE EDITSTART LABEL PressToStartEditing</p><p class="s3" style="padding-left: 209pt;text-indent: 96pt;line-height: 88%;text-align: left;">ITEMS (EDITEM)) (TYPE EDIT ID EDITEM LABEL ""))</p><p class="s3" style="padding-left: 191pt;text-indent: 0pt;line-height: 10pt;text-align: left;">(WINDOWPROPS TITLE "Example Does Nothing"))))</p><p style="padding-top: 5pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: justify;">The first row has two items in it: one is a <span class="s3">TITLE</span>, and the second is a <span class="s3">3STATE </span>item. The second row also has two items. The second, the <span class="s3">EDIT </span>item, is invisible, because its label is an empty string. The caret will appear for editing, however, if the <span class="s3">EDITSTART </span>item is chosen. Windowprops can appear as part of the description of the menu, because a</p><p style="padding-left: 107pt;text-indent: 0pt;line-height: 11pt;text-align: justify;">menu is, affer all, just a special window. You can specify not only the title with</p><p class="s3" style="padding-left: 107pt;text-indent: 0pt;text-align: justify;">WINDOWPROPS<span class="p">, but also the position of the free menu, using the "left" and "bottom"</span></p><p style="padding-left: 106pt;text-indent: 0pt;text-align: left;">properties, and the width of the border in pixels, with the "border" property. Evaluating this expression will return a window. You can see the menu by using the function <span class="s3">OPENW</span>. The following example illustrates this:</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 235pt;text-indent: 0pt;text-align: left;">Figure 20.1. Example Free Menu</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 107pt;text-indent: 0pt;text-align: justify;">The next example shows you what the menu looks like after the <span class="s3">EDITSTART </span>item,</p><p class="s3" style="padding-left: 106pt;text-indent: 0pt;text-align: justify;">PressToStartEditing<span class="p">, has been chosen.</span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 185pt;text-indent: 0pt;text-align: left;">Figure 20.2. Free menu after <span class="s3">EDITSTART </span>Item Chosen</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">The following example shows the menu with the <span class="s3">3STATE </span>item in its <span class="s3">T </span>state, with the item highlighted. (In the previous bitmaps, it was in its neutral state.)</p><p style="padding-left: 35pt;text-indent: 0pt;line-height: 11pt;text-align: left;">.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 182pt;text-indent: 0pt;text-align: left;">Figure 20.3. Free menu with <span class="s3">3STATE </span>Item in its <span class="s3">T </span>State</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-top: 4pt;padding-left: 107pt;text-indent: 0pt;line-height: 107%;text-align: left;">Finally, Figure 20.4 shows the <span class="s3">3STATE </span>item in its <span class="s3">NIL </span>state, with a diagonal line through the item</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p style="padding-left: 169pt;text-indent: 0pt;text-align: left;">Figure 20.4 Free menu with the <span class="s3">3STATE </span>item in its <span class="s3">NIL </span>State</p><p style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">If you would like to specify the layout yourself, you can do that too. See the <i>Lisp Library Packages Manual </i>for more information.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Parts of a Free Menu Item </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">There are eight different types of items that you can use in a free menu. No matter</p><p style="padding-left: 107pt;text-indent: 0pt;text-align: left;">what type, the menu item is easily described by a list of properties, and values. Some of the properties you will use most often are listed below:</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">LABEL <span class="p">Required for every type of menu item. It is the atom, string, or bitmap that appears as a menu selection.</span></p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">TYPE <span class="p">One of eight types of menu items. Each of these are described in the section below.</span></p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">MESSAGE <span class="p">The message that appears in the prompt window if a mouse button is held down over the item.</span></p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">ID <span class="p">An item’s unique identifier. An ID is needed for certain types of menu items.</span></p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">ITEMS <span class="p">Used to list a series of choices for an </span>NCHOOSE <span class="p">item, and to list the ID’s of the editable items for an </span>EDITSTART <span class="p">item.</span></p><p class="s3" style="padding-top: 7pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">SELECTEDFN <span class="p">The name of the function to be called if the item is chosen.</span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><h2 style="padding-left: 35pt;text-indent: 0pt;text-align: left;">Types of Free Menu Items </h2><p style="padding-top: 9pt;padding-left: 107pt;text-indent: 0pt;text-align: left;">Each type of menu item is described in the following list, including an example description list for each one.</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 107pt;text-indent: 0pt;text-align: left;">MOMENTARY <span class="p">This is the familiar sort of menu item. When it is selected, the</span></p><p style="padding-left: 191pt;text-indent: 0pt;text-align: left;">function stored with it is called. A description for the function that creates and format s the menu looks like this:</p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: 0pt;line-height: 11pt;text-align: left;">(TYPE MOMENTARY</p><p class="s3" style="padding-left: 215pt;text-indent: 0pt;line-height: 10pt;text-align: left;">LABEL Blink-N-Ring</p><p class="s3" style="padding-left: 215pt;text-indent: 0pt;line-height: 88%;text-align: left;">MESSAGE "Blinks the screen and rings bells" SELECTEDFN RINGBELLS)</p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 106%;text-align: left;">TOGGLE <span class="p">This menu item has two states, </span>T <span class="p">and </span>NIL<span class="p">. The default state is </span>NIL<span class="p">, but choosing the item toggles its state. The following is an example description list, without code for the </span>SELECTEDFN <span class="p">function, for this type of item:</span></p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: 0pt;line-height: 11pt;text-align: left;">(TYPE TOGGLE</p><p class="s3" style="padding-left: 215pt;text-indent: 0pt;line-height: 88%;text-align: left;">LABEL DwimDisable SELECTEDFN ChangeDwimState)</p><p class="s6" style="padding-top: 3pt;text-indent: 0pt;text-align: right;">20. FREE MENUS</p><p style="padding-left: 35pt;text-indent: 0pt;line-height: 1pt;text-align: left;"><span><img width="665" height="1" alt="image" src="Image_140.png"/></span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 190pt;text-indent: -84pt;line-height: 107%;text-align: left;">3STATE <span class="p">This type of menu item has three states, </span>NEUTRAL <span class="p">, </span>T<span class="p">, and </span>NIL. NEUTRAL <span class="p">is the default state. </span>T <span class="p">is shown by highlighting the item, and </span>NIL <span class="p">is shown with diagonal lines. The following is an example</span></p><p style="padding-left: 191pt;text-indent: 0pt;line-height: 107%;text-align: left;">description list, without code for the <span class="s3">SELECTEDFN </span>function, for this type of item:</p><p class="s3" style="padding-top: 6pt;padding-left: 190pt;text-indent: 0pt;line-height: 11pt;text-align: left;">(TYPE 3STATE</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 88%;text-align: left;">LABEL CorrectProgramAllOrNoSpelling SELECTEDFN ToggleSpellingCorrection)</p><p class="s3" style="padding-top: 6pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">TITLE <span class="p">This menu item appears on the menu as dummy text. It does nothing when chosen. An example of its description:</span></p><p class="s3" style="padding-top: 6pt;padding-left: 190pt;text-indent: 0pt;text-align: left;">(TYPE TITLE LABEL "Choices:")</p><p class="s3" style="padding-top: 7pt;padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: left;">NWAY <span class="p">A group of items, nnly one of which can be chosen at a time. The items in the </span>NWAY <span class="p">group should all have an ID field, and the ID’s</span></p><p style="padding-left: 190pt;text-indent: 0pt;text-align: left;">should be the same. For example, to set up a menu that would allow the user to choose between Helvetica, Gacha, Modern, and Classic font s, the descriptions might look like this (once again, without the code for the <span class="s3">SELECTEDFN</span>):</p><p class="s3" style="padding-top: 7pt;padding-left: 190pt;text-indent: 0pt;line-height: 11pt;text-align: left;">(TYPE NWAY ID FONTCHOICE</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 88%;text-align: left;">LABEL Helvetica SELECTEDFN ChangeFont)</p><p class="s3" style="padding-left: 190pt;text-indent: 0pt;line-height: 10pt;text-align: left;">(TYPE NWAY ID FONTCHOICE</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 10pt;text-align: left;">LABEL Gacha</p><p class="s3" style="padding-left: 190pt;text-indent: 24pt;line-height: 88%;text-align: left;">SELECTEDFN ChangeFont) (TYPE NWAY ID FONTCHOICE)</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 88%;text-align: left;">LABEL Modern SELECTEDFN ChangeFont)</p><p class="s3" style="padding-left: 190pt;text-indent: 0pt;line-height: 10pt;text-align: left;">(TYPE NWAY ID FONTCHOICE</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 88%;text-align: left;">LABEL Classic SELECTEDFN Changefont)</p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s3" style="padding-left: 191pt;text-indent: -84pt;line-height: 107%;text-align: justify;">NCHOOSE <span class="p">This type of menu item is like </span>NWAY <span class="p">except that the choices are given to the user in a submenu. The list to specify an </span>NCHOOSE <span class="p">menu item that is analogous to the </span>NWAY <span class="p">item above might look like this:</span></p><p class="s3" style="padding-top: 7pt;padding-left: 190pt;text-indent: 0pt;line-height: 11pt;text-align: left;">(TYPE NCHOOSE</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 10pt;text-align: left;">LABEL FontChoices</p><p class="s3" style="padding-left: 214pt;text-indent: 0pt;line-height: 88%;text-align: left;">ITEMS Helvetica Gacha Modern Classic) SELECTDFN Changefont)</p><p class="s3" style="padding-top: 6pt;padding-left: 190pt;text-indent: -84pt;line-height: 107%;text-align: left;">EDITSTART <span class="p">When this type of menu itein is chosen, it activates another type of item, an </span>EDIT <span class="p">item. The </span>EDIT <span class="p">item or items associated with an </span>EDITSTART <span class="p">item have their lD’s listed on the </span>EDITSTART <span class="p">’s </span>ITEMS <span class="p">property. An example description list is:</span></p><p class="s3" style="padding-top: 6pt;padding-left: 190pt;text-indent: 0pt;text-align: left;">(TYPE EDITSTART LABEL "Function to add?" ITEMS (Fn))</p><p class="s3" style="padding-top: 7pt;padding-left: 106pt;text-indent: 0pt;text-align: left;">EDIT <span class="p">This type of menu item can actually be edited by you. It is often</span></p><p style="padding-left: 190pt;text-indent: 0pt;line-height: 106%;text-align: left;">associated with an <span class="s3">EDITSTART </span>item (see above), but the caret that prompts for input will also appear if the item itself is chosen. An <span class="s3">EDIT </span>item follows the same editing conventions as editing in</p><p style="padding-left: 191pt;text-indent: 0pt;text-align: left;">Executive Window:</p><p class="s10" style="padding-top: 7pt;padding-left: 191pt;text-indent: 0pt;text-align: left;">Add characters <span class="p">by typing them at the caret.</span></p><p class="s10" style="padding-top: 7pt;padding-left: 190pt;text-indent: 0pt;text-align: left;">Move the caret <span class="p">by pointing the mouse at the new position, and clicking the left button.</span></p><p style="text-indent: 0pt;text-align: left;"><br/></p><p class="s10" style="padding-top: 4pt;padding-left: 191pt;text-indent: 0pt;text-align: left;">Delete characters <span class="p">from the caret to the mouse by pressing the right button of the mouse. Delete a character behind the caret by pressing the backspace key.</span></p><p class="s10" style="padding-top: 7pt;padding-left: 191pt;text-indent: 0pt;text-align: left;">Stop editing <span class="p">by typing a carriage return, a Control-X, or by choosing another item from the menu.</span></p><p style="padding-top: 7pt;padding-left: 191pt;text-indent: 0pt;text-align: left;">An example description list for this type of item is:</p><p class="s3" style="padding-top: 7pt;padding-left: 191pt;text-indent: 0pt;text-align: left;">(TYPE EDIT ID Fn LABEL **)</p><p class="nav"> </p><p class="nav"> </p><p class="nav"><a href="part22.htm">< Previous</a><span> | </span><a href="../Medley-Primer.html">Contents</a><span> | </span><a href="part24.htm">Next ></a></p><p class="nav"> </p></body></html>
|