Merge branch 'replace-connect-bind'

Replace almost all occurrences of wxEvtHandler::Connect() with Bind().

See https://github.com/wxWidgets/wxWidgets/pull/820
This commit is contained in:
Vadim Zeitlin
2018-06-01 18:31:59 +02:00
80 changed files with 459 additions and 946 deletions

View File

@@ -274,7 +274,7 @@ wxDataObject to achieve this.
This sample demonstrates various features of the wxWidgets events. It This sample demonstrates various features of the wxWidgets events. It
shows how to dynamic events and connecting/disconnecting the event handlers shows how to dynamic events and connecting/disconnecting the event handlers
during run time by using wxEvtHandler::Connect() and wxEvtHandler::Disconnect(), during run time by using wxEvtHandler::Bind() and wxEvtHandler::Unbind(),
and also how to use wxWindow::PushEventHandler() and wxWindow::PopEventHandler(). and also how to use wxWindow::PushEventHandler() and wxWindow::PopEventHandler().
@sampledir{event} @sampledir{event}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -809,9 +809,8 @@ wxCalendarCtrlBase *MyPanel::DoCreateCalendar(const wxDateTime& dt, long style)
wxDefaultSize, wxDefaultSize,
style); style);
calendar->Connect(wxEVT_RIGHT_DOWN, calendar->Bind(wxEVT_RIGHT_DOWN,
wxMouseEventHandler(MyFrame::OnCalRClick), &MyFrame::OnCalRClick,
NULL,
( MyFrame * )wxGetTopLevelParent(this)); ( MyFrame * )wxGetTopLevelParent(this));
return calendar; return calendar;

View File

@@ -622,9 +622,7 @@ void MyFrame::BuildDataViewCtrl(wxPanel* parent, unsigned int nPanel, unsigned l
m_ctrl[0] = m_ctrl[0] =
new wxDataViewCtrl( parent, ID_MUSIC_CTRL, wxDefaultPosition, new wxDataViewCtrl( parent, ID_MUSIC_CTRL, wxDefaultPosition,
wxDefaultSize, style ); wxDefaultSize, style );
m_ctrl[0]->Connect(wxEVT_CHAR, m_ctrl[0]->Bind(wxEVT_CHAR, &MyFrame::OnDataViewChar, this);
wxKeyEventHandler(MyFrame::OnDataViewChar),
NULL, this);
m_music_model = new MyMusicTreeModel; m_music_model = new MyMusicTreeModel;
m_ctrl[0]->AssociateModel( m_music_model.get() ); m_ctrl[0]->AssociateModel( m_music_model.get() );

View File

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

View File

@@ -147,12 +147,8 @@ MyDllApp::MyDllApp()
// by shutting the thread down when it's no longer needed, though. // by shutting the thread down when it's no longer needed, though.
SetExitOnFrameDelete(false); SetExitOnFrameDelete(false);
Connect(CMD_SHOW_WINDOW, Bind(wxEVT_THREAD, &MyDllApp::OnShowWindow, this, CMD_SHOW_WINDOW);
wxEVT_THREAD, Bind(wxEVT_THREAD, &MyDllApp::OnTerminate, this, CMD_TERMINATE);
wxThreadEventHandler(MyDllApp::OnShowWindow));
Connect(CMD_TERMINATE,
wxEVT_THREAD,
wxThreadEventHandler(MyDllApp::OnTerminate));
} }
void MyDllApp::OnShowWindow(wxThreadEvent& event) void MyDllApp::OnShowWindow(wxThreadEvent& event)

View File

@@ -1018,14 +1018,7 @@ DnDFrame::DnDFrame()
m_ctrlText->SetDropTarget(new DnDText(m_ctrlText)); m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
#if wxUSE_DRAG_AND_DROP #if wxUSE_DRAG_AND_DROP
m_ctrlDir->Connect m_ctrlDir->Bind(wxEVT_TREE_BEGIN_DRAG, &DnDFrame::OnBeginDrag, this);
(
wxID_ANY,
wxEVT_TREE_BEGIN_DRAG,
wxTreeEventHandler(DnDFrame::OnBeginDrag),
NULL,
this
);
#endif // wxUSE_DRAG_AND_DROP #endif // wxUSE_DRAG_AND_DROP
#if wxUSE_LOG #if wxUSE_LOG

View File

@@ -193,13 +193,7 @@ bool wxTextDocument::OnCreate(const wxString& path, long flags)
// subscribe to changes in the text control to update the document state // subscribe to changes in the text control to update the document state
// when it's modified // when it's modified
GetTextCtrl()->Connect GetTextCtrl()->Bind(wxEVT_TEXT, &wxTextDocument::OnTextChange, this);
(
wxEVT_TEXT,
wxCommandEventHandler(wxTextDocument::OnTextChange),
NULL,
this
);
return true; return true;
} }

View File

@@ -159,8 +159,7 @@ public:
} }
Create (parent, wxID_ANY, pos, size, wxBORDER_NONE); Create (parent, wxID_ANY, pos, size, wxBORDER_NONE);
Connect(wxEVT_PAINT, Bind(wxEVT_PAINT, &ControlWithTransparency::OnPaint, this);
wxPaintEventHandler(ControlWithTransparency::OnPaint));
if ( !reason.empty() ) if ( !reason.empty() )
{ {

View File

@@ -92,8 +92,7 @@ public:
: wxButton(parent, BUTTON_ID, label) : wxButton(parent, BUTTON_ID, label)
{ {
// Add a dynamic handler for this button event to button itself // Add a dynamic handler for this button event to button itself
Connect(wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyEvtTestButton::OnClickDynamicHandler, this);
wxCommandEventHandler(MyEvtTestButton::OnClickDynamicHandler));
} }
private: private:
@@ -307,8 +306,8 @@ bool MyApp::OnInit()
frame->Show(true); frame->Show(true);
// Add a dynamic handler at the application level for the test button // Add a dynamic handler at the application level for the test button
Connect(MyEvtTestButton::BUTTON_ID, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyApp::OnClickDynamicHandlerApp, this,
wxCommandEventHandler(MyApp::OnClickDynamicHandlerApp)); MyEvtTestButton::BUTTON_ID);
// success: wxApp::OnRun() will be called which will enter the main message // success: wxApp::OnRun() will be called which will enter the main message
// loop and the application will run. If we returned false here, the // loop and the application will run. If we returned false here, the
@@ -427,15 +426,12 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
// event handlers (see class definition); // event handlers (see class definition);
// Add a dynamic handler for this button event in the parent frame // Add a dynamic handler for this button event in the parent frame
Connect(m_testBtn->GetId(), wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyFrame::OnClickDynamicHandlerFrame, this,
wxCommandEventHandler(MyFrame::OnClickDynamicHandlerFrame)); m_testBtn->GetId());
// Bind a method of this frame (notice "this" argument!) to the button // Bind a method of this frame (notice "this" argument!) to the button
// itself // itself
m_testBtn->Connect(wxEVT_BUTTON, m_testBtn->Bind(wxEVT_BUTTON, &MyFrame::OnClickDynamicHandlerButton, this);
wxCommandEventHandler(MyFrame::OnClickDynamicHandlerButton),
NULL,
this);
mainSizer->Add(m_testBtn); mainSizer->Add(m_testBtn);
panel->SetSizer(mainSizer); panel->SetSizer(mainSizer);
@@ -545,19 +541,13 @@ void MyFrame::OnConnect(wxCommandEvent& event)
{ {
if ( event.IsChecked() ) if ( event.IsChecked() )
{ {
m_btnDynamic->Connect(wxID_ANY, wxEVT_BUTTON, m_btnDynamic->Bind(wxEVT_BUTTON, &MyFrame::OnDynamic, this);
wxCommandEventHandler(MyFrame::OnDynamic), Bind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic);
NULL, this);
Connect(Event_Dynamic, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnDynamic));
} }
else // disconnect else // disconnect
{ {
m_btnDynamic->Disconnect(wxID_ANY, wxEVT_BUTTON, m_btnDynamic->Unbind(wxEVT_BUTTON, &MyFrame::OnDynamic, this);
wxCommandEventHandler(MyFrame::OnDynamic), Unbind(wxEVT_MENU, &MyFrame::OnDynamic, this, Event_Dynamic);
NULL, this);
Disconnect(Event_Dynamic, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnDynamic));
} }
UpdateDynamicStatus(event.IsChecked()); UpdateDynamicStatus(event.IsChecked());

View File

@@ -180,8 +180,7 @@ MyFrame::MyFrame(const wxString& title)
_("If checked, dereference symlinks") _("If checked, dereference symlinks")
); );
it->Check(false); it->Check(false);
Connect(MENU_ID_DEREFERENCE, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnFollowLinks, this, MENU_ID_DEREFERENCE);
wxCommandEventHandler(MyFrame::OnFollowLinks));
#endif // __UNIX__ #endif // __UNIX__
// the "About" item should be in the help menu // the "About" item should be in the help menu
@@ -267,28 +266,18 @@ MyFrame::MyFrame(const wxString& title)
// event handlers & show // event handlers & show
// menu // menu
Connect(MENU_ID_CLEAR, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnClear, this, MENU_ID_CLEAR);
wxCommandEventHandler(MyFrame::OnClear)); Bind(wxEVT_MENU, &MyFrame::OnQuit, this, MENU_ID_QUIT);
Connect(MENU_ID_QUIT, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnWatch, this, MENU_ID_WATCH);
wxCommandEventHandler(MyFrame::OnQuit)); Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
Connect(MENU_ID_WATCH, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnWatch));
Connect(wxID_ABOUT, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnAbout));
// buttons // buttons
Connect(BTN_ID_ADD, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyFrame::OnAdd, this, BTN_ID_ADD);
wxCommandEventHandler(MyFrame::OnAdd)); Bind(wxEVT_BUTTON, &MyFrame::OnAddTree, this, BTN_ID_ADD_TREE);
Connect(BTN_ID_ADD_TREE, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyFrame::OnRemove, this, BTN_ID_REMOVE);
wxCommandEventHandler(MyFrame::OnAddTree)); Bind(wxEVT_UPDATE_UI, &MyFrame::OnRemoveUpdateUI, this, BTN_ID_REMOVE);
Connect(BTN_ID_REMOVE, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MyFrame::OnRemoveAll, this, BTN_ID_REMOVE_ALL);
wxCommandEventHandler(MyFrame::OnRemove)); Bind(wxEVT_UPDATE_UI, &MyFrame::OnRemoveAllUpdateUI, this, BTN_ID_REMOVE_ALL);
Connect(BTN_ID_REMOVE, wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(MyFrame::OnRemoveUpdateUI));
Connect(BTN_ID_REMOVE_ALL, wxEVT_BUTTON,
wxCommandEventHandler(MyFrame::OnRemoveAll));
Connect(BTN_ID_REMOVE_ALL, wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(MyFrame::OnRemoveAllUpdateUI));
// and show itself (the frames, unlike simple controls, are not shown when // and show itself (the frames, unlike simple controls, are not shown when
// created initially) // created initially)
@@ -306,8 +295,7 @@ bool MyFrame::CreateWatcherIfNecessary()
return false; return false;
CreateWatcher(); CreateWatcher();
Connect(wxEVT_FSWATCHER, Bind(wxEVT_FSWATCHER, &MyFrame::OnFileSystemEvent, this);
wxFileSystemWatcherEventHandler(MyFrame::OnFileSystemEvent));
return true; return true;
} }

View File

@@ -719,8 +719,7 @@ void GridFrame::SetTabBehaviour(wxCommandEvent& event)
{ {
// To make any built-in behaviour work, we need to disable the custom TAB // To make any built-in behaviour work, we need to disable the custom TAB
// handler, otherwise it would be overriding them. // handler, otherwise it would be overriding them.
grid->Disconnect(wxEVT_GRID_TABBING, grid->Unbind(wxEVT_GRID_TABBING, &GridFrame::OnGridCustomTab, this);
wxGridEventHandler(GridFrame::OnGridCustomTab));
grid->SetTabBehaviour( grid->SetTabBehaviour(
static_cast<wxGrid::TabBehaviour>(event.GetId() - ID_TAB_STOP) static_cast<wxGrid::TabBehaviour>(event.GetId() - ID_TAB_STOP)
@@ -729,9 +728,7 @@ void GridFrame::SetTabBehaviour(wxCommandEvent& event)
void GridFrame::SetTabCustomHandler(wxCommandEvent&) void GridFrame::SetTabCustomHandler(wxCommandEvent&)
{ {
grid->Connect(wxEVT_GRID_TABBING, grid->Bind(wxEVT_GRID_TABBING, &GridFrame::OnGridCustomTab, this);
wxGridEventHandler(GridFrame::OnGridCustomTab),
NULL, this);
} }
@@ -2349,10 +2346,7 @@ void GridFrame::OnGridRender( wxCommandEvent& event )
m_gridBitmap = bmp; m_gridBitmap = bmp;
canvas->Connect( wxEVT_PAINT, canvas->Bind( wxEVT_PAINT, &GridFrame::OnRenderPaint, this );
wxPaintEventHandler(GridFrame::OnRenderPaint),
NULL,
this );
frame->Show(); frame->Show();
} }

View File

@@ -875,7 +875,7 @@ public:
m_bitmap = wxBitmap(m_image); m_bitmap = wxBitmap(m_image);
Connect(wxEVT_PAINT, wxPaintEventHandler(MyGraphicsFrame::OnPaint)); Bind(wxEVT_PAINT, &MyGraphicsFrame::OnPaint, this);
Show(); Show();
} }

