#include <Menu.h>
Public Member Functions | |
MenuItem () | |
MenuItem (const String &text, CommandId id, Keys::Type defaultShortcut=Keys::None) | |
Creates a new menu item. | |
virtual | ~MenuItem () |
Menu * | getParent () |
Menu * | getRoot () |
CommandId | getId () |
const String & | getText () |
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 MenuItem * | checkShortcuts (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 | |
Menu * | m_parent |
String | m_text |
CommandId | m_id |
std::vector< Keys::Type > | m_shortcuts |
bool | m_enabled: 1 |
bool | m_checked: 1 |
Friends | |
class | Frame |
class | Menu |
MenuItem::MenuItem | ( | ) |
MenuItem::MenuItem | ( | const String & | text, | |
CommandId | id, | |||
Keys::Type | defaultShortcut = Keys::None | |||
) |
Creates a new menu item.
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] |
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.
friend class Frame [friend] |
Reimplemented in Vaca::MenuBar.
friend class Menu [friend] |
Menu* Vaca::MenuItem::m_parent [private] |
String Vaca::MenuItem::m_text [private] |
CommandId Vaca::MenuItem::m_id [private] |
std::vector<Keys::Type> Vaca::MenuItem::m_shortcuts [private] |
bool Vaca::MenuItem::m_enabled [private] |
bool Vaca::MenuItem::m_checked [private] |