You may return to the Cvo Object Documenation Index from this document. This document contains the following sections describing the Cvo_Menu object:
Cvo_Menu
Cvo_Window
#include
<Cvo/Menu.h++>
new
Cvo_Menu ( char *resource_name,
{ Cvo_Object *parent | Display *display },
[ Cvo_MenuItem *menu_items ] )
A Cvo_Menu object is used to produce an array of choices which can be selected with the mouse, quick-keys, or accelerators. While in operation, a menu takes control of the keyboard and mouse, so they really should be transients. Typically a menu is created due to the pressing of a button (see the Cvo_ButtonMenu object) or by pressing a mouse button in some particular area.
Typically a menu is defined by the NULL
terminated array of
Cvo_MenuItem structures pointed to by menu_items. A list of
Cvo_MenuEntry objects is used to store the various items in a menu.
The MenuEntries()
member function returns this list.
It is also possible to modify menu entries on the fly. The Cvo_MenuEntry object provides methods to add or remove entries from a menu.
Note that in most cases, the parent argument should be
Cvo_MAINWINDOW
as menus should display as a transient window on the
screen.
This object defines the following member functions in addition to those defined by its parent and ancestor objects.
Start (
int count,
[ { int x, int y } | { Cvo_Object *from } ] )
This function is used to start processing of the menu. It is expected that the menu has already been mapped by the time this function has been called. The count argument is the number of mouse buttons currently pressed down. Generally this is 1 (e.g. a mouse press was used to start the menu) but can be 0 if this menu was not started by simply a mouse button down event.
The optional arguments x and y specify the screen coordinates for the origin of the Cvo_Menu object's window.
The optional argument from specifies a Cvo object to which the Cvo_Menu object's window should be adjacent. The Cvo_Menu object's window will be placed either above or below the object specified by from depending on the space available on the screen.
StartCascade (
int count,
{ Cvo_Object *from } )
This function is very similar to the Start()
member function. It
differs only in the placement of the Cvo_Menu object window. This
function will cause the window to be placed either to the left or
right of the Cvo object from depending on the space available on
the screen.
As with the Start()
member function, the count argument is the
number of mouse buttons currently pressed down.
Cvo_MenuEntry *MenuEntries (
)
This function returns a pointer to the list of Cvo_MenuEntry objects containing the various entries of the menu.
This object defines the following Cvo Events in addition to those defined by its parent and ancestor objects.
CvoNewMenuItemEvent
struct
Cvo_NewMenuItemEvent
Cvo_MenuEntry *item
This event is generated whenever a new item is added to a menu. The item argument points to the new Cvo_MenuEntry object.
CvoMenuEvent
struct
Cvo_MenuEvent
Cvo_Menu *menu,
Cvo_MenuEntry *item
This event is generated when a menu selection is made. The menu argument is the Cvo_Menu that contains the item that was selected and the item argument points to the Cvo_MenuEntry object for the actual item selected.
Note that this event will be sent directly to an event handler function. The Cvo_MenuItem and Cvo_MenuEntry objects permit an event handler to be associated with each menu entry. You cannot register for this event.
CvoMenuCascadeEvent
struct
Cvo_MenuEvent
Cvo_Menu *menu,
Cvo_MenuEntry *item
This event is generated whenever a cascade menu item is entered, and the cascade menu is displayed. The menu argument points to the Cvo_Menu containing the item which was entered. The item argument points to the Cvo_MenuEntry object for the item which was entered.
This object uses the following X resources in addition to those used by its parent and ancestor objects.
*CvoMenu.menuCursor
(class:
MenuCursor
) (default value:
Arrow
)
This is the X cursor which will be displayed in the Cvo_Menu window.
This object modifies the following X resources which are used by its parent or other ancestors.
*CvoMenu.LayoutPad
(new value:
0
)
*CvoMenu.InternalPad
(new value:
0
)
See the example source code for an example of how to use this object.
See the legend for information about the conventions used in this documentation.