View File

@@ -47,7 +47,7 @@ class MyClient;
class MyApp : public wxApp class MyApp : public wxApp
{ {
public: public:
MyApp() { Connect(wxEVT_IDLE, wxIdleEventHandler(MyApp::OnIdle)); } MyApp() { Bind(wxEVT_IDLE, &MyApp::OnIdle, this); }
virtual bool OnInit() wxOVERRIDE; virtual bool OnInit() wxOVERRIDE;
virtual int OnExit() wxOVERRIDE; virtual int OnExit() wxOVERRIDE;

View File

@@ -224,35 +224,19 @@ MyFrame::MyFrame(const wxString& title)
// connect menu event handlers // connect menu event handlers
Connect(QuitID, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnQuit, this, QuitID);
wxCommandEventHandler(MyFrame::OnQuit)); Bind(wxEVT_MENU, &MyFrame::OnAbout, this, wxID_ABOUT);
Bind(wxEVT_MENU, &MyFrame::OnClear, this, ClearID);
Connect(wxID_ABOUT, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnSkipHook, this, SkipHook);
wxCommandEventHandler(MyFrame::OnAbout)); Bind(wxEVT_MENU, &MyFrame::OnSkipDown, this, SkipDown);
Bind(wxEVT_MENU, &MyFrame::OnInputWindowKind, this, IDInputCustom, IDInputText);
Connect(ClearID, wxEVT_MENU, Bind(wxEVT_MENU, &MyFrame::OnTestAccelA, this, TestAccelA);
wxCommandEventHandler(MyFrame::OnClear)); Bind(wxEVT_MENU, &MyFrame::OnTestAccelCtrlA, this, TestAccelCtrlA);
Bind(wxEVT_MENU, &MyFrame::OnTestAccelEsc, this, TestAccelEsc);
Connect(SkipHook, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnSkipHook));
Connect(SkipDown, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnSkipDown));
Connect(IDInputCustom, IDInputText, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnInputWindowKind));
Connect(TestAccelA, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnTestAccelA));
Connect(TestAccelCtrlA, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnTestAccelCtrlA));
Connect(TestAccelEsc, wxEVT_MENU,
wxCommandEventHandler(MyFrame::OnTestAccelEsc));
// notice that we don't connect OnCharHook() to the input window, unlike // notice that we don't connect OnCharHook() to the input window, unlike
// the usual key events this one is propagated upwards // the usual key events this one is propagated upwards
Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(MyFrame::OnCharHook)); Bind(wxEVT_CHAR_HOOK, &MyFrame::OnCharHook, this);
// status bar is useful for showing the menu items help strings // status bar is useful for showing the menu items help strings
CreateStatusBar(); CreateStatusBar();
@@ -300,18 +284,13 @@ void MyFrame::DoCreateInputWindow(InputKind inputKind)
m_inputWin->SetForegroundColour(*wxWHITE); m_inputWin->SetForegroundColour(*wxWHITE);
// connect event handlers for the blue input window // connect event handlers for the blue input window
m_inputWin->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyFrame::OnKeyDown), m_inputWin->Bind(wxEVT_KEY_DOWN, &MyFrame::OnKeyDown, this);
NULL, this); m_inputWin->Bind(wxEVT_KEY_UP, &MyFrame::OnKeyUp, this);
m_inputWin->Connect(wxEVT_KEY_UP, wxKeyEventHandler(MyFrame::OnKeyUp), m_inputWin->Bind(wxEVT_CHAR, &MyFrame::OnChar, this);
NULL, this);
m_inputWin->Connect(wxEVT_CHAR, wxKeyEventHandler(MyFrame::OnChar),
NULL, this);
if ( inputKind == Input_Custom ) if ( inputKind == Input_Custom )
{ {
m_inputWin->Connect(wxEVT_PAINT, m_inputWin->Bind(wxEVT_PAINT, &MyFrame::OnPaintInputWin, this);
wxPaintEventHandler(MyFrame::OnPaintInputWin),
NULL, this);
} }
if ( oldWin ) if ( oldWin )

View File

@@ -270,10 +270,8 @@ MyProportionsFrame::MyProportionsFrame(wxFrame *parent)
SetSizerAndFit(sizerTop); SetSizerAndFit(sizerTop);
// and connect the events // and connect the events
Connect(wxEVT_TEXT, Bind(wxEVT_TEXT, &MyProportionsFrame::OnProportionUpdated, this);
wxCommandEventHandler(MyProportionsFrame::OnProportionUpdated)); Bind(wxEVT_SPINCTRL, &MyProportionsFrame::OnProportionChanged, this);
Connect(wxEVT_SPINCTRL,
wxSpinEventHandler(MyProportionsFrame::OnProportionChanged));
} }
void MyProportionsFrame::UpdateProportions() void MyProportionsFrame::UpdateProportions()

View File

