value]
DESCRIPTION
d.menu allows the user to create a menu containing
a TITLE and options, and to display this menu in the active
frame on the graphics monitor. After the menu is displayed
in the active frame, the pointing device (mouse) is
activated and must be used to select one of the menu
options. The number associated with the selected menu
option is then printed to standard output and the program
exits. This program provides
GRASS macro writers with a mouse interface for users.
Parameters can be stated on the command line, from within
standard input, or (as illustrated in EXAMPLE)
from within a script file.
The user can specify the menu's background, text, and line
colors (bcolor, tcolor, and
dcolor) and the menu size (size) on
the command line. If the user sets at least one of these
values on the command line, any remaining values that are
not specified on the command line will be set
(automatically) to their default values (see below).
Alternately, the user can simply type d.menu on the
command line; in this case, the program will prompt the
user for the menu colors and text size using the standard
GRASS parser interface. The
user will then be (silently) prompted to enter the menu's
location and contents through standard input (see Menu
Information, below).
Parameters:
- bcolor=name
- Sets the color of the menu background (the rectangle on
which the text sits).
Options: red, orange, yellow, green, blue, indigo,
violet, magenta, brown, gray, white, and black.
Default: black
- tcolor=name
- Sets the color of the menu text.
Options: Same as those for bcolor.
Default: white
- dcolor=name
- Sets the line color used to divide text lines in the menu.
Options: Same as those for bcolor.
Default: white
- size=value
- Sets the menu's text size to the specified value. Sizes are stated as
percentages of the height of the active graphics display frame.
Options: 1 - 100
Default: 3 (i.e., 3%)
Menu Information:
After the user has (optionally) specified menu colors and
size, the program expects the user to enter information
about the menu's location and content. The menu will be
placed in the lower left corner of the active display frame
by default if the user does not position it elsewhere using
the .T or .L commands.
The user specifies the menu contents by typing in a menu
TITLE followed by the option choices to appear in the menu
when displayed. The user must enter a menu TITLE
and at least one menu option.
-
.T value
-
Specifies the menu's distance from the active display frame's top edge
(as a percentage of the active frame's height).
Note: Not required
-
.L value
-
Specifies the menu's distance from the active display frame's left edge
(as a percentage of the active frame's width).
Note: Not required
-
menu TITLE
-
A TITLE that describes the type of options listed in the menu,
and that will appear at the top of the menu when it is displayed.
-
option name(s)
-
The options that will appear in the menu when displayed.
Each menu option should appear on a separate line.
The user may enter as many options as desired, but must enter at least
one menu option.
Note: The user should choose a menu size and location that will allow
all menu options to be displayed in the active frame.
If the user enters the menu TITLE and option(s) from
standard input (i.e., at the keyboard rather than from a
file), the user should enter control-d to end
input and display the menu in the active frame on the
graphics monitor. (Note: The d.menu program can
also be incorporated into UNIX Bourne shell script macros.
The below example shows how this might be done.)
In the following example, the shell script menu2
calls the shell script color.select which contains
d.menu commands to display a menu in the current
frame on the graphics monitor. After the user selects an
option from the display menu, the selection number is
available for use by menu2.
Contents of file menu2:
#! /bin/csh -f
set option = 0
set colors = (red green blue black white )
@ option = `color.select`
if ($option <= 5) then
set color = $colors[$option]
echo $color
endif
exit
Contents of file color.select:
#! /bin/csh -f
d.menu bcolor=red tcolor=green dcolor=yellow size=5 << EOF
.T 25
.L 25
Color Choices
Option 1
Option 2
Option 3
Option 4
Option 5
EOF
If the user runs menu2, a menu will be displayed
on the graphics monitor that has red background, green
text, with menu options divided by yellow lines, and a text
size of 5% of the active display frame height. The mouse
cursor will become active, allowing the user to select (by
pointing with the mouse) one of the displayed menu
options. Here, these menu options are called
Option 1, Option 2, and
Option 3, etc. The first line of text (here,
the words Color Choices) contains the TITLE of
the menu; this line is not a menu option that can be
chosen by the user with the mouse. When the user presses
one of the mouse buttons while pointing to the desired menu
choice, the number of the option chosen will be available
for capture by the shell script menu2.
menu2 is a simple example that takes this
information and only echoes it to the screen.
NOTES
Although the user can vary text size, all text within the
same menu is displayed in a single text size (and font). If
the user specifies that items included in the menu's text
be displayed in different sizes, all text will be displayed
in the size stated last.
SEE ALSO
d.display
d.font
d.frame
d.grid
d.label
d.legend
d.paint.labels
d.text
d.title
show.fonts.sh
parser
AUTHOR
James Westervelt,
U.S. Army Construction Engineering
Research Laboratory