VkSubMenu(3x)VkSubMenu(3x)NAMEVkSubMenu - A container for pulldown or pull-right menu panes
INHERITS FROM
VkMenu : VkMenuItem: VkComponent : VkCallbackObject
HEADER FILE
#include <Vk/VkSubMenu.h>
PUBLIC PROTOCOL SUMMARY
Constructor/Destructor
VkSubMenu(const char *name,
VkMenuDesc *desc = NULL,
XtPointer defaultClientData = NULL);
VkSubMenu(Widget parent,
const char *,
VkMenuDesc *desc = NULL,
XtPointer defaultClientData = NULL);
virtual ~VkSubMenu();
Tear Off Control
void showTearOff(Boolean showit);
Access Functions
virtual VkMenuItemType menuType ();
Widget pulldown();
virtual const char* className();
CLASS DESCRIPTION
The VkSubMenu class supports pulldown menu panes. These menu panes can be
used within a menu bar (a VkMenuBar object), or as a cascading, pull-
right menu in a popup or other pulldown menu.
MENUS IN THE OVERLAY PLANES
By default, menus appear in the normal planes. A ViewKit application's
menus may be explicitly placed in the deepest available overlay planes.
Doing so prevents menus from causing expose events and disturbing such
things as complex GL rendering. Doing so may also allow better looking
menus when they contain things like checkmarks. The current
implementation is global. For a single application, either all menus go
in the overlay planes or none of them do. That may be relaxed in a
future release.
There are three ways to enable menus in the overlay planes:
Call VkMenu::useOverlayMenus(TRUE) in your application. This will
Page 1
VkSubMenu(3x)VkSubMenu(3x)
force all menus to be in the overlay planes, with no way to put them
back in the normal planes without recompiling.
Put the resource string "*useOverlayMenus: True" in your
application's app-defaults file. This will put menus in the overlay
planes by default, but allow users to use the normal planes by
changing their .Xdefaults file.
Ask the user to add the "-useOverlayMenus" command line switch when
they run your application. This will put menus in the normal planes
by default, but allow the user to explicitly ask that the overlay
planes be used.
There are several disadvantages to using the overlay planes, so menus
should be put there only when the advantages outweigh the disadvantages:
The colormap in the overlay planes may have fewer pixels. On some
hardware, the deepest overlay only has three color entries. (The
fourth entry is a transparent pixel.) When there are fewer colors
available, menus in the overlay planes have a different appearance.
In that case, if you have items in your pulldown menus other than
labels (e.g. cascade buttons or toggle buttons), they may not look
correct in some of the less-common color schemes.
Other applications that are using the overlay planes at the same
time will display in the wrong colors when a menu appears (i.e.
colors will flash). This happens because the menu's colormap will
get installed and replace any previous overlay colormap.
When a pulldown menu in the overlay planes is torn off, 4Dwm puts
the tear-off in the overlay planes. The title bar of the window
appears with the wrong colors and, as with (2), the window appears
with the wrong colors when another application uses the overlay
planes (e.g. 4Dwm's root-window popup menu).
Running the example program "vkmenu" shows that the expose counter
increments each time a menubar item is selected and dismissed. Running
"vkmenu -useOverlayMenus" shows that the expose counter does not change
when pulldown menus appear and disappear, since no expose events are
generated. For more information see /usr/share/src/ViewKit/Menus/README.
FUNCTION DESCRIPTIONSVkSubMenu()
VkSubMenu(const char *name,
VkMenuDesc *desc = NULL,
XtPointer defaultClientData = NULL);
VkSubMenu(Widget parent,
const char *name,
VkMenuDesc *desc = NULL,
XtPointer defaultClientData = NULL);
Page 2
VkSubMenu(3x)VkSubMenu(3x)
The VkSubMenu constructor initializes a VkSubMenu object. If the
second form, which takes a widget as the first argument, is used,
the widgets used in the menu are built immediately. Otherwise, the
widgets in the menu are created at some later time. Both forms of
the constructor support a defaultClientData argument which can be
used to supply a clientData argument for use with menu items added
to the pane whose callbacks do not specify clientData. This allows
menus to be specified statically, while still allowing an instance
pointer to be used with callbacks. Both forms of the constructor
also accept an optional array of VkMenuDesc structures that
statically describe the contents of the menu.
It is seldom necessary to directly create a VkSubMenu object.
SubMenus can be added to any VkMenuBar, VkPopupMenu, or VkSubMenu by
calling those classes's addSubmenu() member function. Menu panes can
also be added to a VkWindow by calling VkWindow::addMenuPane().
~VkSubMenu()
virtual ~VkSubMenu()
Frees all memory allocated by the VkSubMenu class and destroys all
widgets used by this class. If the VkSubMenu object contains other
VkMenuItem objects, these objects are deleted.
Tear Off Control
void showTearOff(Boolean showit);
This function allows applications to specify whether or not a given
menu pane has a tear-off control.
menuType()
virtual VkMenuItemType menuType()
Returns VkMenuItem::SUBMENU.
pulldown()
Widget pulldown()
This function provides access to the XmRowColumn widget used to
implement the pulldown menu pane. The baseWidget() method returns
the XmCascadeButton widget required by Motif pulldown menus.
className()
virtual const char *classname()
Page 3
VkSubMenu(3x)VkSubMenu(3x)
Returns "VkSubMenu".
EXAMPLES
The following code segment creates a VkPopupMenu object and adds two
cascading menu panes to the popup menu.
VkPopupMenu *popup = new VkPopupMenu("popupMenu");
VkSubMenu *subMenu1 = popup->addSubmenu("Submenu1");
VkSubMenu *subMenu2 = popup->addSubmenu("Submenu2");
// add items to submenus here
The following code segment is a constructor for a subclass of VkWindow.
This constructor adds two panes to the VkWindow object's menu bar.
MyWindow::MyWindow( const char *name) :
VkWindow( name)
{
Widget label = XmCreateLabel(mainWindowWidget(),
"menuDemo", NULL, 0);
VkSubMenu *appMenuPane = addMenuPane("Application");
appMenuPane->addAction("Open",
&MyWindow::openCallback,
(XtPointer) this);
appMenuPane->addSeparator();
appMenuPane->addAction("Quit",
&MyWindow::quitCallback,
(XtPointer) this);
// Add a second menu pane
VkSubMenu *editMenuPane = addMenuPane("Edit");
editMenuPane->addAction("copy",
&MyWindow::copyCallback,
(XtPointer) this);
editMenuPane->addAction("cut",
&MyWindow::cutCallback,
(XtPointer) this);
editMenuPane->addAction("paste",
&MyWindow::pasteCallback,
(XtPointer) this);
Page 4
VkSubMenu(3x)VkSubMenu(3x)INHERITED MEMBER FUNCTIONS
Inherited from VkMenu
isContainer(), addAction(), addActionWidget(),
addConfirmFirstAction(), addSeparator(), addLabel(), addToggle(),
add(), addSubmenu()addRadioSubmenu(), registerSubmenu(),
findNamedItem(), removeItem(), deactivateItem(), replace(),
getItemPosition(), operator[](), numItems(),
Inherited from VkMenuItem
show(), hide(), manageAll(), setLabel(), setPosition(), activate(),
deactivate(), remove(), show(), _position, _isBuilt, _sensitive,
_parentMenu, _label, _isHidden, _unmanagedWidgets,
_numUnmanagedWidgets,
Inherited from VkComponent
installDestroyHandler(), removeDestroyHandler(), widgetDestroyed(),
setDefaultResources(), getResources(), manage(), unmanage(),
baseWidget(), okToQuit(), _name, _baseWidget, _w, deleteCallback
Inherited from VkCallbackObject
callCallbacks(), addCallback(), removeCallback(),
removeAllCallbacks()KNOWN DERIVED CLASSES
VkHelpPane, VkRadioSubMenu,
CLASSES USED BY THIS CLASS
VkMenuItem
KNOWN CLASSES THAT USE THIS CLASS
VkMenu, VkMenuBar
SEE ALSO
VkMenu, VkMenuItem, VkComponent, VkMenu, VkMenuBar, VkMenuItem
ViewKit Programmer's Guide
The X Window System, DEC Press, Bob Sheifler and Jim Gettys
The X Window System Toolkit, DEC Press, Paul Asente and Ralph Swick
The OSF/Motif Programmers Reference, Prentice Hall, OSF
Page 5