utilities: Use Bind instead of Connect

This commit is contained in:
Jonathan Li 2016-06-16 20:37:31 +01:00
parent c10728319b
commit 3904c67e6e
7 changed files with 15 additions and 26 deletions

View File

@ -362,9 +362,3 @@ public:
protected: protected:
int _DoDialog() const; int _DoDialog() const;
}; };
typedef void (wxEvtHandler::*pxSyncronousEventFunction)(pxSynchronousCommandEvent&);
#define pxSynchronousEventHandler(func) \
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxSyncronousEventFunction, &func )

View File

@ -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: // Ensure that the right-side of the static group box isn't too cozy:
SetMinWidth( ThisToggle.GetSize().GetWidth() + 32 ); 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) // Event handler for click events for the main checkbox (default behavior: enables/disables all child controls)

View File

@ -41,7 +41,7 @@ Threading::WaitForTaskDialog::WaitForTaskDialog( const wxString& title, const wx
if( m_title.IsEmpty() ) m_title = _("Waiting for task..."); if( m_title.IsEmpty() ) m_title = _("Waiting for task...");
if( m_heading.IsEmpty() ) m_heading = m_title; if( m_heading.IsEmpty() ) m_heading = m_title;
Connect( pxEvt_ThreadedTaskComplete, wxCommandEventHandler(WaitForTaskDialog::OnTaskComplete) ); Bind(pxEvt_ThreadedTaskComplete, &WaitForTaskDialog::OnTaskComplete, this);
*this += 12; *this += 12;
*this += Heading(m_heading).Unwrapped() | StdExpand(); *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 += new wxButton( &applyDlg, wxID_CANCEL ) | pxCenter;
//applyDlg += 6; //applyDlg += 6;
//Connect( m_Timer.GetId(), wxEVT_TIMER, wxTimerEventHandler(WaitForTaskDialog::OnTimer) ); //Bind(wxEVT_TIMER, &WaitForTaskDialog::OnTimer, this, m_Timer.GetId());
//m_Timer.Start( 200 ); //m_Timer.Start( 200 );
//GetSysExecutorThread().PostEvent( new SysExecEvent_ApplyPlugins( this, m_sync ) ); //GetSysExecutorThread().PostEvent( new SysExecEvent_ApplyPlugins( this, m_sync ) );
} }

View File

@ -57,7 +57,7 @@ void pxCheckBox::Init(const wxString& label, const wxString& subtext, int flags)
*this += &spaced | pxExpand; *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 ) pxCheckBox& pxCheckBox::SetSubPadding( int pad )

View File

@ -46,7 +46,7 @@ void pxStaticText::Init( const wxString& label )
m_autowrap = true; m_autowrap = true;
m_wrappedWidth = -1; m_wrappedWidth = -1;
m_label = label; 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 // we need to refresh the window after changing its size as the standard

View File

@ -630,24 +630,19 @@ void wxAppWithHelpers::DeleteThread( pxThread& obj )
AddIdleEvent( evt ); AddIdleEvent( evt );
} }
typedef void (wxEvtHandler::*pxInvokeActionEventFunction)(pxActionEvent&);
bool wxAppWithHelpers::OnInit() bool wxAppWithHelpers::OnInit()
{ {
#define pxActionEventHandler(func) \ Bind(pxEvt_SynchronousCommand, &wxAppWithHelpers::OnSynchronousCommand, this);
(wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(pxInvokeActionEventFunction, &func ) Bind(pxEvt_InvokeAction, &wxAppWithHelpers::OnInvokeAction, this);
Connect( pxEvt_SynchronousCommand, pxSynchronousEventHandler (wxAppWithHelpers::OnSynchronousCommand) ); Bind(pxEvt_StartIdleEventTimer, &wxAppWithHelpers::OnStartIdleEventTimer, this);
Connect( pxEvt_InvokeAction, pxActionEventHandler (wxAppWithHelpers::OnInvokeAction) );
Connect( pxEvt_StartIdleEventTimer, wxCommandEventHandler (wxAppWithHelpers::OnStartIdleEventTimer) ); Bind(pxEvt_DeleteObject, &wxAppWithHelpers::OnDeleteObject, this);
Bind(pxEvt_DeleteThread, &wxAppWithHelpers::OnDeleteThread, this);
Connect( pxEvt_DeleteObject, wxCommandEventHandler (wxAppWithHelpers::OnDeleteObject) ); Bind(wxEVT_IDLE, &wxAppWithHelpers::OnIdleEvent, this);
Connect( pxEvt_DeleteThread, wxCommandEventHandler (wxAppWithHelpers::OnDeleteThread) );
Connect( wxEVT_IDLE, wxIdleEventHandler (wxAppWithHelpers::OnIdleEvent) ); Bind(wxEVT_TIMER, &wxAppWithHelpers::OnIdleEventTimeout, this, m_IdleEventTimer.GetId());
Connect( m_IdleEventTimer.GetId(), wxEVT_TIMER, wxTimerEventHandler(wxAppWithHelpers::OnIdleEventTimeout) );
return _parent::OnInit(); return _parent::OnInit();
} }

View File

@ -167,10 +167,10 @@ void wxDialogWithHelpers::Init( const pxDialogCreationFlags& cflags )
delete wxHelpProvider::Set( new wxSimpleHelpProvider() ); delete wxHelpProvider::Set( new wxSimpleHelpProvider() );
#endif #endif
Connect( pxEvt_OnDialogCreated, wxCommandEventHandler (wxDialogWithHelpers::OnDialogCreated) ); Bind(pxEvt_OnDialogCreated, &wxDialogWithHelpers::OnDialogCreated, this);
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) ); Bind(wxEVT_BUTTON, &wxDialogWithHelpers::OnOkCancel, this, wxID_OK);
Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) ); Bind(wxEVT_BUTTON, &wxDialogWithHelpers::OnOkCancel, this, wxID_CANCEL);
wxCommandEvent createEvent( pxEvt_OnDialogCreated ); wxCommandEvent createEvent( pxEvt_OnDialogCreated );
createEvent.SetId( GetId() ); createEvent.SetId( GetId() );