home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
344_02
/
windows.doc
< prev
next >
Wrap
Text File
|
1980-01-03
|
3KB
|
63 lines
Menu Magic
By Paul Ammann
Throughout the 80's, we have seen many revolutions, one of these being in
software. Software has advanced perhaps even faster than hardware. Software
techniques, once reserved for the "big" minis and mainframes, have now
found their way down to the microcomputer.
One technique that has gained rapid acceptance and popularity involves
placing program options within pull-down menus. These menus appear on the
screen allowing you to make a selection, and then return the underlying
screen back to its original state (graphics and all).
The program listing used in this article demonstrates this pull-down
technique and how it can be added to a C program. You can modularize most
of the code in this program into subroutines and merge them into your own,
or simply take the program as presented here and expand upon it.
In "Menu Magic", I have set up 5 menus that you can pull down from a menu
bar at the top of the screen. Use the left and right cursor keys to move
from one menu window to the next. Each time one of these windows appears,
the title of the current menu reverses colors.
The top item in the new menu being displayed also appears with inverse
color, highlighting that option. To make another selection, use the up and
down cursor keys to highlight a different option. Once your option is
highlighted, press [ENTER].
Only one menu has "logic" actively connected to it. This is the EXIT menu,
which provides two options - REDO and EXIT. As you pull this menu down, the
word REDO is highlighted. If you press [ENTER] now, the program re-runs
itself. If you select EXIT, the program comes to an end.
Menu Minuets
You can use "Menu Magic" to experiment with your own menus. You can alter
the titles, the options within the menu, the number of options, and the
width of the menu window. All these changes are possible with simple
modifications to the data statements. The routine accepts data for up to
10 options per window, each option name can be up to 20 characters wide.
For larger titles, you need to make some minor modifications to expand
the INV.HEAD array, which contains the inverse image of the title.
The data for the menus in this example are contained in the
INITIALIZATION_ROUTINE. Each group of data specifies one menu window. The
first group specifies the ITEM window. The first data in the group is the
word ITEM - the title of the menu. The program is currently set up to
handle 4 characteres in the title.
The next two numeric values specify the X and Y coordinates of the
upper-left corner of the menu; in this case X = 5, Y = 3. The second set
of numeric values specify the width of the menu window in characters, and
the number of options in the window; in this case WIDTH = 11, OPTIONS = 3.
The rest of the data in the first gorup contains the text of the options.
Take care that the text is not longer than the width of the window, or
it will be chopped off in the resulting display. A total 10 parameter
positions for the window options can be in the data statements. Unused data
positions should be left blank. Just remember the number of data positions
in a window will be equal to the number of options.