Vaca::MenuItem Class Reference

#include <Menu.h>

Inheritance diagram for Vaca::MenuItem:

Vaca::Component Vaca::Referenceable Vaca::NonCopyable Vaca::Menu Vaca::MenuSeparator Vaca::MdiListMenu Vaca::MenuBar Vaca::PopupMenu

List of all members.


Detailed Description

A menu item.

Public Member Functions

 MenuItem ()
 MenuItem (const String &text, CommandId id, Keys::Type defaultShortcut=Keys::None)
 Creates a new menu item.
virtual ~MenuItem ()
MenugetParent ()
MenugetRoot ()
CommandId getId ()
const StringgetText ()
void setText (const String &text)
void setId (CommandId id)
bool isEnabled ()
void setEnabled (bool state)
bool isChecked ()
void setChecked (bool state)
void setRadio (bool state)
 Radio MenuItem groups are automatically delimited by MenuSeparator or by the beginning and the end of the menu.
void addShortcut (Keys::Type shortcut)
virtual MenuItemcheckShortcuts (Keys::Type pressedKey)
virtual bool isMenu () const
virtual bool isSeparator () const
virtual bool isMdiList () const

Protected Member Functions

virtual void onAction (MenuItemEvent &ev)
 It's called when the menu item is selected.
virtual void onUpdate (MenuItemEvent &ev)
 It's called when a menu is shown for first time.

Private Attributes

Menum_parent
String m_text
CommandId m_id
std::vector< Keys::Typem_shortcuts
bool m_enabled: 1
bool m_checked: 1

Friends

class Frame
class Menu

Constructor & Destructor Documentation

MenuItem::MenuItem (  ) 

MenuItem::MenuItem ( const String text,
CommandId  id,
Keys::Type  defaultShortcut = Keys::None 
)

Creates a new menu item.

Parameters:
text You can use the & character to underline a letter (e.g.: "&New")
defaultShortcut The default keyboard shortcut for this menu item.
id You can use an specified CommandId for the menu.

MenuItem::~MenuItem (  )  [virtual]


Member Function Documentation

Menu * MenuItem::getParent (  ) 

Menu * MenuItem::getRoot (  ) 

CommandId MenuItem::getId (  ) 

const String & MenuItem::getText (  ) 

void MenuItem::setText ( const String text  ) 

void MenuItem::setId ( CommandId  id  ) 

bool MenuItem::isEnabled (  ) 

void MenuItem::setEnabled ( bool  state  ) 

bool MenuItem::isChecked (  ) 

void MenuItem::setChecked ( bool  state  ) 

void MenuItem::setRadio ( bool  state  ) 

Radio MenuItem groups are automatically delimited by MenuSeparator or by the beginning and the end of the menu.

void MenuItem::addShortcut ( Keys::Type  shortcut  ) 

MenuItem * MenuItem::checkShortcuts ( Keys::Type  pressedKey  )  [virtual]

Reimplemented in Vaca::Menu.

bool MenuItem::isMenu (  )  const [virtual]

Reimplemented in Vaca::Menu.

bool MenuItem::isSeparator (  )  const [virtual]

Reimplemented in Vaca::MenuSeparator.

bool MenuItem::isMdiList (  )  const [virtual]

Reimplemented in Vaca::MdiListMenu.

void MenuItem::onAction ( MenuItemEvent ev  )  [protected, virtual]

It's called when the menu item is selected.

Also it's called when some keyboard shortcut of this MenuItem is pressed (MenuItem::m_shortcuts). Remember that onAction() is called only after an onUpdate() and only if it leaves the MenuItem enabled (see setEnabled() method),

void MenuItem::onUpdate ( MenuItemEvent ev  )  [protected, virtual]

It's called when a menu is shown for first time.

Also when the user press a keyboard shortcut (MenuItem::m_shortcuts) it's called to known if the item is available after execute onAction().

Internally, when the WM_INITMENU message is received, a Frame calls this event.

The default implementation search for a Command with ID equal to MenuItem::getId, so the Command::isEnabled routine will be called to change the state of this MenuItem.


Friends And Related Function Documentation

friend class Frame [friend]

Reimplemented in Vaca::MenuBar.

friend class Menu [friend]


Member Data Documentation

std::vector<Keys::Type> Vaca::MenuItem::m_shortcuts [private]

bool Vaca::MenuItem::m_enabled [private]

bool Vaca::MenuItem::m_checked [private]