From 3904c67e6e4388175539e9e9be75723ca978b522 Mon Sep 17 00:00:00 2001 From: Jonathan Li Date: Thu, 16 Jun 2016 20:37:31 +0100 Subject: [PATCH] utilities: Use Bind instead of Connect --- common/include/Utilities/pxEvents.h | 6 ------ common/src/Utilities/CheckedStaticBox.cpp | 2 +- common/src/Utilities/ThreadingDialogs.cpp | 4 ++-- common/src/Utilities/pxCheckBox.cpp | 2 +- common/src/Utilities/pxStaticText.cpp | 2 +- common/src/Utilities/wxAppWithHelpers.cpp | 19 +++++++------------ common/src/Utilities/wxHelpers.cpp | 6 +++--- 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/common/include/Utilities/pxEvents.h b/common/include/Utilities/pxEvents.h index a36c3c04fc..feb17b85af 100644 --- a/common/include/Utilities/pxEvents.h +++ b/common/include/Utilities/pxEvents.h @@ -362,9 +362,3 @@ public: protected: int _DoDialog() const; }; - - -typedef void (wxEvtHandler::*pxSyncronousEventFunction)(pxSynchronousCommandEvent&); - -#define pxSynchronousEventHandler(func) \ - (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxSyncronousEventFunction, &func ) diff --git a/common/src/Utilities/CheckedStaticBox.cpp b/common/src/Utilities/CheckedStaticBox.cpp index ac91bab6d8..ee26175904 100644 --- a/common/src/Utilities/CheckedStaticBox.cpp +++ b/common/src/Utilities/CheckedStaticBox.cpp @@ -27,7 +27,7 @@ CheckedStaticBox::CheckedStaticBox( wxWindow* parent, int orientation, const wxS // Ensure that the right-side of the static group box isn't too cozy: SetMinWidth( ThisToggle.GetSize().GetWidth() + 32 ); - Connect( ThisToggle.GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( CheckedStaticBox::MainToggle_Click ) ); + Bind(wxEVT_CHECKBOX, &CheckedStaticBox::MainToggle_Click, this, ThisToggle.GetId()); } // Event handler for click events for the main checkbox (default behavior: enables/disables all child controls) diff --git a/common/src/Utilities/ThreadingDialogs.cpp b/common/src/Utilities/ThreadingDialogs.cpp index 77e2c6b6bc..1871f4cde0 100644 --- a/common/src/Utilities/ThreadingDialogs.cpp +++ b/common/src/Utilities/ThreadingDialogs.cpp @@ -41,7 +41,7 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx if( m_title.IsEmpty() ) m_title = _("Waiting for task..."); if( m_heading.IsEmpty() ) m_heading = m_title; - Connect( pxEvt_ThreadedTaskComplete, wxCommandEventHandler(WaitForTaskDialog::OnTaskComplete) ); + Bind(pxEvt_ThreadedTaskComplete, &WaitForTaskDialog::OnTaskComplete, this); *this += 12; *this += Heading(m_heading).Unwrapped() | StdExpand(); @@ -53,7 +53,7 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx //applyDlg += new wxButton( &applyDlg, wxID_CANCEL ) | pxCenter; //applyDlg += 6; - //Connect( m_Timer.GetId(), wxEVT_TIMER, wxTimerEventHandler(WaitForTaskDialog::OnTimer) ); + //Bind(wxEVT_TIMER, &WaitForTaskDialog::OnTimer, this, m_Timer.GetId()); //m_Timer.Start( 200 ); //GetSysExecutorThread().PostEvent( new SysExecEvent_ApplyPlugins( this, m_sync ) ); } diff --git a/common/src/Utilities/pxCheckBox.cpp b/common/src/Utilities/pxCheckBox.cpp index 26bfa224ee..98888e7ed2 100644 --- a/common/src/Utilities/pxCheckBox.cpp +++ b/common/src/Utilities/pxCheckBox.cpp @@ -57,7 +57,7 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext, int flags) *this += &spaced | pxExpand; } - Connect( m_checkbox->GetId(), wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler(pxCheckBox::OnCheckpartCommand) ); + Bind(wxEVT_CHECKBOX, &pxCheckBox::OnCheckpartCommand, this, m_checkbox->GetId()); } pxCheckBox& pxCheckBox::SetSubPadding( int pad ) diff --git a/common/src/Utilities/pxStaticText.cpp b/common/src/Utilities/pxStaticText.cpp index f16d77c292..ec45804b36 100644 --- a/common/src/Utilities/pxStaticText.cpp +++ b/common/src/Utilities/pxStaticText.cpp @@ -46,7 +46,7 @@ void pxStaticText::Init( const wxString& label ) m_autowrap = true; m_wrappedWidth = -1; m_label = label; - Connect( wxEVT_PAINT, wxPaintEventHandler(pxStaticText::paintEvent) ); + Bind(wxEVT_PAINT, &pxStaticText::paintEvent, this); } // we need to refresh the window after changing its size as the standard diff --git a/common/src/Utilities/wxAppWithHelpers.cpp b/common/src/Utilities/wxAppWithHelpers.cpp index ba89c8d7b6..f2c9157a38 100644 --- a/common/src/Utilities/wxAppWithHelpers.cpp +++ b/common/src/Utilities/wxAppWithHelpers.cpp @@ -630,24 +630,19 @@ void wxAppWithHelpers::DeleteThread( pxThread& obj ) AddIdleEvent( evt ); } -typedef void (wxEvtHandler::*pxInvokeActionEventFunction)(pxActionEvent&); - bool wxAppWithHelpers::OnInit() { -#define pxActionEventHandler(func) \ - (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxInvokeActionEventFunction, &func ) + Bind(pxEvt_SynchronousCommand, &wxAppWithHelpers::OnSynchronousCommand, this); + Bind(pxEvt_InvokeAction, &wxAppWithHelpers::OnInvokeAction, this); - Connect( pxEvt_SynchronousCommand, pxSynchronousEventHandler (wxAppWithHelpers::OnSynchronousCommand) ); - Connect( pxEvt_InvokeAction, pxActionEventHandler (wxAppWithHelpers::OnInvokeAction) ); + Bind(pxEvt_StartIdleEventTimer, &wxAppWithHelpers::OnStartIdleEventTimer, this); - Connect( pxEvt_StartIdleEventTimer, wxCommandEventHandler (wxAppWithHelpers::OnStartIdleEventTimer) ); + Bind(pxEvt_DeleteObject, &wxAppWithHelpers::OnDeleteObject, this); + Bind(pxEvt_DeleteThread, &wxAppWithHelpers::OnDeleteThread, this); - Connect( pxEvt_DeleteObject, wxCommandEventHandler (wxAppWithHelpers::OnDeleteObject) ); - Connect( pxEvt_DeleteThread, wxCommandEventHandler (wxAppWithHelpers::OnDeleteThread) ); + Bind(wxEVT_IDLE, &wxAppWithHelpers::OnIdleEvent, this); - Connect( wxEVT_IDLE, wxIdleEventHandler (wxAppWithHelpers::OnIdleEvent) ); - - Connect( m_IdleEventTimer.GetId(), wxEVT_TIMER, wxTimerEventHandler(wxAppWithHelpers::OnIdleEventTimeout) ); + Bind(wxEVT_TIMER, &wxAppWithHelpers::OnIdleEventTimeout, this, m_IdleEventTimer.GetId()); return _parent::OnInit(); } diff --git a/common/src/Utilities/wxHelpers.cpp b/common/src/Utilities/wxHelpers.cpp index ae0acc693f..8654db4edd 100644 --- a/common/src/Utilities/wxHelpers.cpp +++ b/common/src/Utilities/wxHelpers.cpp @@ -167,10 +167,10 @@ void wxDialogWithHelpers::Init( const pxDialogCreationFlags& cflags ) delete wxHelpProvider::Set( new wxSimpleHelpProvider() ); #endif - Connect( pxEvt_OnDialogCreated, wxCommandEventHandler (wxDialogWithHelpers::OnDialogCreated) ); + Bind(pxEvt_OnDialogCreated, &wxDialogWithHelpers::OnDialogCreated, this); - Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) ); - Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) ); + Bind(wxEVT_BUTTON, &wxDialogWithHelpers::OnOkCancel, this, wxID_OK); + Bind(wxEVT_BUTTON, &wxDialogWithHelpers::OnOkCancel, this, wxID_CANCEL); wxCommandEvent createEvent( pxEvt_OnDialogCreated ); createEvent.SetId( GetId() );