// it may also be convenient to define an event table macro for this event type
#define EVT_MY_CUSTOM_COMMAND(id, fn) \
DECLARE_EVENT_TABLE_ENTRY( \
- wxEVT_MY_CUSTOM_COMMAND, id, -1, \
+ wxEVT_MY_CUSTOM_COMMAND, id, wxID_ANY, \
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent( wxCommandEventFunction, &fn ), \
(wxObject *) NULL \
),
EVT_UPDATE_UI(Event_Pop, MyFrame::OnUpdateUIPop)
- EVT_MY_CUSTOM_COMMAND(-1, MyFrame::OnProcessCustom)
+ EVT_MY_CUSTOM_COMMAND(wxID_ANY, MyFrame::OnProcessCustom)
- // this would also work:
- //EVT_CUSTOM(wxEVT_MY_CUSTOM_COMMAND, -1, MyFrame::OnProcessCustom)
+ // the line below would also work if OnProcessCustom() were defined as
+ // taking a wxEvent (as required by EVT_CUSTOM) and not wxCommandEvent
+ //EVT_CUSTOM(wxEVT_MY_CUSTOM_COMMAND, wxID_ANY, MyFrame::OnProcessCustom)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyEvtHandler, wxEvtHandler)
// and show it (the frames, unlike simple controls, are not shown when
// created initially)
- frame->Show(TRUE);
+ frame->Show(true);
// 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
// application would exit immediately.
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
// frame constructor
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
- : wxFrame((wxFrame *)NULL, -1, title, pos, size)
+ : wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
{
// init members
m_nPush = 0;
wxMenu *menuEvent = new wxMenu;
menuEvent->Append(Event_Connect, _T("&Connect\tCtrl-C"),
_T("Connect or disconnect the dynamic event handler"),
- TRUE /* checkable */);
+ true /* checkable */);
menuEvent->Append(Event_Dynamic, _T("&Dynamic event\tCtrl-D"),
_T("Dynamic event sample - only works after Connect"));
menuEvent->AppendSeparator();
// crashes!
while ( m_nPush-- != 0 )
{
- PopEventHandler(TRUE /* delete handler */);
+ PopEventHandler(true /* delete handler */);
}
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
- // TRUE is to force the frame to close
- Close(TRUE);
+ // true is to force the frame to close
+ Close(true);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox( wxT("Event sample shows different ways of using events\n")
- wxT("© 2001 Vadim Zeitlin"),
+ wxT("(c) 2001 Vadim Zeitlin"),
wxT("About Event Sample"), wxOK | wxICON_INFORMATION, this );
}
if ( event.IsChecked() )
{
// disconnect
- Connect(Event_Dynamic, -1, wxEVT_COMMAND_MENU_SELECTED,
+ Connect(Event_Dynamic, wxID_ANY, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction)
(wxEventFunction)
(wxCommandEventFunction)&MyFrame::OnDynamic);
+#if wxUSE_STATUSBAR
SetStatusText(_T("You can now use \"Dynamic\" item in the menu"));
SetStatusText(_T("Dynamic: on"), Status_Dynamic);
+#endif // wxUSE_STATUSBAR
}
else // connect
{
- Disconnect(Event_Dynamic, -1, wxEVT_COMMAND_MENU_SELECTED);
+ Disconnect(Event_Dynamic, wxID_ANY, wxEVT_COMMAND_MENU_SELECTED);
+#if wxUSE_STATUSBAR
SetStatusText(_T("You can no more use \"Dynamic\" item in the menu"));
SetStatusText(_T("Dynamic: off"), Status_Dynamic);
+#endif // wxUSE_STATUSBAR
}
}
{
PushEventHandler(new MyEvtHandler(++m_nPush));
+#if wxUSE_STATUSBAR
SetStatusText(wxString::Format(_T("Push count: %u"), m_nPush), Status_Push);
+#endif // wxUSE_STATUSBAR
}
void MyFrame::OnPopEventHandler(wxCommandEvent& WXUNUSED(event))
{
wxCHECK_RET( m_nPush, _T("this command should be disabled!") );
- PopEventHandler(TRUE /* delete handler */);
+ PopEventHandler(true /* delete handler */);
m_nPush--;
+#if wxUSE_STATUSBAR
SetStatusText(wxString::Format(_T("Push count: %u"), m_nPush), Status_Push);
+#endif // wxUSE_STATUSBAR
}
void MyFrame::OnTest(wxCommandEvent& WXUNUSED(event))