Public Member Functions

Wt::Ext::Menu Class Reference
[Ext widgets]

A menu presented in a popup window. More...

#include <Wt/Ext/Menu>

Inherits Wt::Ext::Widget.

List of all members.

Public Member Functions

 Menu ()
 Create a new menu.
MenuItemaddItem (const WString &text)
 Add an item with given text.
MenuItemaddItem (const std::string &iconPath, const WString &text)
 Add an item with given icon and text.
template<class T , class V >
MenuItemaddItem (const WString &text, T *target, void(V::*method)())
 Add an item with given text, and specify a slot method to be called when activated.
template<class T , class V >
MenuItemaddItem (const std::string &iconPath, const WString &text, T *target, void(V::*method)())
 Add an item with given text and icon, and specify a slot method to be called when activated.
MenuItemaddMenu (const WString &text, Menu *menu)
 Add a submenu, with given text.
MenuItemaddMenu (const std::string &iconPath, const WString &text, Menu *menu)
 Add a submenu, with given icon and text.
void add (MenuItem *item)
 Add a menu item.
void add (WWidget *item)
 Add a widget to the menu.
void addSeparator ()
 Add a separator to the menu.

Detailed Description

A menu presented in a popup window.

A menu is always presented in a popup window, and, unlike other widgets, cannot be instantiated on its own (by adding to a WContainerWidget). Instead it must be associated with a Button or MenuItem (to create sub menus).

Usage example:

 // Create a menu with some items
 Wt::Ext::Menu *menu = new Wt::Ext::Menu();
 Wt::Ext::MenuItem *item;

 item = menu->addItem("File open...");
 item->setIcon("icons/yellow-folder-open.png");

 item = menu->addItem("I dig Wt");
 item->setCheckable(true);
 item->setChecked(true);

 item = menu->addItem("I dig Wt too");
 item->setCheckable(true);

 menu->addSeparator();
 menu->addItem("Menu item");
 menu->addSeparator();

 // Add a sub menu
 Wt::Ext::Menu *subMenu = new Wt::Ext::Menu();
 subMenu->addItem("Do this");
 subMenu->addItem("And that");

 item = menu->addMenu("More ...", subMenu);
 item->setIcon("icons/yellow-folder-open.png");

 // Create a tool bar
 Wt::Ext::ToolBar *toolBar = new Wt::Ext::ToolBar(ex);

 // Associate the menu with a button
 Wt::Ext::Button *b = toolBar->addButton("Button w/Menu", menu);
 b->setIcon("icons/yellow-folder-closed.png");
ExtMenu-1.png

Example of a Menu

See also:
MenuItem, AbstractButton::setMenu()

Constructor & Destructor Documentation

Wt::Ext::Menu::Menu (  ) 

Create a new menu.

The menu cannot be added to a WContainerWidget, but must instead be associated with a Button or MenuItem.

See also:
Button::setMenu(), MenuItem::setMenu(), addMenu().

Member Function Documentation

template<class T , class V >
MenuItem * Wt::Ext::Menu::addItem ( const std::string &  iconPath,
const WString text,
T *  target,
void(V::*)()  method 
)

Add an item with given text and icon, and specify a slot method to be called when activated.

The target and method are connected to the MenuItem::activated() signal.

template<class T , class V >
MenuItem * Wt::Ext::Menu::addItem ( const WString text,
T *  target,
void(V::*)()  method 
)

Add an item with given text, and specify a slot method to be called when activated.

The target and method are connected to the MenuItem::activated() signal.


Generated on Mon Nov 29 2010 08:03:20 for Wt by doxygen 1.7.1