#include <ax/ax_menu.h>
Inheritance diagram for AxMenuItem:
Public Member Functions | |
AxMenuItem (const AxMenuItem &item) | |
AxMenuItem () | |
AxMenuItem (const wxString &label, const wxString &descr, const wxString &id=wxEmptyString, AxActivator *activator=NULL) | |
Construct a menu item with label and description, and optional identifier and activator object. | |
~AxMenuItem () | |
void | Init () |
Member initialisation. | |
void | Copy (const AxMenuItem &item) |
void | operator= (const AxMenuItem &item) |
bool | operator== (const AxMenuItem &item) const |
virtual AxMenuItem * | Clone () const |
Override this function for derived classes. | |
void | SetSubMenu (AxMenu *menu) |
Sets the submenu. | |
AxMenu * | GetSubMenu () const |
Gets the submenu. | |
void | SetActivator (AxActivator *activator) |
Sets the activator object. The menu item will now own the object. | |
AxActivator * | GetActivator () const |
Gets the activator object. | |
void | SetValidator (AxValidator *validator) |
Sets the validator object. The menu item will now own the object. | |
AxValidator * | GetValidator () const |
Gets the validator object. | |
void | SetData (AxMenuItemData *data) |
Sets the data associated with the menu item. | |
AxMenuItemData * | GetData () const |
Gets the data associated with the menu item. | |
void | SetId (const wxString &id) |
Sets the string identifier associated with the menu item. | |
const wxString & | GetId () const |
Gets the string identifier associated with the menu item. | |
void | SetStyle (int style) |
Sets the menu item style. | |
int | GetStyle () const |
Gets the menu item style. | |
void | Enable (bool enable=true) |
Enables or disables the item. | |
bool | IsEnabled () const |
Returns true if the item is enabled. | |
void | SetDescription (const wxString &description) |
Sets the descriptive text. | |
const wxString & | GetDescription () const |
Gets the descriptive text. | |
void | SetLabel (const wxString &label) |
Sets the label. | |
const wxString & | GetLabel () const |
Gets the label. | |
void | SetParent (AxMenu *menu) |
Sets the parent menu. | |
AxMenu * | GetParent () const |
Gets the parent menu. | |
void | SetDynamic (bool dynamic=true) |
Marks the item as dynamic (the submenu should be recreated each time it is used). | |
bool | IsDynamic () const |
Returns true if the item is dynamic. | |
bool | IsStatic () const |
Returns true if the item is static. | |
int | GetPosition () const |
Get the zero-based position in the parent menu. | |
virtual bool | ProcessEvent (wxEvent &event) |
Processes the event, or sends it up the hierarchy. | |
virtual bool | TransferDataToMenu (bool recurse=false) |
Transfer data using validator, if any. | |
virtual bool | TransferDataFromMenu (bool recurse=false) |
Transfer data using validator, if any. | |
void | SetLabelSpec (const wxString &spec) |
Set menu item label spec, if any. | |
wxString | GetLabelSpec () const |
Gets menu item label spec, if any. | |
void | SetDescriptionSpec (const wxString &spec) |
Sets menu item description spec, if any. | |
wxString | GetDescriptionSpec () const |
Gets menu item description spec, if any. | |
void | SetKind (const wxString &kind) |
Optionally provide a short name used to describe the item. | |
const wxString & | GetKind () const |
Returns the kind of menu item, such as command, file selector, etc. | |
Protected Attributes | |
AxMenu * | m_subMenu |
AxMenuItemData * | m_data |
wxString | m_label |
wxString | m_kind |
wxString | m_id |
wxString | m_description |
AxMenu * | m_parent |
AxActivator * | m_activator |
AxValidator * | m_validator |
int | m_style |
bool | m_enabled |
bool | m_dynamic |
It has a label, a description, and a string identifier. It can be disabled or enabled, and it can contain a submenu.
If the menu item has an AxActivator object associated with it, AxActivator::Activate is called when the item is activated, for example by the user double-clicking on the item or pressing Return. Similarly, selecting the menu will cause AxActivator::Select to be called. AxActivator::Activate can return a submenu, which will be shown if non-NULL.
A menu item can be marked dynamic with AxMenuItem::SetDynamic. A dynamic item can have its submenu deleted by the system when not showing, and it also ensures that old information is not used - the submenu will be recreated every time it is invoked. If your item is static, be sure not to recreate its submenu every time - return AxMenItem::GetSubMenu after the first AxMenuItem::Activate call.
A menu item can contain an AxValidator object. AxValidator classes implement TransferDataFromMenu and TransferDataToMenu functions that get or set data using data objects specific to the AxValidator class. For example, the AxTextValidator class implemented in ax_menu_text.h
works with the AxTextMenuItem class. AxTextMenuItem stores a string that can be changed on activation; and without a validator, the text string will remain in the text menu item. But when a AxTextValidator is specified, created with a pointer to a wxString, the wxString value will be set when the user enters a new value.
Note that validator and activator objects should not be shared between different menu items. Always create new objects. Also, ensure that menu items can be copied correctly by implementing the Clone function for any derived AxMenuItem, AxActivator and AxValidator classes.
AxMenuItem::AxMenuItem | ( | const AxMenuItem & | item | ) | [inline] |
AxMenuItem::AxMenuItem | ( | ) | [inline] |
AxMenuItem::AxMenuItem | ( | const wxString & | label, | |
const wxString & | descr, | |||
const wxString & | id = wxEmptyString , |
|||
AxActivator * | activator = NULL | |||
) | [inline] |
Construct a menu item with label and description, and optional identifier and activator object.
AxMenuItem::~AxMenuItem | ( | ) |
void AxMenuItem::Init | ( | ) |
void AxMenuItem::Copy | ( | const AxMenuItem & | item | ) |
void AxMenuItem::operator= | ( | const AxMenuItem & | item | ) | [inline] |
bool AxMenuItem::operator== | ( | const AxMenuItem & | item | ) | const |
virtual AxMenuItem* AxMenuItem::Clone | ( | ) | const [inline, virtual] |
Override this function for derived classes.
Reimplemented in AxChoiceMenuItem, AxFolderMenuItem, AxFileMenuItem, AxTextMenuItem, AxResourceLibrarySettingsMenuItem, AxResourceLibraryAddByFolderMenuItem, and AxResourceLibraryAddByFileMenuItem.
void AxMenuItem::SetSubMenu | ( | AxMenu * | menu | ) |
Sets the submenu.
AxMenu* AxMenuItem::GetSubMenu | ( | ) | const [inline] |
Gets the submenu.
void AxMenuItem::SetActivator | ( | AxActivator * | activator | ) |
Sets the activator object. The menu item will now own the object.
AxActivator* AxMenuItem::GetActivator | ( | ) | const [inline] |
Gets the activator object.
void AxMenuItem::SetValidator | ( | AxValidator * | validator | ) |
Sets the validator object. The menu item will now own the object.
AxValidator* AxMenuItem::GetValidator | ( | ) | const [inline] |
Gets the validator object.
void AxMenuItem::SetData | ( | AxMenuItemData * | data | ) | [inline] |
Sets the data associated with the menu item.
This is not currently used and will probably be removed.
AxMenuItemData* AxMenuItem::GetData | ( | ) | const [inline] |
Gets the data associated with the menu item.
This is not currently used and will probably be removed.
void AxMenuItem::SetId | ( | const wxString & | id | ) | [inline] |
Sets the string identifier associated with the menu item.
Translate it to a wxWidgets integer identifier with the AxId macro or AxGetId function.
const wxString& AxMenuItem::GetId | ( | ) | const [inline] |
Gets the string identifier associated with the menu item.
void AxMenuItem::SetStyle | ( | int | style | ) | [inline] |
Sets the menu item style.
This is a bit list of the following values:
Reimplemented in AxFolderMenuItem.
int AxMenuItem::GetStyle | ( | ) | const [inline] |
void AxMenuItem::Enable | ( | bool | enable = true |
) | [inline] |
Enables or disables the item.
The item will be displayed with a grey label, and activation will not be possible.
bool AxMenuItem::IsEnabled | ( | ) | const [inline] |
Returns true if the item is enabled.
void AxMenuItem::SetDescription | ( | const wxString & | description | ) | [inline] |
Sets the descriptive text.
This will appear beneath the menu control, in the standard user interface.
const wxString& AxMenuItem::GetDescription | ( | ) | const [inline] |
Gets the descriptive text.
void AxMenuItem::SetLabel | ( | const wxString & | label | ) | [inline] |
Sets the label.
const wxString& AxMenuItem::GetLabel | ( | ) | const [inline] |
Gets the label.
void AxMenuItem::SetParent | ( | AxMenu * | menu | ) | [inline] |
Sets the parent menu.
AxMenu* AxMenuItem::GetParent | ( | ) | const [inline] |
Gets the parent menu.
void AxMenuItem::SetDynamic | ( | bool | dynamic = true |
) | [inline] |
Marks the item as dynamic (the submenu should be recreated each time it is used).
A dynamic menu item should return a new submenu every time its associated AxActivator::Activate function is called.
bool AxMenuItem::IsDynamic | ( | ) | const [inline] |
Returns true if the item is dynamic.
bool AxMenuItem::IsStatic | ( | ) | const [inline] |
Returns true if the item is static.
int AxMenuItem::GetPosition | ( | ) | const |
Get the zero-based position in the parent menu.
bool AxMenuItem::ProcessEvent | ( | wxEvent & | event | ) | [virtual] |
Processes the event, or sends it up the hierarchy.
bool AxMenuItem::TransferDataToMenu | ( | bool | recurse = false |
) | [virtual] |
Transfer data using validator, if any.
bool AxMenuItem::TransferDataFromMenu | ( | bool | recurse = false |
) | [virtual] |
Transfer data using validator, if any.
void AxMenuItem::SetLabelSpec | ( | const wxString & | spec | ) |
Set menu item label spec, if any.
This will be used by menu item classes that support keywords in labels and descriptions.
Reimplemented in AxChoiceMenuItem.
wxString AxMenuItem::GetLabelSpec | ( | ) | const |
void AxMenuItem::SetDescriptionSpec | ( | const wxString & | spec | ) |
Sets menu item description spec, if any.
This will be used by menu item classes that support keywords in labels and descriptions.
Reimplemented in AxChoiceMenuItem.
wxString AxMenuItem::GetDescriptionSpec | ( | ) | const |
void AxMenuItem::SetKind | ( | const wxString & | kind | ) | [inline] |
Optionally provide a short name used to describe the item.
By default, this is empty, in order not to clutter speech unnecessarily. But you might want to provide it to indicate the kind of operation the user might expect, without needing to describe it in detail. For example, a toggle item sets the kind to "toggle".
const wxString& AxMenuItem::GetKind | ( | ) | const [inline] |
Returns the kind of menu item, such as command, file selector, etc.
AxMenu* AxMenuItem::m_subMenu [protected] |
AxMenuItemData* AxMenuItem::m_data [protected] |
wxString AxMenuItem::m_label [protected] |
wxString AxMenuItem::m_kind [protected] |
wxString AxMenuItem::m_id [protected] |
wxString AxMenuItem::m_description [protected] |
AxMenu* AxMenuItem::m_parent [protected] |
AxActivator* AxMenuItem::m_activator [protected] |
AxValidator* AxMenuItem::m_validator [protected] |
int AxMenuItem::m_style [protected] |
Reimplemented in AxFolderMenuItem.
bool AxMenuItem::m_enabled [protected] |
bool AxMenuItem::m_dynamic [protected] |