Make some non-mutating hotkey methods const.

Originally committed to SVN as r3852.
This commit is contained in:
Thomas Goyne 2009-12-05 04:26:07 +00:00
parent c3a6fbae6e
commit fc75937466
2 changed files with 14 additions and 16 deletions

View File

@ -74,7 +74,7 @@ HotkeyType::HotkeyType(wxString text,wxString name) {
/// @brief Get string of hotkey /// @brief Get string of hotkey
/// @return /// @return
/// ///
wxString HotkeyType::GetText() { wxString HotkeyType::GetText() const {
wxString text; wxString text;
// Modifiers // Modifiers
@ -539,10 +539,10 @@ void HotkeyManager::SetFile(wxString file) {
/// @param function /// @param function
/// @return /// @return
/// ///
wxString HotkeyManager::GetText(wxString function) { const wxString HotkeyManager::GetText(wxString function) const {
std::map<wxString,HotkeyType>::iterator cur = key.find(function.Lower()); std::map<wxString,HotkeyType>::const_iterator cur = key.find(function.Lower());
if (cur != key.end()) { if (cur != key.end()) {
return (*cur).second.GetText(); return cur->second.GetText();
} }
else throw _T("Hotkey not defined"); else throw _T("Hotkey not defined");
} }
@ -554,10 +554,10 @@ wxString HotkeyManager::GetText(wxString function) {
/// @param id /// @param id
/// @return /// @return
/// ///
wxAcceleratorEntry HotkeyManager::GetAccelerator(wxString function,int id) { wxAcceleratorEntry HotkeyManager::GetAccelerator(wxString function,int id) const {
std::map<wxString,HotkeyType>::iterator cur = key.find(function.Lower()); std::map<wxString,HotkeyType>::const_iterator cur = key.find(function.Lower());
if (cur != key.end()) { if (cur != key.end()) {
HotkeyType *hotkey = &(*cur).second; const HotkeyType *hotkey = &(*cur).second;
wxAcceleratorEntry entry; wxAcceleratorEntry entry;
entry.Set(hotkey->flags,hotkey->keycode,id); entry.Set(hotkey->flags,hotkey->keycode,id);
return entry; return entry;
@ -587,10 +587,10 @@ void HotkeyManager::SetPressed(int keypress,bool ctrl,bool alt,bool shift) {
/// @param function /// @param function
/// @return /// @return
/// ///
bool HotkeyManager::IsPressed(wxString function) { bool HotkeyManager::IsPressed(wxString function) const {
std::map<wxString,HotkeyType>::iterator cur = key.find(function.Lower()); std::map<wxString,HotkeyType>::const_iterator cur = key.find(function.Lower());
if (cur != key.end()) { if (cur != key.end()) {
HotkeyType *hotkey = &(*cur).second; const HotkeyType *hotkey = &(*cur).second;
return (hotkey->keycode == lastKey && hotkey->flags == lastMod); return (hotkey->keycode == lastKey && hotkey->flags == lastMod);
} }
else throw _T("Hotkey not defined"); else throw _T("Hotkey not defined");
@ -611,5 +611,3 @@ HotkeyType *HotkeyManager::Find(int keycode,int mod) {
return NULL; return NULL;
} }

View File

@ -74,7 +74,7 @@ public:
HotkeyType(wxString text,wxString name); HotkeyType(wxString text,wxString name);
void Parse(wxString text); void Parse(wxString text);
wxString GetText(); wxString GetText() const;
/// DOCME /// DOCME
@ -123,9 +123,9 @@ public:
void LoadDefaults(); void LoadDefaults();
HotkeyType *Find(int keycode,int mod); HotkeyType *Find(int keycode,int mod);
wxString GetText(wxString function); const wxString GetText(wxString function) const;
wxAcceleratorEntry GetAccelerator(wxString function,int id); wxAcceleratorEntry GetAccelerator(wxString function,int id) const;
bool IsPressed(wxString function); bool IsPressed(wxString function) const;
void SetPressed(int key,bool ctrl=false,bool alt=false,bool shift=false); void SetPressed(int key,bool ctrl=false,bool alt=false,bool shift=false);
}; };