# WoopsiUI::ContextMenu Class Reference

`#include <contextmenu.h>`

Inheritance diagram for WoopsiUI::ContextMenu:

List of all members.

## Public Member Functions
| ContextMenu (GadgetStyle *style=NULL)
virtual void | addOption (const WoopsiString &text, u32 value)
virtual void | reset ()
void | setOpener (Gadget *gadget)
Gadget * | getOpener ()
virtual void | getPreferredDimensions (Rect &rect) const
virtual void | handleReleaseEvent (const GadgetEventArgs &e)
virtual void | handleReleaseOutsideEvent (const GadgetEventArgs &e)

## Detailed Description

The context menu is implemented as a member of the Woopsi class. It should not be instantiated elsewhere. It offers a simple context-aware menu that opens when the user holds down a modifier key when tapping a gadget.

## Constructor & Destructor Documentation

WoopsiUI::ContextMenu::ContextMenu | ( | GadgetStyle * | style = `NULL` | ) |

Constructor.

Parameters:

  | style | The style that the gadget should use. If this is not specified, the gadget will use the values stored in the global defaultGadgetStyle object. The gadget will copy the properties of the style into its own internal style object.

## Member Function Documentation

virtual void WoopsiUI::ContextMenu::addOption | ( | const WoopsiString & | text,
|  | u32 | value |
| ) |  |  | `[virtual]`

Add a new menu item to the gadget.

Parameters:

  | text | Text to show in the item.
  | value | The value of the item.

Gadget* WoopsiUI::ContextMenu::getOpener | ( |  | ) | `[inline]`

Get the gadget that opened the menu.

Returns:
  Pointer to the gadget that opened the menu.

virtual void WoopsiUI::ContextMenu::getPreferredDimensions | ( | Rect & | rect | ) | const`[virtual]`

Insert the dimensions that this gadget wants to have into the rect passed in as a parameter. All co-ordinates are relative to the gadget's parent. Value is based on the length of the largest string in the set of options.

Parameters:

  | rect | Reference to a rect to populate with data.

Reimplemented from WoopsiUI::Gadget.

virtual void WoopsiUI::ContextMenu::handleReleaseEvent | ( | const GadgetEventArgs & | e | ) | `[virtual]`

Handles events raised by the gadget's sub-gadgets.

Parameters:

  | e | The event arguments.

Reimplemented from WoopsiUI::GadgetEventHandler.

virtual void WoopsiUI::ContextMenu::handleReleaseOutsideEvent | ( | const GadgetEventArgs & | e | ) | `[virtual]`

Handles events raised by the gadget's sub-gadgets.

Parameters:

  | e | The event arguments.

Reimplemented from WoopsiUI::GadgetEventHandler.

virtual void WoopsiUI::ContextMenu::reset | ( |  | ) | `[virtual]`

Clear all items from the menu and reset it.

void WoopsiUI::ContextMenu::setOpener | ( | Gadget * | gadget | ) | `[inline]`

Set the gadget that opened the menu.

Parameters:

  | gadget | Pointer to the gadget that opened the menu.

The documentation for this class was generated from the following file:

- contextmenu.h