@@ -220,14 +220,14 @@ MyFrame::MyFrame()
#endif // wxUSE_ACCEL #endif // wxUSE_ACCEL
// connect it only now, after creating m_textWindow // connect it only now, after creating m_textWindow
Connect(wxEVT_SIZE, wxSizeEventHandler(MyFrame::OnSize)); Bind(wxEVT_SIZE, &MyFrame::OnSize, this);
} }
MyFrame::~MyFrame() MyFrame::~MyFrame()
{ {
// and disconnect it to prevent accessing already deleted m_textWindow in // and disconnect it to prevent accessing already deleted m_textWindow in
// the size event handler if it's called during destruction // the size event handler if it's called during destruction
Disconnect(wxEVT_SIZE, wxSizeEventHandler(MyFrame::OnSize)); Unbind(wxEVT_SIZE, &MyFrame::OnSize, this);
// also prevent its use as log target // also prevent its use as log target
delete wxLog::SetActiveTarget(NULL); delete wxLog::SetActiveTarget(NULL);

View File

@@ -579,129 +579,48 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
// //
// Connect events. // Connect events.
// //
// There are two ways in wxWidgets to use events -
// Message Maps and Connections.
//
// Message Maps are implemented by putting
// DECLARE_MESSAGE_MAP in your wxEvtHandler-derived
// class you want to use for events, such as wxMediaPlayerFrame.
//
// Then after your class declaration you put
// wxBEGIN_EVENT_TABLE(wxMediaPlayerFrame, wxFrame)
// EVT_XXX(XXX)...
// wxEND_EVENT_TABLE()
//
// Where wxMediaPlayerFrame is the class with the DECLARE_MESSAGE_MAP
// in it. EVT_XXX(XXX) are each of your handlers, such
// as EVT_MENU for menu events and the XXX inside
// is the parameters to the event macro - in the case
// of EVT_MENU the menu id and then the function to call.
//
// However, with wxEvtHandler::Connect you can avoid a
// global message map for your class and those annoying
// macros. You can also change the context in which
// the call the handler (more later).
//
// The downside is that due to the limitation that
// wxWidgets doesn't use templates in certain areas,
// You have to triple-cast the event function.
//
// There are five parameters to wxEvtHandler::Connect -
//
// The first is the id of the instance whose events
// you want to handle - i.e. a menu id for menus,
// a control id for controls (wxControl::GetId())
// and so on.
//
// The second is the event id. This is the same
// as the message maps (EVT_MENU) except prefixed
// with "wx" (wxEVT_MENU).
//
// The third is the function handler for the event -
// You need to cast it to the specific event handler
// type, then to a wxEventFunction, then to a
// wxObjectEventFunction - I.E.
// (wxObjectEventFunction)(wxEventFunction)
// (wxCommandEventFunction) &wxMediaPlayerFrame::MyHandler
//
// Or, you can use the new (2.5.5+) event handler
// conversion macros - for instance the above could
// be done as
// wxCommandEventHandler(wxMediaPlayerFrame::MyHandler)
// pretty simple, eh?
//
// The fourth is an optional userdata param -
// this is of historical relevance only and is
// there only for backwards compatibility.
//
// The fifth is the context in which to call the
// handler - by default (this param is optional)
// this. For example in your event handler
// if you were to call "this->MyFunc()"
// it would literally do this->MyFunc. However,
// if you were to pass myHandler as the fifth
// parameter, for instance, you would _really_
// be calling myHandler->MyFunc, even though
// the compiler doesn't really know it.
//
// //
// Menu events // Menu events
// //
this->Connect(wxID_EXIT, wxEVT_MENU, Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnQuit, this,
wxCommandEventHandler(wxMediaPlayerFrame::OnQuit)); wxID_EXIT);
Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnAbout, this,
this->Connect(wxID_ABOUT, wxEVT_MENU, wxID_ABOUT);
wxCommandEventHandler(wxMediaPlayerFrame::OnAbout)); Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnLoop, this,
wxID_LOOP);
this->Connect(wxID_LOOP, wxEVT_MENU, Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnShowInterface, this,
wxCommandEventHandler(wxMediaPlayerFrame::OnLoop)); wxID_SHOWINTERFACE);
Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnOpenFileNewPage, this,
this->Connect(wxID_SHOWINTERFACE, wxEVT_MENU, wxID_OPENFILENEWPAGE);
wxCommandEventHandler(wxMediaPlayerFrame::OnShowInterface)); Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnOpenFileSamePage, this,
wxID_OPENFILESAMEPAGE);
this->Connect(wxID_OPENFILENEWPAGE, wxEVT_MENU, Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnOpenURLNewPage, this,
wxCommandEventHandler(wxMediaPlayerFrame::OnOpenFileNewPage)); wxID_OPENURLNEWPAGE);
Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnOpenURLSamePage, this,
this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_MENU, wxID_OPENURLSAMEPAGE);
wxCommandEventHandler(wxMediaPlayerFrame::OnOpenFileSamePage)); Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnCloseCurrentPage, this,
wxID_CLOSECURRENTPAGE);
this->Connect(wxID_OPENURLNEWPAGE, wxEVT_MENU, Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnPlay, this,
wxCommandEventHandler(wxMediaPlayerFrame::OnOpenURLNewPage)); wxID_PLAY);
Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnStop, this,
this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_MENU, wxID_STOP);
wxCommandEventHandler(wxMediaPlayerFrame::OnOpenURLSamePage)); Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnNext, this,
wxID_NEXT);
this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_MENU, Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnPrev, this,
wxCommandEventHandler(wxMediaPlayerFrame::OnCloseCurrentPage)); wxID_PREV);
Bind(wxEVT_MENU, &wxMediaPlayerFrame::OnSelectBackend, this,
this->Connect(wxID_PLAY, wxEVT_MENU, wxID_SELECTBACKEND);
wxCommandEventHandler(wxMediaPlayerFrame::OnPlay));
this->Connect(wxID_STOP, wxEVT_MENU,
wxCommandEventHandler(wxMediaPlayerFrame::OnStop));
this->Connect(wxID_NEXT, wxEVT_MENU,
wxCommandEventHandler(wxMediaPlayerFrame::OnNext));
this->Connect(wxID_PREV, wxEVT_MENU,
wxCommandEventHandler(wxMediaPlayerFrame::OnPrev));
this->Connect(wxID_SELECTBACKEND, wxEVT_MENU,
wxCommandEventHandler(wxMediaPlayerFrame::OnSelectBackend));
// //
// Key events // Key events
// //
wxTheApp->Connect(wxID_ANY, wxEVT_KEY_DOWN, wxTheApp->Bind(wxEVT_KEY_DOWN, &wxMediaPlayerFrame::OnKeyDown, this);
wxKeyEventHandler(wxMediaPlayerFrame::OnKeyDown),
(wxObject*)0, this);
// //
// Close events // Close events
// //
this->Connect(wxID_ANY, wxEVT_CLOSE_WINDOW, Bind(wxEVT_CLOSE_WINDOW, &wxMediaPlayerFrame::OnClose, this);
wxCloseEventHandler(wxMediaPlayerFrame::OnClose));
// //
// End of Events // End of Events
@@ -1710,58 +1629,50 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
// //
// ListCtrl events // ListCtrl events
// //
this->Connect( wxID_LISTCTRL, wxEVT_LIST_ITEM_ACTIVATED, Bind(wxEVT_LIST_ITEM_ACTIVATED, &wxMediaPlayerFrame::OnChangeSong, parentFrame,
wxListEventHandler(wxMediaPlayerFrame::OnChangeSong), wxID_LISTCTRL);
(wxObject*)0, parentFrame);
// //
// Slider events // Slider events
// //
this->Connect(wxID_SLIDER, wxEVT_SCROLL_THUMBTRACK, Bind(wxEVT_SCROLL_THUMBTRACK, &wxMediaPlayerNotebookPage::OnBeginSeek, this,
wxScrollEventHandler(wxMediaPlayerNotebookPage::OnBeginSeek)); wxID_SLIDER);
this->Connect(wxID_SLIDER, wxEVT_SCROLL_THUMBRELEASE, Bind(wxEVT_SCROLL_THUMBRELEASE, &wxMediaPlayerNotebookPage::OnEndSeek, this,
wxScrollEventHandler(wxMediaPlayerNotebookPage::OnEndSeek)); wxID_SLIDER);
this->Connect(wxID_PBSLIDER, wxEVT_SCROLL_THUMBRELEASE, Bind(wxEVT_SCROLL_THUMBRELEASE, &wxMediaPlayerNotebookPage::OnPBChange, this,
wxScrollEventHandler(wxMediaPlayerNotebookPage::OnPBChange)); wxID_PBSLIDER);
this->Connect(wxID_VOLSLIDER, wxEVT_SCROLL_THUMBRELEASE, Bind(wxEVT_SCROLL_THUMBRELEASE, &wxMediaPlayerNotebookPage::OnVolChange, this,
wxScrollEventHandler(wxMediaPlayerNotebookPage::OnVolChange)); wxID_VOLSLIDER);
// //
// Media Control events // Media Control events
// //
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_PLAY, Bind(wxEVT_MEDIA_PLAY, &wxMediaPlayerNotebookPage::OnMediaPlay, this,
wxMediaEventHandler(wxMediaPlayerNotebookPage::OnMediaPlay)); wxID_MEDIACTRL);
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_PAUSE, Bind(wxEVT_MEDIA_PAUSE, &wxMediaPlayerNotebookPage::OnMediaPause, this,
wxMediaEventHandler(wxMediaPlayerNotebookPage::OnMediaPause)); wxID_MEDIACTRL);
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_STOP, Bind(wxEVT_MEDIA_STOP, &wxMediaPlayerNotebookPage::OnMediaStop, this,
wxMediaEventHandler(wxMediaPlayerNotebookPage::OnMediaStop)); wxID_MEDIACTRL);
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_FINISHED, Bind(wxEVT_MEDIA_FINISHED, &wxMediaPlayerNotebookPage::OnMediaFinished, this,
wxMediaEventHandler(wxMediaPlayerNotebookPage::OnMediaFinished)); wxID_MEDIACTRL);
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_LOADED, Bind(wxEVT_MEDIA_LOADED, &wxMediaPlayerFrame::OnMediaLoaded, parentFrame,
wxMediaEventHandler(wxMediaPlayerFrame::OnMediaLoaded), wxID_MEDIACTRL);
(wxObject*)0, parentFrame);
// //
// Button events // Button events
// //
this->Connect( wxID_BUTTONPREV, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnPrev, parentFrame,
wxCommandEventHandler(wxMediaPlayerFrame::OnPrev), wxID_BUTTONPREV);
(wxObject*)0, parentFrame); Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnPlay, parentFrame,
this->Connect( wxID_BUTTONPLAY, wxEVT_BUTTON, wxID_BUTTONPLAY);
wxCommandEventHandler(wxMediaPlayerFrame::OnPlay), Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnStop, parentFrame,
(wxObject*)0, parentFrame); wxID_BUTTONSTOP);
this->Connect( wxID_BUTTONSTOP, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnNext, parentFrame,
wxCommandEventHandler(wxMediaPlayerFrame::OnStop), wxID_BUTTONNEXT);
(wxObject*)0, parentFrame); Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnVolumeDown, parentFrame,
this->Connect( wxID_BUTTONNEXT, wxEVT_BUTTON, wxID_BUTTONVD);
wxCommandEventHandler(wxMediaPlayerFrame::OnNext), Bind(wxEVT_BUTTON, &wxMediaPlayerFrame::OnVolumeUp, parentFrame,
(wxObject*)0, parentFrame); wxID_BUTTONVU);
this->Connect( wxID_BUTTONVD, wxEVT_BUTTON,
wxCommandEventHandler(wxMediaPlayerFrame::OnVolumeDown),
(wxObject*)0, parentFrame);
this->Connect( wxID_BUTTONVU, wxEVT_BUTTON,
wxCommandEventHandler(wxMediaPlayerFrame::OnVolumeUp),
(wxObject*)0, parentFrame);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -116,9 +116,7 @@ SimpleTransientPopup::SimpleTransientPopup( wxWindow *parent, bool scrolled )
// Keep this code to verify if mouse events work, they're required if // Keep this code to verify if mouse events work, they're required if
// you're making a control like a combobox where the items are highlighted // you're making a control like a combobox where the items are highlighted
// under the cursor, the m_panel is set focus in the Popup() function // under the cursor, the m_panel is set focus in the Popup() function
m_panel->Connect(wxEVT_MOTION, m_panel->Bind(wxEVT_MOTION, &SimpleTransientPopup::OnMouse, this);
wxMouseEventHandler(SimpleTransientPopup::OnMouse),
NULL, this);
wxStaticText *text = new wxStaticText( m_panel, wxID_ANY, wxStaticText *text = new wxStaticText( m_panel, wxID_ANY,
wxT("wxPopupTransientWindow is a\n") wxT("wxPopupTransientWindow is a\n")

View File

@@ -1969,14 +1969,6 @@ void FormMain::CreateGrid( int style, int extraStyle )
//m_pPropGridManager->SetSplitterLeft(true); //m_pPropGridManager->SetSplitterLeft(true);
//m_pPropGridManager->SetSplitterPosition(137); //m_pPropGridManager->SetSplitterPosition(137);
/*
// This would setup event handling without event table entries
Connect(m_pPropGridManager->GetId(), wxEVT_PG_SELECTED,
wxPropertyGridEventHandler(FormMain::OnPropertyGridSelect) );
Connect(m_pPropGridManager->GetId(), wxEVT_PG_CHANGED,
wxPropertyGridEventHandler(FormMain::OnPropertyGridChange) );
*/
m_topSizer->Add( m_pPropGridManager, wxSizerFlags(1).Expand()); m_topSizer->Add( m_pPropGridManager, wxSizerFlags(1).Expand());
FinalizePanel(wasCreated); FinalizePanel(wasCreated);

View File

@@ -49,7 +49,7 @@ public:
SetVirtualSize( WIDTH, HEIGHT ); SetVirtualSize( WIDTH, HEIGHT );
SetBackgroundColour( *wxWHITE ); SetBackgroundColour( *wxWHITE );
Connect(wxEVT_PAINT, wxPaintEventHandler(MySimpleCanvas::OnPaint)); Bind(wxEVT_PAINT, &MySimpleCanvas::OnPaint, this);
} }
private: private:
@@ -125,10 +125,8 @@ public:
mbar->Append(menuFile, "&File"); mbar->Append(menuFile, "&File");
SetMenuBar( mbar ); SetMenuBar( mbar );
Connect(wxID_DELETE, wxEVT_MENU, Bind(wxEVT_MENU, &MyCanvasFrame::OnDeleteAll, this, wxID_DELETE);
wxCommandEventHandler(MyCanvasFrame::OnDeleteAll)); Bind(wxEVT_MENU, &MyCanvasFrame::OnInsertNew, this, wxID_NEW);
Connect(wxID_NEW, wxEVT_MENU,
wxCommandEventHandler(MyCanvasFrame::OnInsertNew));
Show(); Show();
} }
@@ -197,7 +195,7 @@ public:
{ {
m_owner = parent; m_owner = parent;
Connect(wxEVT_PAINT, wxPaintEventHandler(MySubColLabels::OnPaint)); Bind(wxEVT_PAINT, &MySubColLabels::OnPaint, this);
} }
private: private:
@@ -232,7 +230,7 @@ public:
{ {
m_owner = parent; m_owner = parent;
Connect(wxEVT_PAINT, wxPaintEventHandler(MySubRowLabels::OnPaint)); Bind(wxEVT_PAINT, &MySubRowLabels::OnPaint, this);
} }
private: private:
@@ -289,7 +287,7 @@ public:
SetBackgroundColour("WHEAT"); SetBackgroundColour("WHEAT");
Connect(wxEVT_PAINT, wxPaintEventHandler(MySubCanvas::OnPaint)); Bind(wxEVT_PAINT, &MySubCanvas::OnPaint, this);
} }
// override the base class function so that when this window is scrolled, // override the base class function so that when this window is scrolled,
@@ -396,7 +394,7 @@ public:
SetScrollbars(10, 10, 50, 50); SetScrollbars(10, 10, 50, 50);
Connect(wxEVT_SIZE, wxSizeEventHandler(MySubScrolledWindow::OnSize)); Bind(wxEVT_SIZE, &MySubScrolledWindow::OnSize, this);
} }
protected: protected:
@@ -808,8 +806,8 @@ MySizerScrolledWindow::MySizerScrolledWindow(wxWindow *parent)
SetSizer( sizer ); SetSizer( sizer );
Connect(wxID_RESIZE_FRAME, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &MySizerScrolledWindow::OnResizeClick, this,
wxCommandEventHandler(MySizerScrolledWindow::OnResizeClick)); wxID_RESIZE_FRAME);
} }
void MySizerScrolledWindow::OnResizeClick(wxCommandEvent &WXUNUSED(event)) void MySizerScrolledWindow::OnResizeClick(wxCommandEvent &WXUNUSED(event))

View File

@@ -172,7 +172,7 @@ public:
ShowWithEffect(m_effect, m_timeout); ShowWithEffect(m_effect, m_timeout);
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(EffectFrame::OnClose)); Bind(wxEVT_CLOSE_WINDOW, &EffectFrame::OnClose, this);
} }
private: private:

View File

@@ -134,7 +134,7 @@ public:
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
flags) flags)
{ {
Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(MyTabTextCtrl::OnKeyDown)); Bind(wxEVT_KEY_DOWN, &MyTabTextCtrl::OnKeyDown, this);
} }
private: private:

View File

