Category : C Source Code
Archive   : CXLNGS51.ZIP
Filename : CXLTMNU.NMS

 
Output of file : CXLTMNU.NMS contained in archive : CXLNGS51.ZIP

^bBar Menu Functions^b

To use CXL's menuing system, you must be familiar with the process of
defining menus. There are several functions associated with the
defining of menus. These functions must appear in your source code in a
certain order. Menu structures can be defined as simple as a one-level
pop-up menu, or as complex as a multi-level pull-down menu system. The
basic format of all menu structures is:

^b^b
^bwmenuitem^b
^b[wmenuitxt]^b
^b[wmenuiba]^b
^b[...]^b
^b[wmenuitem...]^b
^bwmenuend^b
^bwmenuget^b

Either wmenubeg() or wmenubegc() is required to mark the start of a
menu, wmenuitem() is required to define menu items, wmenuend() is
required to mark the end of a menu, and wmenuget() initiates user
processing of the entire menu structure.

Notice that you can also define entire menus underneath any individual
menu item. This allows you to easily create nested menus to aid in
building complex pull-down and multi-layered menuing systems. There is
no limit to how deep you can nest sub-menus, with the exception of
available memory.

When coding multi-level menu systems, it is a good idea to use indenting
as shown above to help you distinguish which menu items and menu-ends go
with which menu-begins.

wmenuitxt() and wmenuiba() are optional functions. They allow you to
add specific features to a menu item. If either of these 2 functions
are used, they must immediately follow the call to wmenuitem() to which
they pertain.

After you define the menu structure and call wmenuget(), the user is
allowed to make a selection. The following editing keys may be used by
the user when processing the menu:

^bLeftArrow^b - moves selection bar to item left.
^bRightArrow^b - moves selection bar to item right.
^bUpArrow^b - moves selection bar to item upwards.
^bDownArrow^b - moves selection bar to item downwards. If the current
menu item has a pull-down menu attached, then it will
be opened for processing.
^bEnter^b - selects the item that the selection bar is on. If
selected item has a sub-menu attached, then processing
of that menu will begin.
^bHome^b - moves selection bar to upper-leftmost item.
^bEnd^b - moves selection bar to lower-rightmost item.
^bEsc^b - if Escape checking is on, and your are in the root
menu, pressing this cancels input and returns a -1. If
inside a sub-menu, then you will just back up to the
previous menu.

You can also quick-select a menu item by pressing its highlighted
selection character, unless this feature is disabled.

CXL's menuing system also includes built-in mouse support. If you want
to use it, you need to call msinit() somewhere near the beginning of the
program. This will set the mouse support level to MS_KEYS, which allows
the mouse to emulate cursor keys. If you would like a point-and-shoot
selection capability where the user moves the mouse cursor around then
presses the button to select, you must set the mouse support level to
MS_CURS or MS_FULL via mssupport(). In either method of mouse support,
the left mouse button is equivalent to the [Enter] key, and the right
mouse button is equivalent to the [Esc] key.

Each menu item can have a function and/or sub-menu attached to it. When
the user selects the menu item, wmenuget() will first check for an
attached sub-menu. If one exists, it will be processed. Then
wmenuget() will check for a defined select function. If one exists,
then wmenuget() will call it.

This gives you two ways to handle a user selection. The first, as
you've seen, is to have a function attached to the menu item. For
example, if the menu item is "(A)dd Record" and it has a select function
called add_record(), then it will be called upon selecting that menu
item. The other way to handle a user selection is by using a
switch/case to test the return value from wmenuget(). This will only
work properly on single-level menus, but sometimes gives you more
flexibility.



  3 Responses to “Category : C Source Code
Archive   : CXLNGS51.ZIP
Filename : CXLTMNU.NMS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/