Use Bind() instead of Connect() in wxWidgets code

Use more modern function which allows to avoid wxXXXEventHandler()
macros use.

No real changes.
This commit is contained in:
Vadim Zeitlin
2018-05-28 22:10:56 +02:00
parent 8c8ff2c24d
commit d4f380e16e
48 changed files with 168 additions and 363 deletions

View File

@@ -172,11 +172,7 @@ protected:
// Default ctor sets things up for handling children events correctly.
wxCompositeWindow()
{
this->Connect
(
wxEVT_CREATE,
wxWindowCreateEventHandler(wxCompositeWindow::OnWindowCreate)
);
this->Bind(wxEVT_CREATE, &wxCompositeWindow::OnWindowCreate, this);
}
private:
@@ -191,15 +187,11 @@ private:
wxWindow *child = event.GetWindow();
if ( child == this )
return; // not a child, we don't want to Connect() to ourselves
return; // not a child, we don't want to bind to ourselves
child->Connect(wxEVT_SET_FOCUS,
wxFocusEventHandler(wxCompositeWindow::OnSetFocus),
NULL, this);
child->Bind(wxEVT_SET_FOCUS, &wxCompositeWindow::OnSetFocus, this);
child->Connect(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxCompositeWindow::OnKillFocus),
NULL, this);
child->Bind(wxEVT_KILL_FOCUS, &wxCompositeWindow::OnKillFocus, this);
// Some events should be only handled for non-toplevel children. For
// example, we want to close the control in wxDataViewCtrl when Enter
@@ -213,9 +205,7 @@ private:
win = win->GetParent();
}
child->Connect(wxEVT_CHAR,
wxKeyEventHandler(wxCompositeWindow::OnChar),
NULL, this);
child->Bind(wxEVT_CHAR, &wxCompositeWindow::OnChar, this);
}
void OnChar(wxKeyEvent& event)

View File

@@ -199,14 +199,13 @@ public:
m_container.SetContainerWindow(this);
#ifndef wxHAS_NATIVE_TAB_TRAVERSAL
BaseWindowClass::Connect(wxEVT_NAVIGATION_KEY,
wxNavigationKeyEventHandler(wxNavigationEnabled::OnNavigationKey));
BaseWindowClass::Bind(wxEVT_NAVIGATION_KEY,
&wxNavigationEnabled::OnNavigationKey, this);
BaseWindowClass::Connect(wxEVT_SET_FOCUS,
wxFocusEventHandler(wxNavigationEnabled::OnFocus));
BaseWindowClass::Connect(wxEVT_CHILD_FOCUS,
wxChildFocusEventHandler(wxNavigationEnabled::OnChildFocus));
BaseWindowClass::Bind(wxEVT_SET_FOCUS,
&wxNavigationEnabled::OnFocus, this);
BaseWindowClass::Bind(wxEVT_CHILD_FOCUS,
&wxNavigationEnabled::OnChildFocus, this);
#endif // !wxHAS_NATIVE_TAB_TRAVERSAL
}

View File

@@ -712,10 +712,8 @@ public:
if ( !BaseClass::Create(parent, id, title, pos, size, style, name) )
return false;
this->Connect(wxEVT_ACTIVATE,
wxActivateEventHandler(wxDocChildFrameAny::OnActivate));
this->Connect(wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(wxDocChildFrameAny::OnCloseWindow));
this->Bind(wxEVT_ACTIVATE, &wxDocChildFrameAny::OnActivate, this);
this->Bind(wxEVT_CLOSE_WINDOW, &wxDocChildFrameAny::OnCloseWindow, this);
return true;
}
@@ -867,10 +865,8 @@ public:
if ( !BaseFrame::Create(frame, id, title, pos, size, style, name) )
return false;
this->Connect(wxID_EXIT, wxEVT_MENU,
wxCommandEventHandler(wxDocParentFrameAny::OnExit));
this->Connect(wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(wxDocParentFrameAny::OnCloseWindow));
this->Bind(wxEVT_MENU, &wxDocParentFrameAny::OnExit, this, wxID_EXIT);
this->Bind(wxEVT_CLOSE_WINDOW, &wxDocParentFrameAny::OnCloseWindow, this);
return true;
}

View File

@@ -277,9 +277,8 @@ public: // overrides
virtual void DoConnect( wxControl *sender, wxFileDirPickerCtrlBase *eventSink ) wxOVERRIDE
{
sender->Connect( wxEVT_FILEPICKER_CHANGED,
wxFileDirPickerEventHandler( wxFileDirPickerCtrlBase::OnFileDirChange ),
NULL, eventSink );
sender->Bind(wxEVT_FILEPICKER_CHANGED,
&wxFileDirPickerCtrlBase::OnFileDirChange, eventSink );
}
@@ -377,9 +376,8 @@ public: // overrides
virtual void DoConnect( wxControl *sender, wxFileDirPickerCtrlBase *eventSink ) wxOVERRIDE
{
sender->Connect( wxEVT_DIRPICKER_CHANGED,
wxFileDirPickerEventHandler( wxFileDirPickerCtrlBase::OnFileDirChange ),
NULL, eventSink );
sender->Bind( wxEVT_DIRPICKER_CHANGED,
&wxFileDirPickerCtrlBase::OnFileDirChange, eventSink );
}

View File

@@ -67,18 +67,18 @@ protected:
if ( m_bitmapBg.IsOk() )
{
BaseWindowClass::Connect
BaseWindowClass::Bind
(
wxEVT_ERASE_BACKGROUND,
wxEraseEventHandler(wxCustomBackgroundWindow::OnEraseBackground)
&wxCustomBackgroundWindow::OnEraseBackground, this
);
}
else
{
BaseWindowClass::Disconnect
BaseWindowClass::Unbind
(
wxEVT_ERASE_BACKGROUND,
wxEraseEventHandler(wxCustomBackgroundWindow::OnEraseBackground)
&wxCustomBackgroundWindow::OnEraseBackground, this
);
}
}