@@ -474,140 +474,80 @@ WebFrame::WebFrame(const wxString& url) :
// Connect the toolbar events // Connect the toolbar events
Connect(m_toolbar_back->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnBack, this, m_toolbar_back->GetId());
wxCommandEventHandler(WebFrame::OnBack), NULL, this ); Bind(wxEVT_TOOL, &WebFrame::OnForward, this, m_toolbar_forward->GetId());
Connect(m_toolbar_forward->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnStop, this, m_toolbar_stop->GetId());
wxCommandEventHandler(WebFrame::OnForward), NULL, this ); Bind(wxEVT_TOOL, &WebFrame::OnReload, this, m_toolbar_reload->GetId());
Connect(m_toolbar_stop->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnToolsClicked, this, m_toolbar_tools->GetId());
wxCommandEventHandler(WebFrame::OnStop), NULL, this );
Connect(m_toolbar_reload->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnReload),NULL, this );
Connect(m_toolbar_tools->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnToolsClicked), NULL, this );
Connect(m_url->GetId(), wxEVT_TEXT_ENTER, Bind(wxEVT_TEXT_ENTER, &WebFrame::OnUrl, this, m_url->GetId());
wxCommandEventHandler(WebFrame::OnUrl), NULL, this );
// Connect find toolbar events. // Connect find toolbar events.
Connect(m_find_toolbar_done->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnFindDone, this, m_find_toolbar_done->GetId());
wxCommandEventHandler(WebFrame::OnFindDone), NULL, this ); Bind(wxEVT_TOOL, &WebFrame::OnFindText, this, m_find_toolbar_next->GetId());
Connect(m_find_toolbar_next->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnFindText, this, m_find_toolbar_previous->GetId());
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
Connect(m_find_toolbar_previous->GetId(), wxEVT_TOOL,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
// Connect find control events. // Connect find control events.
Connect(m_find_ctrl->GetId(), wxEVT_TEXT, Bind(wxEVT_TEXT, &WebFrame::OnFindText, this, m_find_ctrl->GetId());
wxCommandEventHandler(WebFrame::OnFindText), NULL, this ); Bind(wxEVT_TEXT_ENTER, &WebFrame::OnFindText, this, m_find_ctrl->GetId());
Connect(m_find_ctrl->GetId(), wxEVT_TEXT_ENTER,
wxCommandEventHandler(WebFrame::OnFindText), NULL, this );
// Connect the webview events // Connect the webview events
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATING, Bind(wxEVT_WEBVIEW_NAVIGATING, &WebFrame::OnNavigationRequest, this, m_browser->GetId());
wxWebViewEventHandler(WebFrame::OnNavigationRequest), NULL, this); Bind(wxEVT_WEBVIEW_NAVIGATED, &WebFrame::OnNavigationComplete, this, m_browser->GetId());
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NAVIGATED, Bind(wxEVT_WEBVIEW_LOADED, &WebFrame::OnDocumentLoaded, this, m_browser->GetId());
wxWebViewEventHandler(WebFrame::OnNavigationComplete), NULL, this); Bind(wxEVT_WEBVIEW_ERROR, &WebFrame::OnError, this, m_browser->GetId());
Connect(m_browser->GetId(), wxEVT_WEBVIEW_LOADED, Bind(wxEVT_WEBVIEW_NEWWINDOW, &WebFrame::OnNewWindow, this, m_browser->GetId());
wxWebViewEventHandler(WebFrame::OnDocumentLoaded), NULL, this); Bind(wxEVT_WEBVIEW_TITLE_CHANGED, &WebFrame::OnTitleChanged, this, m_browser->GetId());
Connect(m_browser->GetId(), wxEVT_WEBVIEW_ERROR,
wxWebViewEventHandler(WebFrame::OnError), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_NEWWINDOW,
wxWebViewEventHandler(WebFrame::OnNewWindow), NULL, this);
Connect(m_browser->GetId(), wxEVT_WEBVIEW_TITLE_CHANGED,
wxWebViewEventHandler(WebFrame::OnTitleChanged), NULL, this);
// Connect the menu events // Connect the menu events
Connect(setPage->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnSetPage, this, setPage->GetId());
wxCommandEventHandler(WebFrame::OnSetPage), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnViewSourceRequest, this, viewSource->GetId());
Connect(viewSource->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnViewTextRequest, this, viewText->GetId());
wxCommandEventHandler(WebFrame::OnViewSourceRequest), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnPrint, this, print->GetId());
Connect(viewText->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnZoomLayout, this, m_tools_layout->GetId());
wxCommandEventHandler(WebFrame::OnViewTextRequest), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnSetZoom, this, m_tools_tiny->GetId());
Connect(print->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnSetZoom, this, m_tools_small->GetId());
wxCommandEventHandler(WebFrame::OnPrint), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnSetZoom, this, m_tools_medium->GetId());
Connect(m_tools_layout->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnSetZoom, this, m_tools_large->GetId());
wxCommandEventHandler(WebFrame::OnZoomLayout), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnSetZoom, this, m_tools_largest->GetId());
Connect(m_tools_tiny->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnClearHistory, this, clearhist->GetId());
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnEnableHistory, this, m_tools_enable_history->GetId());
Connect(m_tools_small->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnCut, this, m_edit_cut->GetId());
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnCopy, this, m_edit_copy->GetId());
Connect(m_tools_medium->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnPaste, this, m_edit_paste->GetId());
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnUndo, this, m_edit_undo->GetId());
Connect(m_tools_large->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRedo, this, m_edit_redo->GetId());
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnMode, this, m_edit_mode->GetId());
Connect(m_tools_largest->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnScrollLineUp, this, m_scroll_line_up->GetId());
wxCommandEventHandler(WebFrame::OnSetZoom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnScrollLineDown, this, m_scroll_line_down->GetId());
Connect(clearhist->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnScrollPageUp, this, m_scroll_page_up->GetId());
wxCommandEventHandler(WebFrame::OnClearHistory), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnScrollPageDown, this, m_scroll_page_down->GetId());
Connect(m_tools_enable_history->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptString, this, m_script_string->GetId());
wxCommandEventHandler(WebFrame::OnEnableHistory), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptInteger, this, m_script_integer->GetId());
Connect(m_edit_cut->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptDouble, this, m_script_double->GetId());
wxCommandEventHandler(WebFrame::OnCut), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptBool, this, m_script_bool->GetId());
Connect(m_edit_copy->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptObject, this, m_script_object->GetId());
wxCommandEventHandler(WebFrame::OnCopy), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptArray, this, m_script_array->GetId());
Connect(m_edit_paste->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptDOM, this, m_script_dom->GetId());
wxCommandEventHandler(WebFrame::OnPaste), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptUndefined, this, m_script_undefined->GetId());
Connect(m_edit_undo->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptNull, this, m_script_null->GetId());
wxCommandEventHandler(WebFrame::OnUndo), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptDate, this, m_script_date->GetId());
Connect(m_edit_redo->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRedo), NULL, this );
Connect(m_edit_mode->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnMode), NULL, this );
Connect(m_scroll_line_up->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollLineUp), NULL, this );
Connect(m_scroll_line_down->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollLineDown), NULL, this );
Connect(m_scroll_page_up->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollPageUp), NULL, this );
Connect(m_scroll_page_down->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnScrollPageDown), NULL, this );
Connect(m_script_string->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptString), NULL, this );
Connect(m_script_integer->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptInteger), NULL, this );
Connect(m_script_double->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptDouble), NULL, this );
Connect(m_script_bool->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptBool), NULL, this );
Connect(m_script_object->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptObject), NULL, this );
Connect(m_script_array->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptArray), NULL, this );
Connect(m_script_dom->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptDOM), NULL, this );
Connect(m_script_undefined->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptUndefined), NULL, this );
Connect(m_script_null->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptNull), NULL, this );
Connect(m_script_date->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptDate), NULL, this );
#if wxUSE_WEBVIEW_IE #if wxUSE_WEBVIEW_IE
Connect(m_script_object_el->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptObjectWithEmulationLevel, this, m_script_object_el->GetId());
wxCommandEventHandler(WebFrame::OnRunScriptObjectWithEmulationLevel), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnRunScriptDateWithEmulationLevel, this, m_script_date_el->GetId());
Connect(m_script_date_el->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptArrayWithEmulationLevel, this, m_script_array_el->GetId());
wxCommandEventHandler(WebFrame::OnRunScriptDateWithEmulationLevel), NULL, this );
Connect(m_script_array_el->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnRunScriptArrayWithEmulationLevel), NULL, this );
#endif #endif
Connect(m_script_custom->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnRunScriptCustom, this, m_script_custom->GetId());
wxCommandEventHandler(WebFrame::OnRunScriptCustom), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnClearSelection, this, m_selection_clear->GetId());
Connect(m_selection_clear->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnDeleteSelection, this, m_selection_delete->GetId());
wxCommandEventHandler(WebFrame::OnClearSelection), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnSelectAll, this, selectall->GetId());
Connect(m_selection_delete->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnLoadScheme, this, loadscheme->GetId());
wxCommandEventHandler(WebFrame::OnDeleteSelection), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnUseMemoryFS, this, usememoryfs->GetId());
Connect(selectall->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnFind, this, m_find->GetId());
wxCommandEventHandler(WebFrame::OnSelectAll), NULL, this ); Bind(wxEVT_MENU, &WebFrame::OnEnableContextMenu, this, m_context_menu->GetId());
Connect(loadscheme->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnLoadScheme), NULL, this );
Connect(usememoryfs->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnUseMemoryFS), NULL, this );
Connect(m_find->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnFind), NULL, this );
Connect(m_context_menu->GetId(), wxEVT_MENU,
wxCommandEventHandler(WebFrame::OnEnableContextMenu), NULL, this );
//Connect the idle events //Connect the idle events
Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(WebFrame::OnIdle), NULL, this); Bind(wxEVT_IDLE, &WebFrame::OnIdle, this);
} }
WebFrame::~WebFrame() WebFrame::~WebFrame()
@@ -1011,8 +951,7 @@ void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt))
{ {
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, back[i]->GetTitle()); item = m_tools_history_menu->AppendRadioItem(wxID_ANY, back[i]->GetTitle());
m_histMenuItems[item->GetId()] = back[i]; m_histMenuItems[item->GetId()] = back[i];
Connect(item->GetId(), wxEVT_MENU, Bind(wxEVT_MENU, &WebFrame::OnHistory, this, item->GetId());
wxCommandEventHandler(WebFrame::OnHistory), NULL, this );
} }
wxString title = m_browser->GetCurrentTitle(); wxString title = m_browser->GetCurrentTitle();
@@ -1028,8 +967,7 @@ void WebFrame::OnToolsClicked(wxCommandEvent& WXUNUSED(evt))
{ {
item = m_tools_history_menu->AppendRadioItem(wxID_ANY, forward[i]->GetTitle()); item = m_tools_history_menu->AppendRadioItem(wxID_ANY, forward[i]->GetTitle());
m_histMenuItems[item->GetId()] = forward[i]; m_histMenuItems[item->GetId()] = forward[i];
Connect(item->GetId(), wxEVT_TOOL, Bind(wxEVT_TOOL, &WebFrame::OnHistory, this, item->GetId());
wxCommandEventHandler(WebFrame::OnHistory), NULL, this );
} }
wxPoint position = ScreenToClient( wxGetMousePosition() ); wxPoint position = ScreenToClient( wxGetMousePosition() );

View File

@@ -205,12 +205,6 @@ wxMenu* SearchCtrlWidgetsPage::CreateTestMenu()
wxString tipText = wxString::Format(wxT("tip %i"),i); wxString tipText = wxString::Format(wxT("tip %i"),i);
menu->Append(ID_SEARCHMENU+i, itemText, tipText, wxITEM_NORMAL); menu->Append(ID_SEARCHMENU+i, itemText, tipText, wxITEM_NORMAL);
} }
// target->Connect(
// ID_SEARCHMENU,
// ID_SEARCHMENU+SEARCH_MENU_SIZE,
// wxEVT_MENU,
// wxCommandEventHandler(MySearchCtrl::OnSearchMenu)
// );
return menu; return menu;
} }

View File

@@ -115,10 +115,8 @@ void StatBmpWidgetsPage::CreateContent()
wxInitAllImageHandlers(); wxInitAllImageHandlers();
Connect(wxEVT_FILEPICKER_CHANGED, Bind(wxEVT_FILEPICKER_CHANGED, &StatBmpWidgetsPage::OnFileChange, this);
wxFileDirPickerEventHandler(StatBmpWidgetsPage::OnFileChange)); Bind(wxEVT_RADIOBOX, &StatBmpWidgetsPage::OnRadioChange, this);
Connect(wxEVT_RADIOBOX,
wxCommandEventHandler(StatBmpWidgetsPage::OnRadioChange));
m_statbmp = NULL; m_statbmp = NULL;
RecreateWidget(); RecreateWidget();
@@ -171,9 +169,8 @@ void StatBmpWidgetsPage::RecreateWidget()
} }
m_sbsizer->Add(m_statbmp, wxSizerFlags(1).Expand()); m_sbsizer->Add(m_statbmp, wxSizerFlags(1).Expand());
GetSizer()->Layout(); GetSizer()->Layout();
m_statbmp->Connect(wxEVT_LEFT_DOWN, m_statbmp->Bind(wxEVT_LEFT_DOWN, &StatBmpWidgetsPage::OnMouseEvent, this);
wxMouseEventHandler(StatBmpWidgetsPage::OnMouseEvent),
NULL, this);
// When switching from generic to native control on wxMSW under Wine, // When switching from generic to native control on wxMSW under Wine,
// the explicit Refresh() is necessary // the explicit Refresh() is necessary
m_statbmp->Refresh(); m_statbmp->Refresh();

View File

@@ -310,9 +310,7 @@ void StaticWidgetsPage::CreateContent()
m_textBox = new wxTextCtrl(this, wxID_ANY, wxEmptyString); m_textBox = new wxTextCtrl(this, wxID_ANY, wxEmptyString);
wxButton *b1 = new wxButton(this, wxID_ANY, "Change &box label"); wxButton *b1 = new wxButton(this, wxID_ANY, "Change &box label");
b1->Connect(wxEVT_BUTTON, b1->Bind(wxEVT_BUTTON, &StaticWidgetsPage::OnButtonBoxText, this);
wxCommandEventHandler(StaticWidgetsPage::OnButtonBoxText),
NULL, this);
sizerMiddle->Add(m_textBox, 0, wxEXPAND|wxALL, 5); sizerMiddle->Add(m_textBox, 0, wxEXPAND|wxALL, 5);
sizerMiddle->Add(b1, 0, wxLEFT|wxBOTTOM, 5); sizerMiddle->Add(b1, 0, wxLEFT|wxBOTTOM, 5);
@@ -320,9 +318,7 @@ void StaticWidgetsPage::CreateContent()
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE|wxHSCROLL); wxTE_MULTILINE|wxHSCROLL);
wxButton *b2 = new wxButton(this, wxID_ANY, "Change &text label"); wxButton *b2 = new wxButton(this, wxID_ANY, "Change &text label");
b2->Connect(wxEVT_BUTTON, b2->Bind(wxEVT_BUTTON, &StaticWidgetsPage::OnButtonLabelText, this);
wxCommandEventHandler(StaticWidgetsPage::OnButtonLabelText),
NULL, this);
sizerMiddle->Add(m_textLabel, 0, wxEXPAND|wxALL, 5); sizerMiddle->Add(m_textLabel, 0, wxEXPAND|wxALL, 5);
sizerMiddle->Add(b2, 0, wxLEFT|wxBOTTOM, 5); sizerMiddle->Add(b2, 0, wxLEFT|wxBOTTOM, 5);
@@ -332,9 +328,7 @@ void StaticWidgetsPage::CreateContent()
wxTE_MULTILINE|wxHSCROLL); wxTE_MULTILINE|wxHSCROLL);
wxButton *b3 = new wxButton(this, wxID_ANY, "Change decorated text label"); wxButton *b3 = new wxButton(this, wxID_ANY, "Change decorated text label");
b3->Connect(wxEVT_BUTTON, b3->Bind(wxEVT_BUTTON, &StaticWidgetsPage::OnButtonLabelWithMarkupText, this);
wxCommandEventHandler(StaticWidgetsPage::OnButtonLabelWithMarkupText),
NULL, this);
sizerMiddle->Add(m_textLabelWithMarkup, 0, wxEXPAND|wxALL, 5); sizerMiddle->Add(m_textLabelWithMarkup, 0, wxEXPAND|wxALL, 5);
sizerMiddle->Add(b3, 0, wxLEFT|wxBOTTOM, 5); sizerMiddle->Add(b3, 0, wxLEFT|wxBOTTOM, 5);
@@ -562,12 +556,8 @@ void StaticWidgetsPage::CreateStatic()
m_sizerStatic->Layout(); m_sizerStatic->Layout();
m_statText->Connect(wxEVT_LEFT_UP, m_statText->Bind(wxEVT_LEFT_UP, &StaticWidgetsPage::OnMouseEvent, this);
wxMouseEventHandler(StaticWidgetsPage::OnMouseEvent), staticBox->Bind(wxEVT_LEFT_UP, &StaticWidgetsPage::OnMouseEvent, this);
NULL, this);
staticBox->Connect(wxEVT_LEFT_UP,
wxMouseEventHandler(StaticWidgetsPage::OnMouseEvent),
NULL, this);
SetUpWidget(); SetUpWidget();
} }

View File

@@ -628,9 +628,7 @@ void WidgetsFrame::InitBook()
} }
} }
Connect( wxID_ANY, Bind(wxEVT_COMMAND_WIDGETS_PAGE_CHANGED, &WidgetsFrame::OnPageChanged, this);
wxEVT_COMMAND_WIDGETS_PAGE_CHANGED,
wxWidgetsbookEventHandler(WidgetsFrame::OnPageChanged) );
const bool pageSet = wxPersistentRegisterAndRestore(m_book); const bool pageSet = wxPersistentRegisterAndRestore(m_book);

View File

@@ -144,8 +144,7 @@ WrapSizerFrame::WrapSizerFrame()
// OK Button // OK Button
sizerRoot->Add(new wxButton(m_panel, wxID_OK), sizerRoot->Add(new wxButton(m_panel, wxID_OK),
wxSizerFlags().Centre().DoubleBorder()); wxSizerFlags().Centre().DoubleBorder());
Connect(wxID_OK, wxEVT_BUTTON, Bind(wxEVT_BUTTON, &WrapSizerFrame::OnButton, this, wxID_OK);
wxCommandEventHandler(WrapSizerFrame::OnButton));
// Set sizer for the panel // Set sizer for the panel
m_panel->SetSizer(sizerRoot); m_panel->SetSizer(sizerRoot);

View File

@@ -261,8 +261,8 @@ void MyFrame::OnControlsToolOrMenuCommand(wxCommandEvent& WXUNUSED(event))
#if wxUSE_ANIMATIONCTRL #if wxUSE_ANIMATIONCTRL
// dynamically connect our event handler for the "clicked" event of the "play" button // dynamically connect our event handler for the "clicked" event of the "play" button
// in the animation ctrl page of our dialog // in the animation ctrl page of our dialog
dlg.Connect(XRCID("controls_animation_button_play"), wxEVT_BUTTON, dlg.Bind(wxEVT_BUTTON, &MyFrame::OnAnimationCtrlPlay, this,
wxCommandEventHandler(MyFrame::OnAnimationCtrlPlay)); XRCID("controls_animation_button_play"));
#endif #endif
// All done. Show the dialog. // All done. Show the dialog.

View File

@@ -48,38 +48,26 @@ ObjrefDialog::ObjrefDialog(wxWindow* parent)
wxCHECK_RET(nb, "failed to find objref_notebook"); wxCHECK_RET(nb, "failed to find objref_notebook");
// Connect different event handlers. // Connect different event handlers.
nb->Connect(wxEVT_NOTEBOOK_PAGE_CHANGED, nb->Bind(wxEVT_NOTEBOOK_PAGE_CHANGED, &ObjrefDialog::OnNotebookPageChanged, this);
wxNotebookEventHandler(ObjrefDialog::OnNotebookPageChanged),
NULL, this);
// We want to direct UpdateUI events for the ID range 'first_row' to // We want to direct UpdateUI events for the ID range 'first_row' to
// OnUpdateUIFirst(). We could achieve this using first_row[0] and // OnUpdateUIFirst(). We could achieve this using first_row[0] and
// first_row[2], but what if a fourth column were added? It's safer to use // first_row[2], but what if a fourth column were added? It's safer to use
// the 'typedefs' for the two ends of the range: // the 'typedefs' for the two ends of the range:
wxNotebookPage *page = nb->GetPage(icons_page); wxNotebookPage *page = nb->GetPage(icons_page);
page->Connect(XRCID("first_row[start]"), XRCID("first_row[end]"), page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUIFirst, this,
wxEVT_UPDATE_UI, XRCID("first_row[start]"), XRCID("first_row[end]"));
wxUpdateUIEventHandler(ObjrefDialog::OnUpdateUIFirst), page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUISecond, this,
NULL, this); XRCID("second_row[start]"), XRCID("second_row[end]"));
page->Connect(XRCID("second_row[start]"), XRCID("second_row[end]"), page->Bind(wxEVT_UPDATE_UI, &ObjrefDialog::OnUpdateUIThird, this,
wxEVT_UPDATE_UI, XRCID("third_row[start]"), XRCID("third_row[end]"));
wxUpdateUIEventHandler(ObjrefDialog::OnUpdateUISecond),
NULL, this);
page->Connect(XRCID("third_row[start]"), XRCID("third_row[end]"),
wxEVT_UPDATE_UI,
wxUpdateUIEventHandler(ObjrefDialog::OnUpdateUIThird),
NULL, this);
// Connect the id ranges, using the [start] and [end] 'typedefs' // Connect the id ranges, using the [start] and [end] 'typedefs'
page = nb->GetPage(calc_page); page = nb->GetPage(calc_page);
page->Connect(XRCID("digits[start]"), XRCID("digits[end]"), page->Bind(wxEVT_BUTTON, &ObjrefDialog::OnNumeralClick, this,
wxEVT_BUTTON, XRCID("digits[start]"), XRCID("digits[end]"));
wxCommandEventHandler(ObjrefDialog::OnNumeralClick), page->Bind(wxEVT_BUTTON, &ObjrefDialog::OnOperatorClick, this,
NULL, this); XRCID("operators[start]"), XRCID("operators[end]"));
page->Connect(XRCID("operators[start]"), XRCID("operators[end]"),
wxEVT_BUTTON,
wxCommandEventHandler(ObjrefDialog::OnOperatorClick),
NULL, this);
} }

View File

@@ -858,8 +858,7 @@ void wxAuiManager::UpdateHintWindowConfig()
wxDefaultPosition, wxSize(1,1), wxDefaultPosition, wxSize(1,1),
wxFRAME_FLOAT_ON_PARENT wxFRAME_FLOAT_ON_PARENT
| wxFRAME_TOOL_WINDOW ); | wxFRAME_TOOL_WINDOW );
m_hintWnd->Connect(wxEVT_ACTIVATE, m_hintWnd->Bind(wxEVT_ACTIVATE, &wxAuiManager::OnHintActivate, this);
wxActivateEventHandler(wxAuiManager::OnHintActivate), NULL, this);
// Can't set the bg colour of a Frame in wxMac // Can't set the bg colour of a Frame in wxMac
wxPanel* p = new wxPanel(m_hintWnd); wxPanel* p = new wxPanel(m_hintWnd);
@@ -3284,8 +3283,8 @@ void wxAuiManager::OnHintFadeTimer(wxTimerEvent& WXUNUSED(event))
if (!m_hintWnd || m_hintFadeAmt >= m_hintFadeMax) if (!m_hintWnd || m_hintFadeAmt >= m_hintFadeMax)
{ {
m_hintFadeTimer.Stop(); m_hintFadeTimer.Stop();
Disconnect(m_hintFadeTimer.GetId(), wxEVT_TIMER, Unbind(wxEVT_TIMER, &wxAuiManager::OnHintFadeTimer, this,
wxTimerEventHandler(wxAuiManager::OnHintFadeTimer)); m_hintFadeTimer.GetId());
return; return;
} }
@@ -3329,8 +3328,8 @@ void wxAuiManager::ShowHint(const wxRect& rect)
// start fade in timer // start fade in timer
m_hintFadeTimer.SetOwner(this); m_hintFadeTimer.SetOwner(this);
m_hintFadeTimer.Start(5); m_hintFadeTimer.Start(5);
Connect(m_hintFadeTimer.GetId(), wxEVT_TIMER, Bind(wxEVT_TIMER, &wxAuiManager::OnHintFadeTimer, this,
wxTimerEventHandler(wxAuiManager::OnHintFadeTimer)); m_hintFadeTimer.GetId());
} }
} }
else // Not using a transparent hint window... else // Not using a transparent hint window...
@@ -3401,8 +3400,8 @@ void wxAuiManager::HideHint()
m_hintFadeTimer.Stop(); m_hintFadeTimer.Stop();
// In case this is called while a hint fade is going, we need to // In case this is called while a hint fade is going, we need to
// disconnect the event handler. // disconnect the event handler.
Disconnect(m_hintFadeTimer.GetId(), wxEVT_TIMER, Unbind(wxEVT_TIMER, &wxAuiManager::OnHintFadeTimer, this,
wxTimerEventHandler(wxAuiManager::OnHintFadeTimer)); m_hintFadeTimer.GetId());
m_lastHint = wxRect(); m_lastHint = wxRect();
return; return;
} }

View File

@@ -67,9 +67,8 @@ bool wxColourPickerCtrl::Create( wxWindow *parent, wxWindowID id,
// complete sizer creation // complete sizer creation
wxPickerBase::PostCreation(); wxPickerBase::PostCreation();
m_picker->Connect(wxEVT_COLOURPICKER_CHANGED, m_picker->Bind(wxEVT_COLOURPICKER_CHANGED,
wxColourPickerEventHandler(wxColourPickerCtrl::OnColourChange), &wxColourPickerCtrl::OnColourChange, this);
NULL, this);
return true; return true;
} }

View File

@@ -1094,15 +1094,10 @@ wxComboCtrlBase::CreateTextCtrl(int style)
style); style);
// Connecting the events is currently the most reliable way // Connecting the events is currently the most reliable way
wxWindowID id = m_text->GetId(); m_text->Bind(wxEVT_TEXT, &wxComboCtrlBase::OnTextCtrlEvent, this);
m_text->Connect(id, wxEVT_TEXT,
wxCommandEventHandler(wxComboCtrlBase::OnTextCtrlEvent),
NULL, this);
if ( style & wxTE_PROCESS_ENTER ) if ( style & wxTE_PROCESS_ENTER )
{ {
m_text->Connect(id, wxEVT_TEXT_ENTER, m_text->Bind(wxEVT_TEXT_ENTER, &wxComboCtrlBase::OnTextCtrlEvent, this);
wxCommandEventHandler(wxComboCtrlBase::OnTextCtrlEvent),
NULL, this);
} }
m_text->SetHint(m_hintText); m_text->SetHint(m_hintText);

View File

@@ -74,9 +74,7 @@ bool wxFontPickerCtrl::Create( wxWindow *parent, wxWindowID id,
// complete sizer creation // complete sizer creation
wxPickerBase::PostCreation(); wxPickerBase::PostCreation();
m_picker->Connect(wxEVT_FONTPICKER_CHANGED, m_picker->Bind(wxEVT_FONTPICKER_CHANGED, &wxFontPickerCtrl::OnFontChange, this);
wxFontPickerEventHandler(wxFontPickerCtrl::OnFontChange),
NULL, this);
return true; return true;
} }

View File

@@ -91,16 +91,9 @@ bool wxPickerBase::CreateBase(wxWindow *parent,
// set the initial contents of the textctrl // set the initial contents of the textctrl
m_text->SetValue(text); m_text->SetValue(text);
m_text->Connect(m_text->GetId(), wxEVT_TEXT, m_text->Bind(wxEVT_TEXT, &wxPickerBase::OnTextCtrlUpdate, this);
wxCommandEventHandler(wxPickerBase::OnTextCtrlUpdate), m_text->Bind(wxEVT_KILL_FOCUS, &wxPickerBase::OnTextCtrlKillFocus, this);
NULL, this); m_text->Bind(wxEVT_DESTROY, &wxPickerBase::OnTextCtrlDelete, this);
m_text->Connect(m_text->GetId(), wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxPickerBase::OnTextCtrlKillFocus),
NULL, this);
m_text->Connect(m_text->GetId(), wxEVT_DESTROY,
wxWindowDestroyEventHandler(wxPickerBase::OnTextCtrlDelete),
NULL, this);
m_sizer->Add(m_text, m_sizer->Add(m_text,
wxSizerFlags(1).CentreVertical().Border(wxRIGHT)); wxSizerFlags(1).CentreVertical().Border(wxRIGHT));

View File

@@ -1139,10 +1139,8 @@ public:
m_maxPage = m_maxPage =
m_page = 1; m_page = 1;
Connect(wxEVT_KILL_FOCUS, Bind(wxEVT_KILL_FOCUS, &wxPrintPageTextCtrl::OnKillFocus, this);
wxFocusEventHandler(wxPrintPageTextCtrl::OnKillFocus)); Bind(wxEVT_TEXT_ENTER, &wxPrintPageTextCtrl::OnTextEnter, this);
Connect(wxEVT_TEXT_ENTER,
wxCommandEventHandler(wxPrintPageTextCtrl::OnTextEnter));
} }
// Update the pages range, must be called after OnPreparePrinting() as // Update the pages range, must be called after OnPreparePrinting() as

View File

@@ -179,7 +179,7 @@ wxTreeCtrlBase::wxTreeCtrlBase()
// quick DoGetBestSize calculation // quick DoGetBestSize calculation
m_quickBestSize = true; m_quickBestSize = true;
Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(wxTreeCtrlBase::OnCharHook)); Bind(wxEVT_CHAR_HOOK, &wxTreeCtrlBase::OnCharHook, this);
} }
wxTreeCtrlBase::~wxTreeCtrlBase() wxTreeCtrlBase::~wxTreeCtrlBase()

View File

@@ -3022,10 +3022,7 @@ wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
{ {
gs_popupMenuSelection = wxID_NONE; gs_popupMenuSelection = wxID_NONE;
Connect(wxEVT_MENU, Bind(wxEVT_MENU, &wxWindowBase::InternalOnPopupMenu, this);
wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu),
NULL,
this);
// it is common to construct the menu passed to this function dynamically // it is common to construct the menu passed to this function dynamically
// using some fixed range of ids which could clash with the ids used // using some fixed range of ids which could clash with the ids used
@@ -3034,21 +3031,12 @@ wxWindowBase::DoGetPopupMenuSelectionFromUser(wxMenu& menu, int x, int y)
// elsewhere in the program code and this is difficult to avoid in the // elsewhere in the program code and this is difficult to avoid in the
// program itself, so instead we just temporarily suspend UI updating while // program itself, so instead we just temporarily suspend UI updating while
// this menu is shown // this menu is shown
Connect(wxEVT_UPDATE_UI, Bind(wxEVT_UPDATE_UI, &wxWindowBase::InternalOnPopupMenuUpdate, this);
wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate),
NULL,
this);
PopupMenu(&menu, x, y); PopupMenu(&menu, x, y);
Disconnect(wxEVT_UPDATE_UI, Unbind(wxEVT_UPDATE_UI, &wxWindowBase::InternalOnPopupMenuUpdate, this);
wxUpdateUIEventHandler(wxWindowBase::InternalOnPopupMenuUpdate), Unbind(wxEVT_MENU, &wxWindowBase::InternalOnPopupMenu, this);
NULL,
this);
Disconnect(wxEVT_MENU,
wxCommandEventHandler(wxWindowBase::InternalOnPopupMenu),
NULL,
this);
return gs_popupMenuSelection; return gs_popupMenuSelection;
} }

View File

@@ -220,10 +220,8 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
CentreOnParent(); CentreOnParent();
#if !wxUSE_MODAL_ABOUT_DIALOG #if !wxUSE_MODAL_ABOUT_DIALOG
Connect(wxEVT_CLOSE_WINDOW, Bind(wxEVT_CLOSE_WINDOW, &wxGenericAboutDialog::OnCloseWindow, this);
wxCloseEventHandler(wxGenericAboutDialog::OnCloseWindow)); Bind(wxEVT_BUTTON, &wxGenericAboutDialog::OnOK, this, wxID_OK);
Connect(wxID_OK, wxEVT_BUTTON,
wxCommandEventHandler(wxGenericAboutDialog::OnOK));
#endif // !wxUSE_MODAL_ABOUT_DIALOG #endif // !wxUSE_MODAL_ABOUT_DIALOG
return true; return true;

View File

@@ -278,9 +278,7 @@ void wxGenericCalendarCtrl::CreateMonthComboBox()
wxDefaultCoord, wxDefaultCoord,
wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT); wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT);
m_comboMonth->Connect(m_comboMonth->GetId(), wxEVT_COMBOBOX, m_comboMonth->Bind(wxEVT_COMBOBOX, &wxGenericCalendarCtrl::OnMonthChange, this);
wxCommandEventHandler(wxGenericCalendarCtrl::OnMonthChange),
NULL, this);
} }
void wxGenericCalendarCtrl::CreateYearSpinCtrl() void wxGenericCalendarCtrl::CreateYearSpinCtrl()
@@ -292,13 +290,8 @@ void wxGenericCalendarCtrl::CreateYearSpinCtrl()
wxSP_ARROW_KEYS | wxCLIP_SIBLINGS, wxSP_ARROW_KEYS | wxCLIP_SIBLINGS,
-4300, 10000, GetDate().GetYear()); -4300, 10000, GetDate().GetYear());
m_spinYear->Connect(m_spinYear->GetId(), wxEVT_TEXT, m_spinYear->Bind(wxEVT_TEXT, &wxGenericCalendarCtrl::OnYearTextChange, this);
wxCommandEventHandler(wxGenericCalendarCtrl::OnYearTextChange), m_spinYear->Bind(wxEVT_SPINCTRL, &wxGenericCalendarCtrl::OnYearChange, this);
NULL, this);
m_spinYear->Connect(m_spinYear->GetId(), wxEVT_SPINCTRL,
wxSpinEventHandler(wxGenericCalendarCtrl::OnYearChange),
NULL, this);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -57,9 +57,7 @@ bool wxGenericColourButton::Create( wxWindow *parent, wxWindowID id,
} }
// and handle user clicks on it // and handle user clicks on it
Connect(GetId(), wxEVT_BUTTON, Bind(wxEVT_BUTTON, &wxGenericColourButton::OnButtonClick, this, GetId());
wxCommandEventHandler(wxGenericColourButton::OnButtonClick),
NULL, this);
m_colour = col; m_colour = col;
UpdateColour(); UpdateColour();

View File

@@ -1514,7 +1514,7 @@ public:
wxWindow( parent, wxID_ANY, wxPoint(0,0), size ) wxWindow( parent, wxID_ANY, wxPoint(0,0), size )
{ {
m_bitmap = bitmap; m_bitmap = bitmap;
Connect( wxEVT_PAINT, wxPaintEventHandler(wxBitmapCanvas::OnPaint) ); Bind(wxEVT_PAINT, &wxBitmapCanvas::OnPaint, this);
} }
void OnPaint( wxPaintEvent &WXUNUSED(event) ) void OnPaint( wxPaintEvent &WXUNUSED(event) )

View File

@@ -86,9 +86,7 @@ public:
if ( !tx ) if ( !tx )
tx = m_combo; tx = m_combo;
tx->Connect(wxEVT_KILL_FOCUS, tx->Bind(wxEVT_KILL_FOCUS, &wxCalendarComboPopup::OnKillTextFocus, this);
wxFocusEventHandler(wxCalendarComboPopup::OnKillTextFocus),
NULL, this);
return true; return true;
} }

View File

@@ -80,9 +80,7 @@ bool wxGenericFileDirButton::Create(wxWindow *parent,
} }
// and handle user clicks on it // and handle user clicks on it
Connect(GetId(), wxEVT_BUTTON, Bind(wxEVT_BUTTON, &wxGenericFileDirButton::OnButtonClick, this, GetId());
wxCommandEventHandler(wxGenericFileDirButton::OnButtonClick),
NULL, this);
// create the dialog associated with this button // create the dialog associated with this button
m_path = path; m_path = path;

View File

@@ -58,9 +58,7 @@ bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id,
} }
// and handle user clicks on it // and handle user clicks on it
Connect(GetId(), wxEVT_BUTTON, Bind(wxEVT_BUTTON, &wxGenericFontButton::OnButtonClick, this, GetId());
wxCommandEventHandler(wxGenericFontButton::OnButtonClick),
NULL, this);
InitFontData(); InitFontData();

View File

@@ -88,15 +88,15 @@ bool wxGenericHyperlinkCtrl::Create(wxWindow *parent, wxWindowID id,
// behave correctly (as we intercept events doing things which interfere // behave correctly (as we intercept events doing things which interfere
// with GTK+'s native handling): // with GTK+'s native handling):
Connect( wxEVT_PAINT, wxPaintEventHandler(wxGenericHyperlinkCtrl::OnPaint) ); Bind( wxEVT_PAINT, &wxGenericHyperlinkCtrl::OnPaint, this);
Connect( wxEVT_SET_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) ); Bind( wxEVT_SET_FOCUS, &wxGenericHyperlinkCtrl::OnFocus, this);
Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler(wxGenericHyperlinkCtrl::OnFocus) ); Bind( wxEVT_KILL_FOCUS, &wxGenericHyperlinkCtrl::OnFocus, this);
Connect( wxEVT_CHAR, wxKeyEventHandler(wxGenericHyperlinkCtrl::OnChar) ); Bind( wxEVT_CHAR, &wxGenericHyperlinkCtrl::OnChar, this);
Connect( wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeaveWindow) ); Bind( wxEVT_LEAVE_WINDOW, &wxGenericHyperlinkCtrl::OnLeaveWindow, this);
Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftDown) ); Bind( wxEVT_LEFT_DOWN, &wxGenericHyperlinkCtrl::OnLeftDown, this);
Connect( wxEVT_LEFT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnLeftUp) ); Bind( wxEVT_LEFT_UP, &wxGenericHyperlinkCtrl::OnLeftUp, this);
Connect( wxEVT_MOTION, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnMotion) ); Bind( wxEVT_MOTION, &wxGenericHyperlinkCtrl::OnMotion, this);
ConnectMenuHandlers(); ConnectMenuHandlers();
@@ -118,9 +118,9 @@ void wxGenericHyperlinkCtrl::Init()
void wxGenericHyperlinkCtrl::ConnectMenuHandlers() void wxGenericHyperlinkCtrl::ConnectMenuHandlers()
{ {
// Connect the event handlers for the context menu. // Connect the event handlers for the context menu.
Connect( wxEVT_RIGHT_UP, wxMouseEventHandler(wxGenericHyperlinkCtrl::OnRightUp) ); Bind( wxEVT_RIGHT_UP, &wxGenericHyperlinkCtrl::OnRightUp, this);
Connect( wxHYPERLINK_POPUP_COPY_ID, wxEVT_MENU, Bind( wxEVT_MENU, &wxGenericHyperlinkCtrl::OnPopUpCopy, this,
wxCommandEventHandler(wxGenericHyperlinkCtrl::OnPopUpCopy) ); wxHYPERLINK_POPUP_COPY_ID);
} }
wxSize wxGenericHyperlinkCtrl::DoGetBestClientSize() const wxSize wxGenericHyperlinkCtrl::DoGetBestClientSize() const

View File

@@ -534,17 +534,15 @@ wxGenericMDIClientWindow::CreateGenericClient(wxWindow *parent)
return false; return false;
m_notebook = new wxNotebook(this, wxID_ANY); m_notebook = new wxNotebook(this, wxID_ANY);
m_notebook->Connect m_notebook->Bind
( (
wxEVT_NOTEBOOK_PAGE_CHANGED, wxEVT_NOTEBOOK_PAGE_CHANGED,
wxNotebookEventHandler( &wxGenericMDIClientWindow::OnPageChanged,
wxGenericMDIClientWindow::OnPageChanged),
NULL,
this this
); );
// now that we have a notebook to resize, hook up OnSize() too // now that we have a notebook to resize, hook up OnSize() too
Connect(wxEVT_SIZE, wxSizeEventHandler(wxGenericMDIClientWindow::OnSize)); Bind(wxEVT_SIZE, &wxGenericMDIClientWindow::OnSize, this);
return true; return true;
} }

View File

@@ -252,7 +252,7 @@ public:
return; return;
} }
Connect(wxEVT_TIMER, wxTimerEventHandler(wxRichToolTipPopup::OnTimer)); Bind(wxEVT_TIMER, &wxRichToolTipPopup::OnTimer, this);
m_timeout = timeout; // set for use in OnTimer if we have a delay m_timeout = timeout; // set for use in OnTimer if we have a delay
m_delayShow = delay != 0; m_delayShow = delay != 0;

