Public Types | |
enum | LoadPolicy { LazyLoading, PreLoading } |
When should the contents be loaded ? More... | |
Public Slots | |
void | select () |
Select this item. | |
Public Member Functions | |
WMenuItem (const WString &text, WWidget *contents, LoadPolicy policy) | |
Create a new WMenuItem. | |
const WString & | text () const |
Get the text for this item. | |
virtual void | setText (const WString &text) |
Set the text for this item. | |
Protected Member Functions | |
WWidget * | itemWidget () |
Get the widget that represents the item in the WMenu. | |
virtual void | renderSelected (bool selected) |
Render the item selected or unselected. | |
virtual WWidget * | createItemWidget () |
Create the widget that represents the item in the WMenu. | |
virtual SignalBase & | activateSignal () |
Get the signal that will be used to activate the item. |
By default, a WMenuItem is rendered as a plain WText widget.
To provide another look for the menu items (such as perhaps adding an icon), you can specialize this class, and reimplement the virtual methods:
Wt::WMenuItem::WMenuItem | ( | const WString & | text, | |
WWidget * | contents, | |||
LoadPolicy | policy | |||
) |
Create a new WMenuItem.
The text specifies the item text. The contents is the widget that must be shown in the WMenu contents stack when the item is selected.
The load policy specifies whether the contents widgets is transmitted only when it the item is activated for the first time (LazyLoading) or transmitted prior to first rendering.
WWidget * Wt::WMenuItem::itemWidget | ( | ) | [protected] |
Get the widget that represents the item in the WMenu.
This returns the widget that was previously created using createItemWidget().
void Wt::WMenuItem::renderSelected | ( | bool | selected | ) | [protected, virtual] |
Render the item selected or unselected.
The default implementation will set the styleclass to 'item' for an unselected, and 'itemselected' for a selected item.
Note that this methods is called from within a stateless slot implementation, and thus should be stateless as well.
WWidget * Wt::WMenuItem::createItemWidget | ( | ) | [protected, virtual] |
Create the widget that represents the item in the WMenu.
The default implementation will create and return a WText representation, unless the menu has history tacking activated and the agent is a web spider. In that case, a WAnchor is will be used to create a link.
Note that if you reimplement this method, you should also reimplement setText(const WString&) and activateSignal().
SignalBase & Wt::WMenuItem::activateSignal | ( | ) | [protected, virtual] |
Get the signal that will be used to activate the item.
The default implementation will try to cast the itemWidget() to a WInteractWidget and bind the clicked signal.