GRASS logo

Note: A new GRASS GIS stable version has been released: GRASS GIS 7. Go directly to the new manual page here

NAME

d.menu - Creates and displays a menu within the active frame on the graphics monitor.

KEYWORDS

display, menu

SYNOPSIS

d.menu
d.menu help
d.menu [bcolor=string] [tcolor=string] [dcolor=string] [size=integer] [--verbose] [--quiet]

Parameters:

bcolor=string
Sets the color of the menu background
Options: red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,aqua,grey,cyan,purple
Default: white
tcolor=string
Sets the color of the menu text
Options: red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,aqua,grey,cyan,purple
Default: black
dcolor=string
Sets the color dividing lines of text
Options: red,orange,yellow,green,blue,indigo,violet,white,black,gray,brown,magenta,aqua,grey,cyan,purple
Default: black
size=integer
Sets the menu text size (in percent)
Options: 1-100
Default: 3

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 mouse must be used to select one of the menu options. The number associated with the selected menu option is then printed to standard output (stdout) and the program exits. This program provides GRASS macro writers with a mouse interface for user interaction.

Parameters can be stated on the command line, from within standard input (stdin), or from within a script file (as illustrated below).

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 will be set (automatically) to their default values.

NOTES

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 right 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 entering 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. All .dot commands are optional.

#
Comment line. (ignored)
.B value
Specifies the menu's background color.
.C value
Specifies the menu's text color.
.D value
Specifies the menu's dividing line color.
.F value
Specifies the menu's font. May be any of the standard GRASS fonts. (see d.font)
.S value
Specifies the menu's font size. (as a percentage of the active frame's height).
.T value
Specifies the menu's distance from the active display frame's top edge (as a percentage of the active frame's height).
.L value
Specifies the menu's distance from the active display frame's left edge (as a percentage of the active frame's width).
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.)

EXAMPLES

Example 1

a=`d.menu << EOF
# set the background color
.B brown
# set the text color
.C yellow
# set the text size in % of entire screen height
.S 3
# set the top edge
.T 10
# set the LEFT edge
.L 10
# The menu Title
Sample Menu
# the options
option 1
option 2
option 3
option 4
option 5
option 6
EOF
`

echo "You have just chosen option $a"

Example 2

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.ask
d.font
d.frame
d.grid
d.legend
d.paint.labels
d.text
d.title

AUTHOR

James Westervelt, U.S. Army Construction Engineering Research Laboratory

Last changed: $Date: 2011-11-08 03:29:50 -0800 (Tue, 08 Nov 2011) $


Main index - display index - Full index

© 2003-2016 GRASS Development Team