View File

@@ -35,7 +35,7 @@ bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
return false; return false;
m_scaleMode = Scale_None; m_scaleMode = Scale_None;
SetBitmap(bitmap); SetBitmap(bitmap);
Connect(wxEVT_PAINT, wxPaintEventHandler(wxGenericStaticBitmap::OnPaint)); Bind(wxEVT_PAINT, &wxGenericStaticBitmap::OnPaint, this);
return true; return true;
} }

View File

@@ -44,7 +44,7 @@ bool wxGenericStaticText::Create(wxWindow *parent,
SetLabel(label); SetLabel(label);
SetInitialSize(size); SetInitialSize(size);
Connect(wxEVT_PAINT, wxPaintEventHandler(wxGenericStaticText::OnPaint)); Bind(wxEVT_PAINT, &wxGenericStaticText::OnPaint, this);
return true; return true;
} }

View File

@@ -92,42 +92,12 @@ public:
m_useAMPM = false; m_useAMPM = false;
#endif #endif
m_text->Connect m_text->Bind(wxEVT_SET_FOCUS, &wxTimePickerGenericImpl::OnTextSetFocus, this);
( m_text->Bind(wxEVT_KEY_DOWN, &wxTimePickerGenericImpl::OnTextKeyDown, this);
wxEVT_SET_FOCUS, m_text->Bind(wxEVT_LEFT_DOWN, &wxTimePickerGenericImpl::OnTextClick, this);
wxFocusEventHandler(wxTimePickerGenericImpl::OnTextSetFocus),
NULL,
this
);
m_text->Connect
(
wxEVT_KEY_DOWN,
wxKeyEventHandler(wxTimePickerGenericImpl::OnTextKeyDown),
NULL,
this
);
m_text->Connect
(
wxEVT_LEFT_DOWN,
wxMouseEventHandler(wxTimePickerGenericImpl::OnTextClick),
NULL,
this
);
m_btn->Connect m_btn->Bind(wxEVT_SPIN_UP, &wxTimePickerGenericImpl::OnArrowUp, this);
( m_btn->Bind(wxEVT_SPIN_DOWN, &wxTimePickerGenericImpl::OnArrowDown, this);
wxEVT_SPIN_UP,
wxSpinEventHandler(wxTimePickerGenericImpl::OnArrowUp),
NULL,
this
);
m_btn->Connect
(
wxEVT_SPIN_DOWN,
wxSpinEventHandler(wxTimePickerGenericImpl::OnArrowDown),
NULL,
this
);
} }
// Set the new value. // Set the new value.

View File

@@ -355,17 +355,13 @@ void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
case State_Focused: case State_Focused:
if ( bitmap.IsOk() ) if ( bitmap.IsOk() )
{ {
Connect(wxEVT_SET_FOCUS, Bind(wxEVT_SET_FOCUS, &wxAnyButton::GTKOnFocus, this);
wxFocusEventHandler(wxAnyButton::GTKOnFocus)); Bind(wxEVT_KILL_FOCUS, &wxAnyButton::GTKOnFocus, this);
Connect(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxAnyButton::GTKOnFocus));
} }
else // no valid focused bitmap else // no valid focused bitmap
{ {
Disconnect(wxEVT_SET_FOCUS, Unbind(wxEVT_SET_FOCUS, &wxAnyButton::GTKOnFocus, this);
wxFocusEventHandler(wxAnyButton::GTKOnFocus)); Unbind(wxEVT_KILL_FOCUS, &wxAnyButton::GTKOnFocus, this);
Disconnect(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxAnyButton::GTKOnFocus));
} }
break; break;

View File

@@ -88,9 +88,7 @@ bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
// we need to know when the dialog has been dismissed clicking OK... // we need to know when the dialog has been dismissed clicking OK...
// NOTE: the "clicked" signal is not available for a GtkFileChooserButton // NOTE: the "clicked" signal is not available for a GtkFileChooserButton
// thus we are forced to use wxFileDialog's event // thus we are forced to use wxFileDialog's event
m_dialog->Connect(wxEVT_BUTTON, m_dialog->Bind(wxEVT_BUTTON, &wxFileButton::OnDialogOK, this);
wxCommandEventHandler(wxFileButton::OnDialogOK),
NULL, this);
m_parent->DoAddChild( this ); m_parent->DoAddChild( this );

View File

@@ -134,24 +134,12 @@ public:
m_mask(CreateShapeBitmap(path), *wxBLACK) m_mask(CreateShapeBitmap(path), *wxBLACK)
{ {
m_win->Connect m_win->Bind(wxEVT_PAINT, &wxNonOwnedWindowShapeImplPath::OnPaint, this);
(
wxEVT_PAINT,
wxPaintEventHandler(wxNonOwnedWindowShapeImplPath::OnPaint),
NULL,
this
);
} }
virtual ~wxNonOwnedWindowShapeImplPath() virtual ~wxNonOwnedWindowShapeImplPath()
{ {
m_win->Disconnect m_win->Unbind(wxEVT_PAINT, &wxNonOwnedWindowShapeImplPath::OnPaint, this);
(
wxEVT_PAINT,
wxPaintEventHandler(wxNonOwnedWindowShapeImplPath::OnPaint),
NULL,
this
);
} }
// Currently we always return false from here, if drawing the border // Currently we always return false from here, if drawing the border

View File

@@ -122,10 +122,8 @@ wxCalendarCtrl::Create(wxWindow *parent,
SetHolidayAttrs(); SetHolidayAttrs();
UpdateMarks(); UpdateMarks();
Connect(wxEVT_LEFT_DOWN, Bind(wxEVT_LEFT_DOWN, &wxCalendarCtrl::MSWOnClick, this);
wxMouseEventHandler(wxCalendarCtrl::MSWOnClick)); Bind(wxEVT_LEFT_DCLICK, &wxCalendarCtrl::MSWOnDoubleClick, this);
Connect(wxEVT_LEFT_DCLICK,
wxMouseEventHandler(wxCalendarCtrl::MSWOnDoubleClick));
return true; return true;
} }

View File

@@ -111,8 +111,7 @@ bool wxDialog::Create(wxWindow *parent,
{ {
CreateGripper(); CreateGripper();
Connect(wxEVT_CREATE, Bind(wxEVT_CREATE, &wxDialog::OnWindowCreate, this);
wxWindowCreateEventHandler(wxDialog::OnWindowCreate));
} }
return true; return true;

View File

@@ -892,10 +892,10 @@ public:
wxAMMediaEvtHandler(wxAMMediaBackend *amb) : wxAMMediaEvtHandler(wxAMMediaBackend *amb) :
m_amb(amb), m_bLoadEventSent(false) m_amb(amb), m_bLoadEventSent(false)
{ {
m_amb->m_pAX->Connect(m_amb->m_pAX->GetId(), m_amb->m_pAX->Bind(
wxEVT_ACTIVEX, wxEVT_ACTIVEX,
wxActiveXEventHandler(wxAMMediaEvtHandler::OnActiveX), &wxAMMediaEvtHandler::OnActiveX, this,
NULL, this m_amb->m_pAX->GetId()
); );
} }

View File

@@ -416,10 +416,9 @@ public:
m_qtb = qtb; m_qtb = qtb;
m_hwnd = hwnd; m_hwnd = hwnd;
m_qtb->m_ctrl->Connect(m_qtb->m_ctrl->GetId(), m_qtb->m_ctrl->Bind(
wxEVT_ERASE_BACKGROUND, wxEVT_ERASE_BACKGROUND,
wxEraseEventHandler(wxQTMediaEvtHandler::OnEraseBackground), &wxQTMediaEvtHandler::OnEraseBackground, this);
NULL, this);
} }
void OnEraseBackground(wxEraseEvent& event); void OnEraseBackground(wxEraseEvent& event);

View File

@@ -681,11 +681,9 @@ public:
wxWMP10MediaEvtHandler(wxWMP10MediaBackend *amb) : wxWMP10MediaEvtHandler(wxWMP10MediaBackend *amb) :
m_amb(amb) m_amb(amb)
{ {
m_amb->m_pAX->Connect(m_amb->m_pAX->GetId(), m_amb->m_pAX->Bind(wxEVT_ACTIVEX,
wxEVT_ACTIVEX, &wxWMP10MediaEvtHandler::OnActiveX, this,
wxActiveXEventHandler(wxWMP10MediaEvtHandler::OnActiveX), m_amb->m_pAX->GetId());
NULL, this
);
} }
void OnActiveX(wxActiveXEvent& event); void OnActiveX(wxActiveXEvent& event);

View File

@@ -82,11 +82,7 @@ bool wxNonOwnedWindow::DoSetRegionShape(const wxRegion& region)
#include "wx/msw/wrapgdip.h" #include "wx/msw/wrapgdip.h"
// This class contains data used only when SetPath(wxGraphicsPath) is called. // This class contains data used only when SetPath(wxGraphicsPath) is called.
// class wxNonOwnedWindowShapeImpl
// Notice that it derives from wxEvtHandler solely to allow Connect()-ing its
// OnPaint() method to the window, we could get rid of this inheritance once
// Bind() can be used in wx sources.
class wxNonOwnedWindowShapeImpl : public wxEvtHandler
{ {
public: public:
wxNonOwnedWindowShapeImpl(wxNonOwnedWindow* win, const wxGraphicsPath& path) : wxNonOwnedWindowShapeImpl(wxNonOwnedWindow* win, const wxGraphicsPath& path) :
@@ -107,24 +103,12 @@ public:
// Connect to the paint event to draw the border. // Connect to the paint event to draw the border.
// //
// TODO: Do this only optionally? // TODO: Do this only optionally?
m_win->Connect m_win->Bind(wxEVT_PAINT, &wxNonOwnedWindowShapeImpl::OnPaint, this);
(
wxEVT_PAINT,
wxPaintEventHandler(wxNonOwnedWindowShapeImpl::OnPaint),
NULL,
this
);
} }
virtual ~wxNonOwnedWindowShapeImpl() virtual ~wxNonOwnedWindowShapeImpl()
{ {
m_win->Disconnect m_win->Unbind(wxEVT_PAINT, &wxNonOwnedWindowShapeImpl::OnPaint, this);
(
wxEVT_PAINT,
wxPaintEventHandler(wxNonOwnedWindowShapeImpl::OnPaint),
NULL,
this
);
} }
private: private:

View File

@@ -1131,14 +1131,9 @@ void wxActiveXContainer::CreateActiveX(REFIID iid, IUnknown* pUnk)
wxWindow* pWnd = m_realparent; wxWindow* pWnd = m_realparent;
int id = m_realparent->GetId(); int id = m_realparent->GetId();
pWnd->Connect(id, wxEVT_SIZE, pWnd->Bind(wxEVT_SIZE, &wxActiveXContainer::OnSize, this, id);
wxSizeEventHandler(wxActiveXContainer::OnSize), 0, this); pWnd->Bind(wxEVT_SET_FOCUS, &wxActiveXContainer::OnSetFocus, this, id);
// this->Connect(GetId(), wxEVT_PAINT, pWnd->Bind(wxEVT_KILL_FOCUS, &wxActiveXContainer::OnKillFocus, this, id);
// wxPaintEventHandler(wxActiveXContainer::OnPaint), 0, this);
pWnd->Connect(id, wxEVT_SET_FOCUS,
wxFocusEventHandler(wxActiveXContainer::OnSetFocus), 0, this);
pWnd->Connect(id, wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxActiveXContainer::OnKillFocus), 0, this);
} }
} }

View File

@@ -128,7 +128,7 @@ bool wxStaticBitmap::Create(wxWindow *parent,
// check if we have an image with alpha or not // check if we have an image with alpha or not
if ( wxTheApp->GetComCtl32Version() < 600 ) if ( wxTheApp->GetComCtl32Version() < 600 )
{ {
Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBitmap::DoPaintManually)); Bind(wxEVT_PAINT, &wxStaticBitmap::DoPaintManually, this);
} }
return true; return true;

View File

