DolphinWX: Use normal instantiation of wxTimer in HotkeyDlg

This commit is contained in:
Lioncash 2014-09-01 13:44:16 -04:00
parent f8e24de833
commit 1ad3740770
2 changed files with 11 additions and 16 deletions

View File

@ -37,22 +37,19 @@ END_EVENT_TABLE()
HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title, HotkeyConfigDialog::HotkeyConfigDialog(wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &position, const wxSize& size, long style) const wxPoint &position, const wxSize& size, long style)
: wxDialog(parent, id, title, position, size, style) : wxDialog(parent, id, title, position, size, style)
, m_ButtonMappingTimer(this)
{ {
CreateHotkeyGUIControls(); CreateHotkeyGUIControls();
#if wxUSE_TIMER
m_ButtonMappingTimer = new wxTimer(this, wxID_ANY);
g_Pressed = 0; g_Pressed = 0;
g_Modkey = 0; g_Modkey = 0;
ClickedButton = nullptr; ClickedButton = nullptr;
GetButtonWaitingID = 0; GetButtonWaitingID = 0;
GetButtonWaitingTimer = 0; GetButtonWaitingTimer = 0;
#endif
} }
HotkeyConfigDialog::~HotkeyConfigDialog() HotkeyConfigDialog::~HotkeyConfigDialog()
{ {
delete m_ButtonMappingTimer;
} }
// Save keyboard key mapping // Save keyboard key mapping
@ -65,7 +62,7 @@ void HotkeyConfigDialog::SaveButtonMapping(int Id, int Key, int Modkey)
void HotkeyConfigDialog::EndGetButtons() void HotkeyConfigDialog::EndGetButtons()
{ {
wxTheApp->Unbind(wxEVT_KEY_DOWN, &HotkeyConfigDialog::OnKeyDown, this); wxTheApp->Unbind(wxEVT_KEY_DOWN, &HotkeyConfigDialog::OnKeyDown, this);
m_ButtonMappingTimer->Stop(); m_ButtonMappingTimer.Stop();
GetButtonWaitingTimer = 0; GetButtonWaitingTimer = 0;
GetButtonWaitingID = 0; GetButtonWaitingID = 0;
ClickedButton = nullptr; ClickedButton = nullptr;
@ -135,19 +132,17 @@ void HotkeyConfigDialog::DoGetButtons(int _GetId)
const int TimesPerSecond = 40; // How often to run the check const int TimesPerSecond = 40; // How often to run the check
// If the Id has changed or the timer is not running we should start one // If the Id has changed or the timer is not running we should start one
if ( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer->IsRunning() ) if ( GetButtonWaitingID != _GetId || !m_ButtonMappingTimer.IsRunning() )
{ {
if (m_ButtonMappingTimer->IsRunning()) if (m_ButtonMappingTimer.IsRunning())
m_ButtonMappingTimer->Stop(); m_ButtonMappingTimer.Stop();
// Save the button Id // Save the button Id
GetButtonWaitingID = _GetId; GetButtonWaitingID = _GetId;
GetButtonWaitingTimer = 0; GetButtonWaitingTimer = 0;
// Start the timer // Start the timer
#if wxUSE_TIMER m_ButtonMappingTimer.Start(1000 / TimesPerSecond);
m_ButtonMappingTimer->Start(1000 / TimesPerSecond);
#endif
} }
// Process results // Process results
@ -177,7 +172,7 @@ void HotkeyConfigDialog::OnButtonClick(wxCommandEvent& event)
{ {
event.Skip(); event.Skip();
if (m_ButtonMappingTimer->IsRunning()) if (m_ButtonMappingTimer.IsRunning())
return; return;
wxTheApp->Bind(wxEVT_KEY_DOWN, &HotkeyConfigDialog::OnKeyDown, this); wxTheApp->Bind(wxEVT_KEY_DOWN, &HotkeyConfigDialog::OnKeyDown, this);

View File

@ -9,6 +9,7 @@
#include <wx/event.h> #include <wx/event.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/string.h> #include <wx/string.h>
#include <wx/timer.h>
#include <wx/translation.h> #include <wx/translation.h>
#include <wx/windowid.h> #include <wx/windowid.h>
@ -20,7 +21,6 @@
#endif #endif
class wxButton; class wxButton;
class wxTimer;
class wxTimerEvent; class wxTimerEvent;
class wxWindow; class wxWindow;
@ -40,10 +40,10 @@ class HotkeyConfigDialog : public wxDialog
wxString OldLabel; wxString OldLabel;
wxButton *ClickedButton, wxButton *ClickedButton;
*m_Button_Hotkeys[NUM_HOTKEYS]; wxButton *m_Button_Hotkeys[NUM_HOTKEYS];
wxTimer *m_ButtonMappingTimer; wxTimer m_ButtonMappingTimer;
void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); } void OnButtonTimer(wxTimerEvent& WXUNUSED(event)) { DoGetButtons(GetButtonWaitingID); }
void OnButtonClick(wxCommandEvent& event); void OnButtonClick(wxCommandEvent& event);