Menu Bar Support

The VkSimpleWindow class is useful for windows that require only a work area. However, windows frequently require menus. By providing support for a menu bar along the top of the window, the VkWindow class extends the VkSimpleWindow class.

In ViewKit ObjectPak, the VkMenuBar(3) class provides support for menu bars. See Chapter 5--Creating Menus for more details about creating and manipulating menus. "Menu Bar" describes additional functions specific to the VkMenuBar class and provides an example of constructing a menu bar for an application. This section only describes functions provided by VkWindow for installing and manipulating a menu bar.

Installing a menu bar

To install a menu bar, use setMenuBar():

void setMenuBar(VkMenuBar *menuObj)
void setMenuBar(VkMenuDesc *menudesc)

If you provide a pointer to an existing VkMenuBar object, setMenuBar() installs that menu bar. If you provide a VkMenuDesc static menu description, setMenuBar() creates a menu bar from that description and then installs the menu bar.

After installing a menu bar, menu() returns a pointer to the menu bar object:

virtual VkMenuBar *menu() const

Adding a menu pane to the menu bar

To add a menu pane to the menu bar, use addMenuPane():

VkSubMenu *addMenuPane(const char *name)
VkSubMenu *addMenuPane(const char *name, VkMenuDesc *menudesc)

addMenuPane() creates a VkSubMenu(3) object and adds it to the window's menu bar. If you provide a VkMenuDesc static menu description, addMenuPane() uses it to create the menu pane. Additionally, addMenuPane() automatically creates and installs a menu bar if the window does not currently have one.

Adding a menu pane to enforce radio behavior

You can add a menu pane that enforces radio behavior on the toggle items it contains using addRadioMenuPane():

VkRadioSubMenu *addRadioMenuPane(const char *name)
VkRadioSubMenu *addRadioMenuPane(const char *name,
VkMenuDesc *menudesc)

addRadioMenuPane() creates a VkRadioSubMenu(3) object and adds it to the window's menu bar. If you provide a VkMenuDesc static menu description, addRadioMenuPane() uses it to create the menu pane. Additionally, addRadioMenuPane() automatically creates and installs a menu bar if the window does not currently have one.

Documentation Type: