X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c9cc312e76950fcddb0174ae48b60c347eee8b4..da0a2aca6b2668b4bd5b69b0ee589bce155ee861:/samples/event/event.cpp?ds=sidebyside diff --git a/samples/event/event.cpp b/samples/event/event.cpp index 1ddacb0430..861c2d2048 100644 --- a/samples/event/event.cpp +++ b/samples/event/event.cpp @@ -4,7 +4,6 @@ // Author: Vadim Zeitlin // Modified by: // Created: 31.01.01 -// RCS-ID: $Id$ // Copyright: (c) 2001-2009 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -30,7 +29,7 @@ #include "wx/wx.h" #endif -#ifndef __WXMSW__ +#ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -92,7 +91,7 @@ public: : wxButton(parent, BUTTON_ID, label) { // Add a dynamic handler for this button event to button itself - Connect(wxEVT_COMMAND_BUTTON_CLICKED, + Connect(wxEVT_BUTTON, wxCommandEventHandler(MyEvtTestButton::OnClickDynamicHandler)); } @@ -304,7 +303,7 @@ bool MyApp::OnInit() frame->Show(true); // Add a dynamic handler at the application level for the test button - Connect(MyEvtTestButton::BUTTON_ID, wxEVT_COMMAND_BUTTON_CLICKED, + Connect(MyEvtTestButton::BUTTON_ID, wxEVT_BUTTON, wxCommandEventHandler(MyApp::OnClickDynamicHandlerApp)); // success: wxApp::OnRun() will be called which will enter the main message @@ -316,7 +315,7 @@ bool MyApp::OnInit() // This is always the first to handle an event ! int MyApp::FilterEvent(wxEvent& event) { - if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED && + if ( event.GetEventType() == wxEVT_BUTTON && event.GetId() == MyEvtTestButton::BUTTON_ID ) { wxLogMessage("Step 0 in \"How Events are Processed\":\n" @@ -365,7 +364,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) // create a menu bar wxMenu *menuFile = new wxMenu; - menuFile->Append(Event_About, wxT("&About...\tCtrl-A"), wxT("Show about dialog")); + menuFile->Append(Event_About, wxT("&About\tCtrl-A"), wxT("Show about dialog")); menuFile->AppendSeparator(); menuFile->Append(Event_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program")); @@ -424,12 +423,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size) // event handlers (see class definition); // Add a dynamic handler for this button event in the parent frame - Connect(m_testBtn->GetId(), wxEVT_COMMAND_BUTTON_CLICKED, + Connect(m_testBtn->GetId(), wxEVT_BUTTON, wxCommandEventHandler(MyFrame::OnClickDynamicHandlerFrame)); // Bind a method of this frame (notice "this" argument!) to the button // itself - m_testBtn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, + m_testBtn->Connect(wxEVT_BUTTON, wxCommandEventHandler(MyFrame::OnClickDynamicHandlerButton), NULL, this); @@ -520,19 +519,19 @@ void MyFrame::OnBind(wxCommandEvent& event) { // as we bind directly to the button, there is no need to use an id // here: the button will only ever get its own events - m_btnDynamic->Bind(wxEVT_COMMAND_BUTTON_CLICKED, &MyFrame::OnDynamic, + m_btnDynamic->Bind(wxEVT_BUTTON, &MyFrame::OnDynamic, this); // but we do need the id for the menu command as the frame gets all of // them - Bind(wxEVT_COMMAND_MENU_SELECTED, &MyFrame::OnDynamic, this, + Bind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic); } else // disconnect { - m_btnDynamic->Unbind(wxEVT_COMMAND_BUTTON_CLICKED, + m_btnDynamic->Unbind(wxEVT_BUTTON, &MyFrame::OnDynamic, this); - Unbind(wxEVT_COMMAND_MENU_SELECTED, &MyFrame::OnDynamic, this, + Unbind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic); } @@ -545,18 +544,18 @@ void MyFrame::OnConnect(wxCommandEvent& event) { if ( event.IsChecked() ) { - m_btnDynamic->Connect(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, + m_btnDynamic->Connect(wxID_ANY, wxEVT_BUTTON, wxCommandEventHandler(MyFrame::OnDynamic), NULL, this); - Connect(Event_Dynamic, wxEVT_COMMAND_MENU_SELECTED, + Connect(Event_Dynamic, wxEVT_MENU, wxCommandEventHandler(MyFrame::OnDynamic)); } else // disconnect { - m_btnDynamic->Disconnect(wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, + m_btnDynamic->Disconnect(wxID_ANY, wxEVT_BUTTON, wxCommandEventHandler(MyFrame::OnDynamic), NULL, this); - Disconnect(Event_Dynamic, wxEVT_COMMAND_MENU_SELECTED, + Disconnect(Event_Dynamic, wxEVT_MENU, wxCommandEventHandler(MyFrame::OnDynamic)); }