Wt::WMenuItem Class Reference

A single item in a menu. More...

Inheritance diagram for Wt::WMenuItem:

Inheritance graph
[legend]

List of all members.

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 WStringtext () const
 Get the text for this item.
virtual void setText (const WString &text)
 Set the text for this item.

Protected Member Functions

WWidgetitemWidget ()
 Get the widget that represents the item in the WMenu.
virtual void renderSelected (bool selected)
 Render the item selected or unselected.
virtual WWidgetcreateItemWidget ()
 Create the widget that represents the item in the WMenu.
virtual SignalBase & activateSignal ()
 Get the signal that will be used to activate the item.


Detailed Description

A single item in a menu.

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:

See also:
WMenu

WMenu::addItem(WMenuItem *)


Member Enumeration Documentation

enum Wt::WMenuItem::LoadPolicy

When should the contents be loaded ?

Enumerator:
LazyLoading  Lazy loading: on first use.
PreLoading  Pre-loading: before first use.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.


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