11
Menus
Menus play an important role in an application’s user interface. An OPEN LOOK menu may
display text or graphics. Menus may be attached to most XView objects such as menu but-
tons, scrollbars or text subwindows, or they may exist independently from objects and be
displayed on demand.
The user may cause a menu to be pinned up by selecting an optional pushpin in the pop-up
menu. When this happens, the menu is taken down and a corresponding command frame is
put up at the same location. Panel items in the pinup window correspond to the menu items
in the menu. Once a menu has been pinned up, the user continues to interact with it just as if
the menu were popped up each time. Menus that are used frequently are good candidates for
having pushpins so the user does not have to repeat the sequence of redisplaying the menu to
make selections.
OPEN LOOK requires that menus have titles. Menus or submenus that originate from menu
buttons or pullright items do not need to have titles, since the name of the menu button or
menu item acts as the title.
Fonts may not be specified in either menu items or menu titles; menu items follow the same
constraints outlined for panel buttons. However, if text is not used, then menu items may
contain graphic images, in which case, the font is of no concern. That is, you could specify a
Server_image that has a string rendered in a particular font.
11.1 Menu Types
There are three different types of menus: pop-up, pulldown, and pullright menus. The gen-
eral term pop-up menu may describes all three types in certain contexts since menus are
popped up. However, pulldown and pullright menus have distinct characteristics that make
them unique.
Menus
Menus 273
11.1.1 Pop-up Menus
Pop-up menus are displayed when the user selects the MENU mouse button over XView
objects such as scrollbars or text subwindows. An OPEN LOOK window manager also utilizes
pop-up menus in the root window and from base frame title bars. XView objects handle the
display of menus automatically. Applications may wish to track ACTION_MENU events in
objects such as canvases and display their own pop-up menus. Figure 11-1, from the OPEN
LOOK
GUI Specification Guide, shows a Window menu-generated from the title bar of an
OPEN LOOK base frame.
Figure 11-1. The Window menu
11.1.2 Pulldown Menus
Pulldown menus are attached to menu buttons. Menu buttons have a set of choices associ-
ated with them that the user can access only via the pulldown menu. When the user presses
the MENU mouse button over a menu button, the choices are displayed in the form of a pull-
down menu. If the menu button is selected using the SELECT button, the default menu item
is selected. See Chapter 7, Panels, for details on creating menu buttons. Figure 11-2, from
the OPEN LOOK GUI Specification Guide, shows sample pulldown menus activated from a
menu button.
11.1.3 Pullright Menus
OPEN LOOK provides for items in the menu to have pullright menus associated with them.
Also called cascading menus, these menus are activated from the user dragging the MENU
mouse button to the right of a menu item that has an arrow pointing to the right. The cascad-
ing menu that results is a pop-up menu that can also have menu items with pullrights atta-
ched. Figure 11-3, from the OPEN LOOK GUI Specification Guide, shows a pullright menu
originating from a menu item in a pulldown menu.
274 XView Programming Manual
Figure 11-2. Menu buttons each with a pulldown menu
Figure 11-3. Pushpins in a menu and a submenu
Menus
Menus 275
11.2 Menu Items
In addition to the menu types, there are different types of menu items: choice, exclusive, and
nonexclusive. The different menu item types may be associated with each type of menu.
Each menu has a default selection associated with it. This item is displayed uniquely from
other menu items and designates a default action to take if the user wants to select the menu
without displaying it (see pulldown menus below). Typically, the 0th item in the menu is the
default, but that may be changed either by the application or by the user.
11.2.1 Choice Items
The choice item is the default menu item type used when a menu is created. The default
selection in a menu has a ring around it. When a pop-up menu is displayed, it is positioned
so that the mouse is pointing at the default item. Choice menu items may have pullright
menus associated with them, in which case there is a pullright arrow at the right side of the
item. If the selection of a menu item brings up a dialog box (command frame), then the label
for the menu item typically ends in ellipses ( . . . ).
11.2.2 Exclusive Items
When a choice item is selected, an action is taken and the menu forgets about it. Exclusive
menu items retain the fact that they are selected even after the menu has popped down. If the
user selects a new item, the new item is remembered. Because this is an exclusive menu,
only one choice may be selected at a time. The default item is indicated by a double-lined
box around the item. Figure 11-4 is from the
OPEN LOOK GUI Specification Guide.
Figure 11-4. Exclusive settings on a menu
276 XView Programming Manual
When exclusive settings are used on menus, the current choice has a bold border when the
pointer is not on a menu choice. When the user drags the pointer onto other settings, the bold
border follows the pointer. Exclusive choice menus may not have items with pullright
menus.
11.2.3 Nonexclusive Items
Also called toggle items, menus that have toggle items support multiple choices from the
menu to be selected at the same time. That is, the user may toggle whether a particular
choice is selected. This action has no affect on the other menu items. Figure 11-5 shows an
example of a menu that has items and a submenu that has nonexclusive settings.
Figure 11-5. Nonexclusive settings on a submenu
In this figure, the chosen settings on the submenu are Bold and Italic. The choices not
selected are Underline and Overstrike.
11.3 Creating Menus
The header file for the MENU package is <xview/openmenu.h>, but the file is already included
by <xview/xview.h>. Another name for the MENU package is MENU_COMMAND_MENU. The
basic menu is created using xv_create():
Menu menu;
menu = (Menu)xv_create(server, MENU, NULL);
Menus (and sometimes menu items) are discrete objects that may have delayed binding. That
is, they may be created independently from any XView object and attached later using
Menus
Menus 277
Get Volume 7A: XView Programming Manual now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.