Replace Connect() with Bind() in all samples and utils too

Still use Connect() in unit tests which were written explicitly for it
and in EventConnector, which can't use Bind() as it uses a variable for
the event type.

No real changes, just use the newer and more convenient function.
This commit is contained in:
Vadim Zeitlin
2018-05-29 17:32:07 +02:00
parent d4f380e16e
commit 5f7a6bd15b
32 changed files with 291 additions and 583 deletions

View File

@@ -676,10 +676,8 @@ MyFrame::MyFrame(const wxString& title)
m_infoBarAdvanced->AddButton(wxID_UNDO);
m_infoBarAdvanced->AddButton(wxID_REDO);
m_infoBarAdvanced->Connect(wxID_REDO, wxEVT_BUTTON,
wxCommandEventHandler(MyFrame::OnInfoBarRedo),
NULL,
this);
m_infoBarAdvanced->Bind(wxEVT_BUTTON, &MyFrame::OnInfoBarRedo, this,
wxID_REDO);
// adding and removing a button immediately doesn't make sense here, of
// course, it's done just to show that it is possible
@@ -723,8 +721,8 @@ MyFrame::MyFrame(const wxString& title)
static const int DIALOGS_SYSTEM_ABOUT = 0x4010;
menu->Append(DIALOGS_SYSTEM_ABOUT, "&About");
Connect(DIALOGS_SYSTEM_ABOUT, wxEVT_MENU,
wxCommandEventHandler(MyFrame::ShowSimpleAboutDialog));
Bind(wxEVT_MENU, &MyFrame::ShowSimpleAboutDialog, this,
DIALOGS_SYSTEM_ABOUT);
}
#endif // __WXMSW__
}
@@ -966,7 +964,8 @@ void MyFrame::MessageBoxWindowModal(wxCommandEvent& WXUNUSED(event))
"so the default \"Yes\"/\"No\"/\"Cancel\" buttons are used.";
}
dialog->SetExtendedMessage(extmsg);
dialog->Connect( wxEVT_WINDOW_MODAL_DIALOG_CLOSED, wxWindowModalDialogEventHandler(MyFrame::MessageBoxWindowModalClosed), NULL, this );
dialog->Bind(wxEVT_WINDOW_MODAL_DIALOG_CLOSED,
&MyFrame::MessageBoxWindowModalClosed, this);
dialog->ShowWindowModal();
}
@@ -1513,12 +1512,9 @@ MyExtraPanel::MyExtraPanel(wxWindow *parent)
m_btn = new wxButton(this, -1, wxT("Custom Button"));
m_btn->Enable(false);
m_cb = new wxCheckBox(this, -1, wxT("Enable Custom Button"));
m_cb->Connect(wxEVT_CHECKBOX,
wxCommandEventHandler(MyExtraPanel::OnCheckBox), NULL, this);
m_cb->Bind(wxEVT_CHECKBOX, &MyExtraPanel::OnCheckBox, this);
m_label = new wxStaticText(this, wxID_ANY, "Nothing selected");
m_label->Connect(wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(MyExtraPanel::OnUpdateLabelUI),
NULL, this);
m_label->Bind(wxEVT_UPDATE_UI, &MyExtraPanel::OnUpdateLabelUI, this);
m_text = new wxTextCtrl(this, -1, m_str,
wxDefaultPosition, wxSize(40*GetCharWidth(), -1));
@@ -2416,21 +2412,8 @@ public:
// And connect the event handlers.
btnShowText->Connect
(
wxEVT_BUTTON,
wxCommandEventHandler(RichTipDialog::OnShowTipForText),
NULL,
this
);
btnShowBtn->Connect
(
wxEVT_BUTTON,
wxCommandEventHandler(RichTipDialog::OnShowTipForBtn),
NULL,
this
);
btnShowText->Bind(wxEVT_BUTTON, &RichTipDialog::OnShowTipForText, this);
btnShowBtn->Bind(wxEVT_BUTTON, &RichTipDialog::OnShowTipForBtn, this);
}
private:
@@ -3624,11 +3607,8 @@ bool TestMessageBoxDialog::Create()
m_labels[n] = new wxTextCtrl(this, wxID_ANY);
sizerBtns->Add(m_labels[n], wxSizerFlags().Expand());
m_labels[n]->Connect(wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(
TestMessageBoxDialog::OnUpdateLabelUI),
NULL,
this);
m_labels[n]->Bind(wxEVT_UPDATE_UI,
&TestMessageBoxDialog::OnUpdateLabelUI, this);
}
sizerBtnsBox->Add(sizerBtns, wxSizerFlags().Expand());
@@ -3663,11 +3643,8 @@ bool TestMessageBoxDialog::Create()
sizerFlags = new wxStaticBoxSizer(wxHORIZONTAL, this, "&Other flags");
m_chkNoDefault = new wxCheckBox(this, wxID_ANY, "Make \"No\" &default");
m_chkNoDefault->Connect(wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(
TestMessageBoxDialog::OnUpdateNoDefaultUI),
NULL,
this);
m_chkNoDefault->Bind(wxEVT_UPDATE_UI,
&TestMessageBoxDialog::OnUpdateNoDefaultUI, this);
sizerFlags->Add(m_chkNoDefault, wxSizerFlags().Border());
m_chkCentre = new wxCheckBox(this, wxID_ANY, "Centre on &parent");