#include <keybinder.h>
Classes | |
struct | wxCmdType |
A registered type of wxCmd-derived class. More... | |
Public Member Functions | |
wxCmd (const wxKeyBind &first, int id, const wxString &name=wxEmptyString, const wxString &desc=wxEmptyString) | |
wxCmd (int id=wxID_INVALID, const wxString &name=wxEmptyString, const wxString &desc=wxEmptyString) | |
virtual void | DeepCopy (const wxCmd *cmd) |
virtual wxCmd * | Clone () const =0 |
virtual | ~wxCmd () |
void | AddShortcut (const wxKeyBind &key) |
Adds the given key binding to this command. | |
void | AddShortcut (int flags, int keycode) |
Builds and adds a key binding to this command. | |
void | AddShortcut (const wxString &key) |
Builds and adds a key binding to this command using the given key description. | |
void | RemoveShortcut (int n) |
Removes the n-th key shortcut associated to this command. | |
void | RemoveAllShortcuts () |
Removes all the shortcuts associates to this command. | |
bool | MatchKey (const wxKeyEvent &ev) const |
Returns TRUE if at least one of the key bindings matches the given key event. | |
bool | IsBindTo (const wxKeyBind &key, int *n=NULL) const |
Returns TRUE if this command is bind to a wxKeyBind object identic to the given one. | |
bool | Save (wxConfigBase *p, const wxString &key=wxEmptyString, bool bCleanOld=FALSE) const |
Saves the command into the given wxConfig object in the given key entry. | |
bool | Load (wxConfigBase *p, const wxString &key=wxEmptyString) |
Loads from the given wxConfig's key a command. | |
wxKeyBind * | GetShortcut (int n) |
const wxKeyBind * | GetShortcut (int n) const |
wxAcceleratorEntry | GetAccelerator (int n) const |
int | GetId () const |
int | GetShortcutCount () const |
wxString | GetDescription () const |
wxString | GetName () const |
wxArrayString | GetShortcutsList () const |
virtual int | GetType () const =0 |
Returns the type ID for this wxCmd-derived class. | |
Static Public Member Functions | |
static wxCmd * | CreateNew (int type, int id) |
Creates a new command of the given type with the given ID. | |
static void | AddCmdType (int type, wxCmdCreationFnc fnc) |
Adds a new command type to our static list. | |
static wxCmdType * | FindCmdType (int type) |
Returns the wxCmdType associated with the given type ID. | |
Protected Types | |
typedef wxCmd *(* | wxCmdCreationFnc )(int id) |
The wxCmd-derived class creation function. | |
Protected Member Functions | |
virtual void | Update () |
Called after that an Add/Remove function is called. | |
virtual void | Exec (wxObject *obj, wxEvtHandler *client)=0 |
Executes the command. | |
Protected Attributes | |
wxKeyBind | m_keyShortcut [wxCMD_MAX_SHORTCUTS] |
The shortcuts. | |
int | m_nShortcuts |
The number of valid entries of m_keyShortcut. | |
wxString | m_strName |
The name of this command. This should be a short string. | |
wxString | m_strDescription |
The description associated with this command. | |
int | m_nId |
The ID which identifies this command. | |
Static Protected Attributes | |
static wxCmdType | m_arrCmdType [wxCMD_MAX_TYPES] |
The array of registered command types. | |
static int | m_nCmdTypes = 0 |
The number of registered command types. | |
Friends | |
class | wxKeyBinder |
This is an abstract class so it cannot be allocated directly: it is used instead as base class for specific type of wxCmd.
The command has up to wxCMD_MAX_SHORTCUTS associated key shortcuts. Besides, the command has three other properties: a description string, a name string and an ID which should be unique for each wxKeyBinder.
typedef wxCmd*(* wxCmd::wxCmdCreationFnc)(int id) [protected] |
The wxCmd-derived class creation function.
Such a function is required into wxCmd::Load.
wxCmd::wxCmd | ( | const wxKeyBind & | first, | |
int | id, | |||
const wxString & | name = wxEmptyString , |
|||
const wxString & | desc = wxEmptyString | |||
) | [inline] |
wxCmd::wxCmd | ( | int | id = wxID_INVALID , |
|
const wxString & | name = wxEmptyString , |
|||
const wxString & | desc = wxEmptyString | |||
) | [inline] |
virtual wxCmd::~wxCmd | ( | ) | [inline, virtual] |
void wxCmd::AddCmdType | ( | int | type, | |
wxCmdCreationFnc | fnc | |||
) | [static] |
Adds a new command type to our static list.
References wxCmd::wxCmdType::cmdCreateFnc, FindCmdType(), m_arrCmdType, m_nCmdTypes, and wxCmd::wxCmdType::type.
Referenced by wxMenuCmd::Register().
void wxCmd::AddShortcut | ( | const wxString & | key | ) | [inline] |
Builds and adds a key binding to this command using the given key description.
References wxCMD_MAX_SHORTCUTS.
void wxCmd::AddShortcut | ( | int | flags, | |
int | keycode | |||
) | [inline] |
void wxCmd::AddShortcut | ( | const wxKeyBind & | key | ) | [inline] |
Adds the given key binding to this command.
References wxCMD_MAX_SHORTCUTS.
Referenced by wxKeyBinder::AddShortcut(), Load(), and wxMenuShortcutWalker::OnMenuItemWalk().
virtual wxCmd* wxCmd::Clone | ( | ) | const [pure virtual] |
wxCmd * wxCmd::CreateNew | ( | int | type, | |
int | id | |||
) | [static] |
Creates a new command of the given type with the given ID.
This function is used mainly in wxCmd::Load.
type | The command type | |
id | The command ID |
References wxCmd::wxCmdType::cmdCreateFnc, FindCmdType(), and Update().
Referenced by wxKeyBinder::Load().
virtual void wxCmd::DeepCopy | ( | const wxCmd * | cmd | ) | [inline, virtual] |
Reimplemented in wxMenuCmd.
References m_keyShortcut, m_nId, m_nShortcuts, m_strDescription, and m_strName.
Referenced by wxMenuCmd::Clone(), and wxMenuCmd::DeepCopy().
virtual void wxCmd::Exec | ( | wxObject * | obj, | |
wxEvtHandler * | client | |||
) | [protected, pure virtual] |
Executes the command.
Implemented in wxMenuCmd.
Referenced by wxKeyBinder::OnChar().
wxCmd::wxCmdType * wxCmd::FindCmdType | ( | int | type | ) | [static] |
Returns the wxCmdType associated with the given type ID.
Returns NULL if no such type of wxCmd is registered.
References m_arrCmdType, and m_nCmdTypes.
Referenced by AddCmdType(), and CreateNew().
wxAcceleratorEntry wxCmd::GetAccelerator | ( | int | n | ) | const [inline] |
wxString wxCmd::GetDescription | ( | ) | const [inline] |
Referenced by Save(), and wxKeyConfigPanel::UpdateDesc().
int wxCmd::GetId | ( | ) | const [inline] |
Referenced by wxMenuCmd::Exec(), wxKeyConfigPanel::ImportKeyProfileCmd(), and wxKeyBinder::Save().
wxString wxCmd::GetName | ( | ) | const [inline] |
Referenced by wxKeyConfigPanel::ImportKeyProfileCmd(), wxKeyBinder::OnChar(), Save(), and wxKeyConfigPanel::UpdateButtons().
const wxKeyBind* wxCmd::GetShortcut | ( | int | n | ) | const [inline] |
wxKeyBind* wxCmd::GetShortcut | ( | int | n | ) | [inline] |
Referenced by wxKeyBinder::GetShortcut(), Save(), and wxMenuCmd::Update().
int wxCmd::GetShortcutCount | ( | ) | const [inline] |
Referenced by Save().
wxArrayString wxCmd::GetShortcutsList | ( | ) | const [inline] |
Referenced by wxKeyConfigPanel::FillInBindings(), and wxKeyBinder::GetShortcutsList().
virtual int wxCmd::GetType | ( | ) | const [pure virtual] |
Returns the type ID for this wxCmd-derived class.
Implemented in wxMenuCmd.
Referenced by wxKeyBinder::Save().
bool wxCmd::IsBindTo | ( | const wxKeyBind & | key, | |
int * | n = NULL | |||
) | const [inline] |
Returns TRUE if this command is bind to a wxKeyBind object identic to the given one.
If "n" is not NULL, it is set to the index of the entry which contains the given shortcut key (if there is such a shortcut registered in this class); otherwise it is left untouched.
Referenced by wxKeyConfigPanel::OnAssignKey(), and wxKeyBinder::OnChar().
bool wxCmd::Load | ( | wxConfigBase * | p, | |
const wxString & | key = wxEmptyString | |||
) |
Loads from the given wxConfig's key a command.
Returns FALSE if the given key does not contain info about this command's type.
References AddShortcut(), m_nId, m_strDescription, m_strName, Update(), and wxID_INVALID.
Referenced by wxKeyBinder::Load().
bool wxCmd::MatchKey | ( | const wxKeyEvent & | ev | ) | const [inline] |
Returns TRUE if at least one of the key bindings matches the given key event.
void wxCmd::RemoveAllShortcuts | ( | ) | [inline] |
Removes all the shortcuts associates to this command.
Referenced by wxKeyConfigPanel::OnRemoveAllKey().
void wxCmd::RemoveShortcut | ( | int | n | ) | [inline] |
Removes the n-th key shortcut associated to this command.
Referenced by wxKeyConfigPanel::OnAssignKey(), and wxKeyConfigPanel::OnRemoveKey().
bool wxCmd::Save | ( | wxConfigBase * | p, | |
const wxString & | key = wxEmptyString , |
|||
bool | bCleanOld = FALSE | |||
) | const |
Saves the command into the given wxConfig object in the given key entry.
bCleanOld | If TRUE, this function will erase the given key before writing into it. |
References GetDescription(), GetName(), GetShortcut(), GetShortcutCount(), and wxKeyBind::GetStr().
Referenced by wxKeyBinder::Save().
virtual void wxCmd::Update | ( | ) | [inline, protected, virtual] |
Called after that an Add/Remove function is called.
Default implementation does nothing.
Reimplemented in wxMenuCmd.
Referenced by CreateNew(), and Load().
friend class wxKeyBinder [friend] |
wxCmd::wxCmdType wxCmd::m_arrCmdType [static, protected] |
wxKeyBind wxCmd::m_keyShortcut[wxCMD_MAX_SHORTCUTS] [protected] |
int wxCmd::m_nCmdTypes = 0 [static, protected] |
int wxCmd::m_nId [protected] |
int wxCmd::m_nShortcuts [protected] |
wxString wxCmd::m_strDescription [protected] |
wxString wxCmd::m_strName [protected] |