+
+ //
+ // 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 MyFrame.
+ //
+ // Then after your class declaration you put
+ // BEGIN_EVENT_TABLE(MyFrame, wxFrame)
+ // EVT_XXX(XXX)...
+ // END_EVENT_TABLE()
+ //
+ // Where MyFrame 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) &MyFrame::MyHandler
+ //
+ // 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
+ //
+ this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnQuit);
+
+ this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnAbout);
+
+ this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnLoop);
+
+ this->Connect(wxID_OPENFILENEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnOpenFileNewPage);
+
+ this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnOpenFileSamePage);
+
+ this->Connect(wxID_OPENURLNEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnOpenURLNewPage);
+
+ this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnOpenURLSamePage);
+
+ this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnCloseCurrentPage);
+
+ this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnPlay);
+
+ this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnPause);
+
+ this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxCommandEventFunction) &MyFrame::OnStop);
+
+ //
+ // Notebook events
+ //
+ this->Connect(wxID_NOTEBOOK, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
+ (wxObjectEventFunction) (wxEventFunction)
+ (wxNotebookEventFunction) &MyFrame::OnPageChange);
+
+ //
+ // End of Events
+ //
+
+ //
+ // Create a timer to update our status bar
+ //
+ m_timer = new MyTimer(this);
+ m_timer->Start(100);