|
Purpose |
Selects an option from an action-bar menu that has pull-down menus | ||
|
Old name |
#define actionbar(mapnr,option,banned_list) | ||
|
Syntax |
int map_bar_choose(int mapnr,int DP4P option,int | ||
|
Parameters |
int mapnr |
Map number of the menu bar. This map must be on screen before making the call to map_bar_choose(). Although map_bar_choose() does not display the menu bar map initially, it does redraw the menu bar occasionally (using the map_draw_over() function with the flag NO_REARRANGE because of the need to colour menu bar fields | |
|
|
int *option |
Pointer to an integer variable in which the selected option is returned. The initial value of this variable determines which option is highlighted to start with | |
|
|
int flags |
Currently three flags are implemented: | |
|
|
HAS_PULL_DOWN |
Enables a second level of pulldown menus | |
|
|
PULL_DOWN |
Allows the user to escape from the whole menu as if it were a pulldown (by clicking outside it) | |
|
|
FUNC_KEYS |
Enables function keys. These are not allowed to select options. Pressing a function key causes map_bar_choose() to return the value of the function key as its return value in abort_code | |
|
|
void (*draw_extra)() |
If a non-zero value is passed for draw_extra, it is a pointer to a function called each time a map is drawn. This enables additional information to be displayed in the maps. The most likely use of this is to indicate 'check states' of particular options | |
|
|
short * banned_list |
Pointer to a banned list of field options to grey out. This should point to an array of field numbers terminating in zero | |
|
Description |
map_bar_choose() provides a simple mechanism to select an option from a menu bar with pulldown menus. When your program runs, map_bar_choose() first does any necessary greying out, then highlights the initial option. The cursor keys, mnemonics and other usual means are available for the user to select options. Pulldown menus are displayed and greyed out as necessary. The selected option is returned in the integer variable option_nr. The option number is returned by combining the field selected from the menu bar (the X co-ordinate) with the field selected from the pulldown menu (the Y co-ordinate) as (16*X)+Y. Assuming you have no more than nine options in the menu bar, or in each pulldown, it is easiest to code the actions selected using a switch statement with the cases coded in hex, as in:
Consider these points:
From v 4.613 it is possible to add a second level of pulldowns to menus. In other words, an option in a pulldown menu leads to its own pulldown menu. You must pass the flag HAS_PULL_DOWN to enable a second level of pulldowns. Where there are two levels of pulldowns, the option number is calculated as (256*x) + (16*y) + z, where x is the number of the menu in the menu bar, y is the number of the option from that menu and z is the number of the option from the sub-menu. | ||
|
Return values |
map_bar_choose() returns 0 if the user makes a choice or ESCAPE if <Esc> is pressed. If an activating function key is pressed or the FUNC_KEYS flag is set, the return value is the function key number. | ||
|
Designing a Menu Bar with Pulldown Menus |
The principal effort in providing a menu bar lies with the map design. But this follows a fixed pattern and is quickly achieved using the MAPEDIT utility. The pulldown menu system used for the QABUTIL utility is currently map 230 from the PROGMAKE mapset on the system database and can be examined to see the general layout. To create a pulldown menu system, use MAPEDIT to create the menu bar and add the top level fields. To add a pulldown menu for option <n> you select the Pull Down option within MAPEDIT. When you do so, MAPEDIT automatically adds a field 100+<n> in the correct position on the map and opens a menu edit window for the creation of the pulldown menu. If the menu bar map number is <m>, the pulldown menu for option <n> is given the map number <m>+<n>. map_bar_choose() attaches the pulldown menu to the field numbered 100+<n>. A maximum of 15 options is allowed in the menu bar as well as in each pulldown menu. Adhere to these guidelines when designing menu bars that conform to the IBM SAA (text mode) convention:
To conform with Windows the rules are different:
| ||
|
Example |
| ||