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

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

#include <Wt/Ext/Menu>

Inheritance diagram for Wt::Ext::Menu:

Inheritance graph
[legend]

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

  Ext::Menu *menu = new Ext::Menu();
  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

  Ext::Menu *subMenu = new 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

  Ext::ToolBar *toolBar = new Ext::ToolBar(ex);

  // Associate the menu with a button

  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 WString text,
T *  target,
void(V::*)()  method 
) [inline]

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.

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

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.


Generated on Fri Jul 25 17:56:38 2008 for Wt by doxygen 1.5.3