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

@@ -146,14 +146,10 @@ public:
m_hasCapture = false;
m_spins = 1;
Connect( wxEVT_LEFT_DOWN,
wxMouseEventHandler(wxPGSpinButton::OnMouseEvent) );
Connect( wxEVT_LEFT_UP,
wxMouseEventHandler(wxPGSpinButton::OnMouseEvent) );
Connect( wxEVT_MOTION,
wxMouseEventHandler(wxPGSpinButton::OnMouseEvent) );
Connect( wxEVT_MOUSE_CAPTURE_LOST,
wxMouseCaptureLostEventHandler(wxPGSpinButton::OnMouseCaptureLost) );
Bind(wxEVT_LEFT_DOWN, &wxPGSpinButton::OnMouseEvent, this);
Bind(wxEVT_LEFT_UP, &wxPGSpinButton::OnMouseEvent, this);
Bind(wxEVT_MOTION, &wxPGSpinButton::OnMouseEvent, this);
Bind(wxEVT_MOUSE_CAPTURE_LOST, &wxPGSpinButton::OnMouseCaptureLost, this);
}
int GetSpins() const

View File

@@ -1048,10 +1048,8 @@ wxPropertyGridPage* wxPropertyGridManager::InsertPage( int index,
pageObj->m_toolId = tool->GetId();
// Connect to toolbar button events.
Connect(pageObj->GetToolId(),
wxEVT_TOOL,
wxCommandEventHandler(
wxPropertyGridManager::OnToolbarClick));
Bind(wxEVT_TOOL, &wxPropertyGridManager::OnToolbarClick, this,
pageObj->GetToolId());
m_pToolbar->Realize();
}
@@ -1541,10 +1539,8 @@ void wxPropertyGridManager::RecreateControls()
m_categorizedModeToolId = tool->GetId();
tbModified = true;
Connect(m_categorizedModeToolId,
wxEVT_TOOL,
wxCommandEventHandler(
wxPropertyGridManager::OnToolbarClick));
Bind(wxEVT_TOOL, &wxPropertyGridManager::OnToolbarClick, this,
m_categorizedModeToolId);
}
if (m_alphabeticModeToolId == -1)
@@ -1560,10 +1556,8 @@ void wxPropertyGridManager::RecreateControls()
m_alphabeticModeToolId = tool->GetId();
tbModified = true;
Connect(m_alphabeticModeToolId,
wxEVT_TOOL,
wxCommandEventHandler(
wxPropertyGridManager::OnToolbarClick));
Bind(wxEVT_TOOL, &wxPropertyGridManager::OnToolbarClick, this,
m_alphabeticModeToolId);
}
// Both buttons should exist here.
@@ -1574,10 +1568,8 @@ void wxPropertyGridManager::RecreateControls()
// Remove buttons if they exist.
if (m_categorizedModeToolId != -1)
{
Disconnect(m_categorizedModeToolId,
wxEVT_TOOL,
wxCommandEventHandler(
wxPropertyGridManager::OnToolbarClick));
Unbind(wxEVT_TOOL, &wxPropertyGridManager::OnToolbarClick, this,
m_categorizedModeToolId);
m_pToolbar->DeleteTool(m_categorizedModeToolId);
m_categorizedModeToolId = -1;
@@ -1586,10 +1578,8 @@ void wxPropertyGridManager::RecreateControls()
if (m_alphabeticModeToolId != -1)
{
Disconnect(m_alphabeticModeToolId,
wxEVT_TOOL,
wxCommandEventHandler(
wxPropertyGridManager::OnToolbarClick));
Unbind(wxEVT_TOOL, &wxPropertyGridManager::OnToolbarClick, this,
m_alphabeticModeToolId);
m_pToolbar->DeleteTool(m_alphabeticModeToolId);
m_alphabeticModeToolId = -1;
@@ -1943,18 +1933,18 @@ void wxPropertyGridManager::ReconnectEventHandlers(wxWindowID oldId, wxWindowID
if (oldId != wxID_NONE)
{
Disconnect(oldId, wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect));
Disconnect(oldId, wxEVT_PG_COL_DRAGGING,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag));
Unbind(wxEVT_PG_SELECTED, &wxPropertyGridManager::OnPropertyGridSelect, this,
oldId);
Unbind(wxEVT_PG_COL_DRAGGING, &wxPropertyGridManager::OnPGColDrag, this,
oldId);
}
if (newId != wxID_NONE)
{
Connect(newId, wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPropertyGridSelect));
Connect(newId, wxEVT_PG_COL_DRAGGING,
wxPropertyGridEventHandler(wxPropertyGridManager::OnPGColDrag));
Bind(wxEVT_PG_SELECTED, &wxPropertyGridManager::OnPropertyGridSelect, this,
newId);
Bind(wxEVT_PG_COL_DRAGGING, &wxPropertyGridManager::OnPGColDrag, this,
newId);
}
}