@@ -90,7 +90,7 @@ bool wxStaticBox::Create(wxWindow *parent,
if (!wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint"))) if (!wxSystemOptions::IsFalse(wxT("msw.staticbox.optimized-paint")))
{ {
Connect(wxEVT_PAINT, wxPaintEventHandler(wxStaticBox::OnPaint)); Bind(wxEVT_PAINT, &wxStaticBox::OnPaint, this);
// Our OnPaint() completely erases our background, so don't do it in // Our OnPaint() completely erases our background, so don't do it in
// WM_ERASEBKGND too to avoid flicker. // WM_ERASEBKGND too to avoid flicker.

View File

@@ -584,7 +584,7 @@ bool wxTextCtrl::MSWCreateText(const wxString& value,
} }
#endif #endif
if ( !contextMenuConnected ) if ( !contextMenuConnected )
Connect(wxEVT_CONTEXT_MENU, wxContextMenuEventHandler(wxTextCtrl::OnContextMenu)); Bind(wxEVT_CONTEXT_MENU, &wxTextCtrl::OnContextMenu, this);
} }
else else
#endif // wxUSE_RICHEDIT #endif // wxUSE_RICHEDIT

View File

@@ -390,7 +390,7 @@ wxWindow* wxFileDialog::CreateFilterPanel(wxWindow *extracontrol)
if ( m_firstFileTypeFilter >= 0 ) if ( m_firstFileTypeFilter >= 0 )
m_filterChoice->SetSelection(m_firstFileTypeFilter); m_filterChoice->SetSelection(m_firstFileTypeFilter);
} }
m_filterChoice->Connect(wxEVT_CHOICE, wxCommandEventHandler(wxFileDialog::OnFilterSelected), NULL, this); m_filterChoice->Bind(wxEVT_CHOICE, &wxFileDialog::OnFilterSelected, this);
} }
if(extracontrol) if(extracontrol)

View File

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

View File

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

View File

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

View File

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

View File

@@ -227,14 +227,14 @@ void wxRibbonPanel::AddChild(wxWindowBase *child)
// for children of the window. The panel wants to be in the hovered state // for children of the window. The panel wants to be in the hovered state
// whenever the mouse cursor is within its boundary, so the events need to // whenever the mouse cursor is within its boundary, so the events need to
// be attached to children too. // be attached to children too.
child->Connect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(wxRibbonPanel::OnMouseEnterChild), NULL, this); child->Bind(wxEVT_ENTER_WINDOW, &wxRibbonPanel::OnMouseEnterChild, this);
child->Connect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxRibbonPanel::OnMouseLeaveChild), NULL, this); child->Bind(wxEVT_LEAVE_WINDOW, &wxRibbonPanel::OnMouseLeaveChild, this);
} }
void wxRibbonPanel::RemoveChild(wxWindowBase *child) void wxRibbonPanel::RemoveChild(wxWindowBase *child)
{ {
child->Disconnect(wxEVT_ENTER_WINDOW, wxMouseEventHandler(wxRibbonPanel::OnMouseEnterChild), NULL, this); child->Unbind(wxEVT_ENTER_WINDOW, &wxRibbonPanel::OnMouseEnterChild, this);
child->Disconnect(wxEVT_LEAVE_WINDOW, wxMouseEventHandler(wxRibbonPanel::OnMouseLeaveChild), NULL, this); child->Unbind(wxEVT_LEAVE_WINDOW, &wxRibbonPanel::OnMouseLeaveChild, this);
wxRibbonControl::RemoveChild(child); wxRibbonControl::RemoveChild(child);
} }
@@ -906,9 +906,8 @@ void wxRibbonPanel::OnKillFocus(wxFocusEvent& evt)
if(IsAncestorOf(this, receiver)) if(IsAncestorOf(this, receiver))
{ {
m_child_with_focus = receiver; m_child_with_focus = receiver;
receiver->Connect(wxEVT_KILL_FOCUS, receiver->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), &wxRibbonPanel::OnChildKillFocus, this);
NULL, this);
} }
else if(receiver == NULL || receiver != m_expanded_dummy) else if(receiver == NULL || receiver != m_expanded_dummy)
{ {
@@ -922,16 +921,16 @@ void wxRibbonPanel::OnChildKillFocus(wxFocusEvent& evt)
if(m_child_with_focus == NULL) if(m_child_with_focus == NULL)
return; // Should never happen, but a check can't hurt return; // Should never happen, but a check can't hurt
m_child_with_focus->Disconnect(wxEVT_KILL_FOCUS, m_child_with_focus->Unbind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), NULL, this); &wxRibbonPanel::OnChildKillFocus, this);
m_child_with_focus = NULL; m_child_with_focus = NULL;
wxWindow *receiver = evt.GetWindow(); wxWindow *receiver = evt.GetWindow();
if(receiver == this || IsAncestorOf(this, receiver)) if(receiver == this || IsAncestorOf(this, receiver))
{ {
m_child_with_focus = receiver; m_child_with_focus = receiver;
receiver->Connect(wxEVT_KILL_FOCUS, receiver->Bind(wxEVT_KILL_FOCUS,
wxFocusEventHandler(wxRibbonPanel::OnChildKillFocus), NULL, this); &wxRibbonPanel::OnChildKillFocus, this);
evt.Skip(); evt.Skip();
} }
else if(receiver == NULL || receiver != m_expanded_dummy) else if(receiver == NULL || receiver != m_expanded_dummy)

View File

@@ -366,9 +366,9 @@ bool ScintillaWX::SetIdle(bool on) {
if (idler.state != on) { if (idler.state != on) {
// connect or disconnect the EVT_IDLE handler // connect or disconnect the EVT_IDLE handler
if (on) if (on)
stc->Connect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxStyledTextCtrl::OnIdle)); stc->Bind(wxEVT_IDLE, &wxStyledTextCtrl::OnIdle, stc);
else else
stc->Disconnect(wxID_ANY, wxEVT_IDLE, wxIdleEventHandler(wxStyledTextCtrl::OnIdle)); stc->Unbind(wxEVT_IDLE, &wxStyledTextCtrl::OnIdle, stc);
idler.state = on; idler.state = on;
} }
return idler.state; return idler.state;

View File

@@ -204,8 +204,8 @@ class wxGStreamerMediaEventHandler : public wxEvtHandler
public: public:
wxGStreamerMediaEventHandler(wxGStreamerMediaBackend* be) : m_be(be) wxGStreamerMediaEventHandler(wxGStreamerMediaBackend* be) : m_be(be)
{ {
this->Connect(wxID_ANY, wxEVT_MEDIA_FINISHED, this->Bind(wxEVT_MEDIA_FINISHED,
wxMediaEventHandler(wxGStreamerMediaEventHandler::OnMediaFinish)); &wxGStreamerMediaEventHandler::OnMediaFinish, this);
} }
void OnMediaFinish(wxMediaEvent& event); void OnMediaFinish(wxMediaEvent& event);

View File

@@ -256,8 +256,7 @@ wxTaskBarIcon::~wxTaskBarIcon()
{ {
if (m_iconWnd) if (m_iconWnd)
{ {
m_iconWnd->Disconnect(wxEVT_DESTROY, m_iconWnd->Unbind(wxEVT_DESTROY, &wxTaskBarIcon::OnDestroy, this);
wxWindowDestroyEventHandler(wxTaskBarIcon::OnDestroy), NULL, this);
RemoveIcon(); RemoveIcon();
} }
} }
@@ -290,9 +289,7 @@ bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip)
m_iconWnd = new wxTaskBarIconArea(this, bmp); m_iconWnd = new wxTaskBarIconArea(this, bmp);
if (m_iconWnd->IsOk()) if (m_iconWnd->IsOk())
{ {
m_iconWnd->Connect(wxEVT_DESTROY, m_iconWnd->Bind(wxEVT_DESTROY, &wxTaskBarIcon::OnDestroy, this);
wxWindowDestroyEventHandler(wxTaskBarIcon::OnDestroy),
NULL, this);
m_iconWnd->Show(); m_iconWnd->Show();
} }
else else

View File

@@ -488,6 +488,55 @@ void MenuTestCase::ChangeBitmap()
wxDELETE(menu); wxDELETE(menu);
} }
#if wxUSE_UIACTIONSIMULATOR
// In C++98 this class can't be defined inside Events() method, unfortunately,
// as its OnMenu() method wouldn't be usable with template Bind() then.
class MenuEventHandler : public wxEvtHandler
{
public:
MenuEventHandler(wxWindow* win)
: m_win(win)
{
m_win->Bind(wxEVT_MENU, &MenuEventHandler::OnMenu, this);
m_gotEvent = false;
m_event = NULL;
}
virtual ~MenuEventHandler()
{
m_win->Unbind(wxEVT_MENU, &MenuEventHandler::OnMenu, this);
delete m_event;
}
const wxCommandEvent& GetEvent()
{
CPPUNIT_ASSERT( m_gotEvent );
m_gotEvent = false;
return *m_event;
}
private:
void OnMenu(wxCommandEvent& event)
{
CPPUNIT_ASSERT( !m_gotEvent );
delete m_event;
m_event = static_cast<wxCommandEvent*>(event.Clone());
m_gotEvent = true;
}
wxWindow* const m_win;
wxCommandEvent* m_event;
bool m_gotEvent;
};
#endif // wxUSE_UIACTIONSIMULATOR
void MenuTestCase::Events() void MenuTestCase::Events()
{ {
#ifdef __WXGTK__ #ifdef __WXGTK__
@@ -502,55 +551,6 @@ void MenuTestCase::Events()
#endif // __WXGTK__ #endif // __WXGTK__
#if wxUSE_UIACTIONSIMULATOR #if wxUSE_UIACTIONSIMULATOR
class MenuEventHandler : public wxEvtHandler
{
public:
MenuEventHandler(wxWindow* win)
: m_win(win)
{
m_win->Connect(wxEVT_MENU,
wxCommandEventHandler(MenuEventHandler::OnMenu),
NULL,
this);
m_gotEvent = false;
m_event = NULL;
}
virtual ~MenuEventHandler()
{
m_win->Disconnect(wxEVT_MENU,
wxCommandEventHandler(MenuEventHandler::OnMenu),
NULL,
this);
delete m_event;
}
const wxCommandEvent& GetEvent()
{
CPPUNIT_ASSERT( m_gotEvent );
m_gotEvent = false;
return *m_event;
}
private:
void OnMenu(wxCommandEvent& event)
{
CPPUNIT_ASSERT( !m_gotEvent );
delete m_event;
m_event = static_cast<wxCommandEvent*>(event.Clone());
m_gotEvent = true;
}
wxWindow* const m_win;
wxCommandEvent* m_event;
bool m_gotEvent;
};
MenuEventHandler handler(m_frame); MenuEventHandler handler(m_frame);
// Invoke the accelerator. // Invoke the accelerator.

View File

@@ -56,7 +56,7 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons
statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY ); statusBar = this->CreateStatusBar( 1, wxST_SIZEGRIP, wxID_ANY );
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( GUIFrame::OnClose ) ); Bind(wxEVT_CLOSE_WINDOW, &GUIFrame::OnClose, this);
} }
void GUIFrame::AddMenuBar() void GUIFrame::AddMenuBar()
@@ -102,11 +102,11 @@ void GUIFrame::AddMenuBar()
this->SetMenuBar( mbar ); this->SetMenuBar( mbar );
// Connect Events // Connect Events
this->Connect( m_menuSeeScr->GetId(), wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnSeeScreenshots ) ); Bind(wxEVT_MENU, &GUIFrame::OnSeeScreenshots, this, m_menuSeeScr->GetId());
this->Connect( m_menuFileQuit->GetId(), wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnQuit ) ); Bind(wxEVT_MENU, &GUIFrame::OnQuit, this, m_menuFileQuit->GetId());
this->Connect( m_menuCapFullScreen->GetId(), wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnCaptureFullScreen ) ); Bind(wxEVT_MENU, &GUIFrame::OnCaptureFullScreen, this, m_menuCapFullScreen->GetId());
this->Connect( m_menuCapAll->GetId(), wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnCaptureAllControls ) ); Bind(wxEVT_MENU, &GUIFrame::OnCaptureAllControls, this, m_menuCapAll->GetId());
this->Connect( m_menuHelpAbout->GetId(), wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnAbout ) ); Bind(wxEVT_MENU, &GUIFrame::OnAbout, this, m_menuHelpAbout->GetId());
} }
void GUIFrame::AddPanel_1() void GUIFrame::AddPanel_1()
@@ -493,10 +493,10 @@ void GUIFrame::AddPanel_5()
GUIFrame::~GUIFrame() GUIFrame::~GUIFrame()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( GUIFrame::OnClose ) ); Unbind(wxEVT_CLOSE_WINDOW, &GUIFrame::OnClose, this);
this->Disconnect( wxID_ANY, wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnSeeScreenshots ) ); Unbind(wxEVT_MENU, &GUIFrame::OnSeeScreenshots, this);
this->Disconnect( wxID_ANY, wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnQuit ) ); Unbind(wxEVT_MENU, &GUIFrame::OnQuit, this);
this->Disconnect( wxID_ANY, wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnCaptureFullScreen ) ); Unbind(wxEVT_MENU, &GUIFrame::OnCaptureFullScreen, this);
this->Disconnect( wxID_ANY, wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnCaptureAllControls ) ); Unbind(wxEVT_MENU, &GUIFrame::OnCaptureAllControls, this);
this->Disconnect( wxID_ANY, wxEVT_MENU, wxCommandEventHandler( GUIFrame::OnAbout ) ); Unbind(wxEVT_MENU, &GUIFrame::OnAbout, this);
} }