An item in a popup menu. More...
#include <Wt/WPopupMenuItem>
Public Member Functions | |
WPopupMenuItem (const WString &text) | |
Creates a new item with given text. | |
WPopupMenuItem (const std::string &iconPath, const WString &text) | |
Creates a new item with given icon and text. | |
~WPopupMenuItem () | |
Destructor. | |
void | setText (const WString &text) |
Sets the item text. | |
const WString & | text () const |
Returns the item text. | |
void | setIcon (const std::string &path) |
Sets the item icon path. | |
const std::string & | icon () |
Returns the item icon path. | |
void | setCheckable (bool how) |
Sets if the item is checkable. | |
bool | isCheckable () const |
Returns whether the item is checkable. | |
void | setPopupMenu (WPopupMenu *menu) |
Sets a sub menu for the item. | |
WPopupMenu * | popupMenu () const |
Returns the sub menu. | |
void | setChecked (bool how) |
Sets the checked state. | |
bool | isChecked () const |
Returns the checked state. | |
void | setData (void *data) |
Sets associated additional data with the item. | |
void * | data () const |
Returns additional data of the item. | |
Signal & | triggered () |
Signal emitted when an item is activated. | |
virtual void | load () |
Loads content just before the widget is used. |
An item in a popup menu.
An item may have a text, icon, and can be checkable or lead to a submenu.
When the mouse hovers over the item, its class is changed from "Wt-item" to "Wt-selected".
Wt::WPopupMenuItem::WPopupMenuItem | ( | const WString & | text ) |
Creates a new item with given text.
Wt::WPopupMenuItem::WPopupMenuItem | ( | const std::string & | iconPath, |
const WString & | text | ||
) |
Creates a new item with given icon and text.
The icon is displayed left to the text.
const std::string & Wt::WPopupMenuItem::icon | ( | ) |
Returns the item icon path.
bool Wt::WPopupMenuItem::isCheckable | ( | ) | const [inline] |
Returns whether the item is checkable.
bool Wt::WPopupMenuItem::isChecked | ( | ) | const |
Returns the checked state.
This is only used when isCheckable() == true
.
void Wt::WPopupMenuItem::load | ( | ) | [virtual] |
Loads content just before the widget is used.
When the widget is inserted in the widget hierarchy, this method is called. Widgets that get inserted in the widget hierarchy will be rendered. Visible widgets are rendered immediately, and invisible widgets in the back-ground (or not for a plain HTML session). This method is called when the widget is directly or indirectly inserted into the widget tree.
The default implementation simply propagates the load signal to its children. You may want to override this method to delay loading of resource-intensive contents.
Reimplemented from Wt::WCompositeWidget.
WPopupMenu* Wt::WPopupMenuItem::popupMenu | ( | ) | const [inline] |
Returns the sub menu.
void Wt::WPopupMenuItem::setCheckable | ( | bool | how ) |
Sets if the item is checkable.
When an item is checkable, a checkbox is displayed to the left of the item text (instead of an icon).
void Wt::WPopupMenuItem::setChecked | ( | bool | how ) |
Sets the checked state.
This is only used when isCheckable() == true
.
void Wt::WPopupMenuItem::setIcon | ( | const std::string & | path ) |
void Wt::WPopupMenuItem::setPopupMenu | ( | WPopupMenu * | menu ) |
Sets a sub menu for the item.
Sets a submenu for the item. Ownership of the submenu is transferred to the item.