View File

@@ -1039,13 +1039,8 @@ void wxPropertyGrid::DoBeginLabelEdit( unsigned int colIndex,
0,
colIndex);
wxWindowID id = tc->GetId();
tc->Connect(id, wxEVT_TEXT_ENTER,
wxCommandEventHandler(wxPropertyGrid::OnLabelEditorEnterPress),
NULL, this);
tc->Connect(id, wxEVT_KEY_DOWN,
wxKeyEventHandler(wxPropertyGrid::OnLabelEditorKeyPress),
NULL, this);
tc->Bind(wxEVT_TEXT_ENTER, &wxPropertyGrid::OnLabelEditorEnterPress, this);
tc->Bind(wxEVT_KEY_DOWN, &wxPropertyGrid::OnLabelEditorKeyPress, this);
tc->SetFocus();
@@ -1227,9 +1222,7 @@ void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP )
// correct top-level window.
if ( m_tlp )
{
m_tlp->Disconnect( wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
NULL, this );
m_tlp->Unbind(wxEVT_CLOSE_WINDOW, &wxPropertyGrid::OnTLPClose, this);
m_tlpClosed = m_tlp;
m_tlpClosedTime = currentTime;
}
@@ -1240,9 +1233,7 @@ void wxPropertyGrid::OnTLPChanging( wxWindow* newTLP )
if ( newTLP != m_tlpClosed ||
m_tlpClosedTime+250 < currentTime )
{
newTLP->Connect( wxEVT_CLOSE_WINDOW,
wxCloseEventHandler(wxPropertyGrid::OnTLPClose),
NULL, this );
newTLP->Bind(wxEVT_CLOSE_WINDOW, &wxPropertyGrid::OnTLPClose, this);
m_tlpClosed = NULL;
}
else
@@ -3928,33 +3919,19 @@ void wxPropertyGrid::SetupChildEventHandling( wxWindow* argWnd )
if ( argWnd == m_wndEditor )
{
argWnd->Connect(id, wxEVT_MOTION,
wxMouseEventHandler(wxPropertyGrid::OnMouseMoveChild),
NULL, this);
argWnd->Connect(id, wxEVT_LEFT_UP,
wxMouseEventHandler(wxPropertyGrid::OnMouseUpChild),
NULL, this);
argWnd->Connect(id, wxEVT_LEFT_DOWN,
wxMouseEventHandler(wxPropertyGrid::OnMouseClickChild),
NULL, this);
argWnd->Connect(id, wxEVT_RIGHT_UP,
wxMouseEventHandler(wxPropertyGrid::OnMouseRightClickChild),
NULL, this);
argWnd->Connect(id, wxEVT_ENTER_WINDOW,
wxMouseEventHandler(wxPropertyGrid::OnMouseEntry),
NULL, this);
argWnd->Connect(id, wxEVT_LEAVE_WINDOW,
wxMouseEventHandler(wxPropertyGrid::OnMouseEntry),
NULL, this);
argWnd->Bind(wxEVT_MOTION, &wxPropertyGrid::OnMouseMoveChild, this, id);
argWnd->Bind(wxEVT_LEFT_UP, &wxPropertyGrid::OnMouseUpChild, this, id);
argWnd->Bind(wxEVT_LEFT_DOWN, &wxPropertyGrid::OnMouseClickChild, this, id);
argWnd->Bind(wxEVT_RIGHT_UP, &wxPropertyGrid::OnMouseRightClickChild, this, id);
argWnd->Bind(wxEVT_ENTER_WINDOW, &wxPropertyGrid::OnMouseEntry, this, id);
argWnd->Bind(wxEVT_LEAVE_WINDOW, &wxPropertyGrid::OnMouseEntry, this, id);
}
wxPropertyGridEditorEventForwarder* forwarder;
forwarder = new wxPropertyGridEditorEventForwarder(this);
argWnd->PushEventHandler(forwarder);
argWnd->Connect(id, wxEVT_KEY_DOWN,
wxCharEventHandler(wxPropertyGrid::OnChildKeyDown),
NULL, this);
argWnd->Bind(wxEVT_KEY_DOWN, &wxPropertyGrid::OnChildKeyDown, this, id);
}
void wxPropertyGrid::DeletePendingObjects()

