home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
COMPUSCI
/
TOT11.ZIP
/
TOTDOC11.ZIP
/
CHAPT12.TXT
< prev
next >
Wrap
Text File
|
1991-02-11
|
59KB
|
1,430 lines
Menus
Menus
Menus
"Ninety-eight percent of the adults in this country are decent, hard-
working Americans. It's the other lousy two percent that get all the
publicity. But then we elected them."
Lily Tomlin
Introduction
You want menus, we got menus!
The Toolkit includes three main menu types: pop-up menus, Lotus-style
menu bars and pull-down menus. All the menus can be nested many levels
deep, i.e. when the user selects an item from a menu, another menu can
be automatically displayed. You may optionally specify a description
for any menu item, and when the user highlights the item, the descrip-
tive text is automatically displayed. All the menus provide full mouse
support, and if the mouse cursor drifts across a specific item, it is
automatically highlighted. Menu items can also be selected with the
cursor keys or by pressing a menu item hotkey.
The object hierarchy includes a number of abstract objects, as illus-
trated in figure 12.1. You should never declare an instance of type
BaseMenuOBJ, WinMenuOBJ, BarMenuOBJ or KwikPullOBJ, as these are
abstract. Use one of the following objects to display a menu:
MenuOBJ This object displays a simple menu in a window. This
object is commonly used for a program's main menu
which is displayed when the program starts.
MoveMenuOBJ This object is similar to MenuOBJ, except that the
user can drag the menu around the screen to view the
contents of the screen below.
LotusMenuOBJ The LotusMenuOBJ provides a 1-2-3 (or Paradox!)
style menu bar. The user scrolls left and right
along the menu bar.
PullMenuOBJ This is an "IDE-like" pull-down menu which supports
multiple levels of sub-menus.
EZPullArrayOBJ This objects provides a quick and easy way of
creating a sophisticated pull-down menu. All you
have to do is update a string array with the
individual item details, and instruct the Toolkit to
display the menu.
12-2 User's Guide
--------------------------------------------------------------------------------
EZPullLinkOBJ This object is similar to the EZPullArrayOBJ, except
that the menu item details are added to a linked
list (of type DLLOBJ or descendant).
Figure 12.1 [PICTURE]
Menu
Object Hierarchy
Common Methods
All menus contain items, hotkeys, descriptions, and the like. The Tool-
kit's varied menu objects share a variety of common methods which are
used to construct the menu details and characteristics.
Adding Menu Item Details
The following methods are used to set the individual menu details:
Init;
The Init method is passed no parameters, and should be called before
any other menu method.
AddItem(Txt:StrVisible);
This method is used to add an item to the menu. The method is passed
one parameter identifying the menu text to be displayed. The item
string may include embedded highlight characters to indicate that a
specific character is designated as a hot key -- refer to the WriteHi
method on page 5-3 for further information. Special strings can be
passed to force blanks or lines in the menu item list - see the note at
the end of this section.
The following methods may be called to further define the settings for
each item. Note, however, that the item must have been added with AddI-
tem (or AddFullItem) before these additional settings can be specified.
SetHK(Item:byte; HK:word);
Any item can be assigned a hotkey, which provides a way for the user to
select the item without scrolling to the item. All the user does is
press the hotkey. The de facto standard is to use normal alphabet char-
acters as the hotkeys. (Lotus and pull-down menus support additional
hotkeys which can be pressed even when the appropriate menu is not on
display -- this subject is discussed in detail later).
Menus Menus Menus 12-3
--------------------------------------------------------------------------------
SetMessage(Item:byte; Msg:StrVisible);
The SetMessage method is used to define a message for an item. When the
item is highlighted, the message will be automatically displayed, and
when the user moves to a different item, the message is removed. The
Toolkit does not save the contents of the screen where the message is
displayed.
SetID(Item:byte; ID:word);
In a menu system, which includes sub-menus, this method can be used to
assign each topic in the menu a unique ID. The method is passed two
parameters; the item number and the item ID. This ID is of type word,
and will be returned by the menu method Activate if the item is
selected by the user. Note that you should not use IDs greater than
65000, because some of these IDs are used internally by the Toolkit.
SetStatus(Item:byte, On:boolean);
Sometimes, certain menu items will not be selectable. For example, a
File Save option may not be operative until a file has been loaded or
created. The SetStatus method is used to control whether an option is
selectable. The method is passed two parameters; the item number and a
boolean parameter. Set the boolean to TRUE to enable the item and FALSE
to disable it.
SetSubMenu(Item:byte; SubMenu:BaseMenuPtr);
This method is used to indicate that another menu should be displayed,
if the item is selected by the user. The Toolkit will automatically
display the new menu below and to the right of the active menu. The
method is passed two parameters; the item number and the address of the
sub-menu object. Normally, you will call another menu instance of the
same type as the parent, e.g. if the parent menu is of type MenuOBJ,
then the sub-menu is usually of type MenuOBJ. This, however, is not
mandatory, and any menu item can display a sub-menu of any type in the
menu object hierarchy. Note that the second parameter is the address of
the sub-menu, and is normally specified by preceding the menu object
with the Turbo Pascal "@" address symbol. For example:
SetSubMenu(5,@FileMenu);
When you want to specify all the menu item details, e.g. message, HK,
sub-menu, etc., you can use the following all-in-one method:
AddFullItem(Txt:StrVisible;ID,Hk:word; Msg:StrVisible; SubM:Baseme-
nuPtr);
12-4 User's Guide
--------------------------------------------------------------------------------
As you may have guessed, this method is used to add a new item and
specify its settings in one heavy statement! This method is a single