View File

@@ -2471,38 +2471,25 @@ bool wxPGArrayEditorDialog::Create( wxWindow *parent,
arr.push_back(ArrayGet(i));
m_elb->SetStrings(arr);
m_elbSubPanel = m_elb->GetNewButton()->GetParent();
// Connect event handlers
wxButton* but;
wxListCtrl* lc = m_elb->GetListCtrl();
but = m_elb->GetNewButton();
m_elbSubPanel = but->GetParent();
but->Connect(but->GetId(), wxEVT_BUTTON,
wxCommandEventHandler(wxPGArrayEditorDialog::OnAddClick),
NULL, this);
m_elb->GetNewButton()->Bind(wxEVT_BUTTON,
&wxPGArrayEditorDialog::OnAddClick, this);
m_elb->GetDelButton()->Bind(wxEVT_BUTTON,
&wxPGArrayEditorDialog::OnDeleteClick, this);
m_elb->GetUpButton()->Bind(wxEVT_BUTTON,
&wxPGArrayEditorDialog::OnUpClick, this);
m_elb->GetDownButton()->Bind(wxEVT_BUTTON,
&wxPGArrayEditorDialog::OnDownClick, this);
but = m_elb->GetDelButton();
but->Connect(but->GetId(), wxEVT_BUTTON,
wxCommandEventHandler(wxPGArrayEditorDialog::OnDeleteClick),
NULL, this);
lc->Bind(wxEVT_LIST_BEGIN_LABEL_EDIT,
&wxPGArrayEditorDialog::OnBeginLabelEdit, this);
but = m_elb->GetUpButton();
but->Connect(but->GetId(), wxEVT_BUTTON,
wxCommandEventHandler(wxPGArrayEditorDialog::OnUpClick),
NULL, this);
but = m_elb->GetDownButton();
but->Connect(but->GetId(), wxEVT_BUTTON,
wxCommandEventHandler(wxPGArrayEditorDialog::OnDownClick),
NULL, this);
lc->Connect(lc->GetId(), wxEVT_LIST_BEGIN_LABEL_EDIT,
wxListEventHandler(wxPGArrayEditorDialog::OnBeginLabelEdit),
NULL, this);
lc->Connect(lc->GetId(), wxEVT_LIST_END_LABEL_EDIT,
wxListEventHandler(wxPGArrayEditorDialog::OnEndLabelEdit),
NULL, this);
lc->Bind(wxEVT_LIST_END_LABEL_EDIT,
&wxPGArrayEditorDialog::OnEndLabelEdit, this);
topsizer->Add(m_elb, wxSizerFlags(1).Expand().Border(0, spacing));