* Update for new event handler stuff

* Update notebook page text on file change
* Some other misc. cleanups (remove strmiids.lib dependancy, cleanup enums, etc.)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32891 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ryan Norton
2005-03-18 11:50:18 +00:00
parent 4153a503ba
commit 14af6816d0

View File

@@ -68,9 +68,6 @@
//Libraries for MSVC with optional backends //Libraries for MSVC with optional backends
#ifdef _MSC_VER #ifdef _MSC_VER
#if wxUSE_DIRECTSHOW
#pragma comment(lib,"strmiids.lib")
#endif
#if wxUSE_QUICKTIME #if wxUSE_QUICKTIME
#pragma comment(lib,"qtmlClient.lib") #pragma comment(lib,"qtmlClient.lib")
#endif #endif
@@ -112,15 +109,9 @@ enum
// wxID_STOP, [built-in to wxWidgets] // wxID_STOP, [built-in to wxWidgets]
// wxID_ABOUT, [built-in to wxWidgets] // wxID_ABOUT, [built-in to wxWidgets]
// wxID_EXIT, [built-in to wxWidgets] // wxID_EXIT, [built-in to wxWidgets]
wxID_SLIDER, // event id for our slider
// event id for our slider wxID_NOTEBOOK, // event id for our notebook
wxID_SLIDER, wxID_MEDIACTRL // event id for our wxMediaCtrl
// event id for our notebook
wxID_NOTEBOOK,
// event id for our wxMediaCtrl
wxID_MEDIACTRL
}; };
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -176,7 +167,7 @@ private:
class MyTimer* m_timer; //Timer to write info to status bar class MyTimer* m_timer; //Timer to write info to status bar
wxString m_basestatus; //Base status string (see ResetStatus()) wxString m_basestatus; //Base status string (see ResetStatus())
wxNotebook* m_notebook; wxNotebook* m_notebook; //Notebook containing our pages
// So that mytimer can access MyFrame's members // So that mytimer can access MyFrame's members
friend class MyTimer; friend class MyTimer;
@@ -413,6 +404,12 @@ MyFrame::MyFrame(const wxString& title)
// (wxObjectEventFunction)(wxEventFunction) // (wxObjectEventFunction)(wxEventFunction)
// (wxCommandEventFunction) &MyFrame::MyHandler // (wxCommandEventFunction) &MyFrame::MyHandler
// //
// Or, you can use the new (2.5.5+) event handler
// conversion macros - for instance the above could
// be done as
// wxCommandEventHandler(MyFrame::MyHandler)
// pretty simple, eh?
//
// The fourth is an optional userdata param - // The fourth is an optional userdata param -
// this is of historical relevance only and is // this is of historical relevance only and is
// there only for backwards compatibility. // there only for backwards compatibility.
@@ -432,55 +429,43 @@ MyFrame::MyFrame(const wxString& title)
// Menu events // Menu events
// //
this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnQuit));
(wxCommandEventFunction) &MyFrame::OnQuit);
this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnAbout));
(wxCommandEventFunction) &MyFrame::OnAbout);
this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnLoop));
(wxCommandEventFunction) &MyFrame::OnLoop);
this->Connect(wxID_OPENFILENEWPAGE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_OPENFILENEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnOpenFileNewPage));
(wxCommandEventFunction) &MyFrame::OnOpenFileNewPage);
this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnOpenFileSamePage));
(wxCommandEventFunction) &MyFrame::OnOpenFileSamePage);
this->Connect(wxID_OPENURLNEWPAGE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_OPENURLNEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnOpenURLNewPage));
(wxCommandEventFunction) &MyFrame::OnOpenURLNewPage);
this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnOpenURLSamePage));
(wxCommandEventFunction) &MyFrame::OnOpenURLSamePage);
this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnCloseCurrentPage));
(wxCommandEventFunction) &MyFrame::OnCloseCurrentPage);
this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnPlay));
(wxCommandEventFunction) &MyFrame::OnPlay);
this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_PAUSE, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnPause));
(wxCommandEventFunction) &MyFrame::OnPause);
this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED, this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyFrame::OnStop));
(wxCommandEventFunction) &MyFrame::OnStop);
// //
// Notebook events // Notebook events
// //
this->Connect(wxID_NOTEBOOK, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, this->Connect(wxID_NOTEBOOK, wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
(wxObjectEventFunction) (wxEventFunction) wxNotebookEventHandler(MyFrame::OnPageChange));
(wxNotebookEventFunction) &MyFrame::OnPageChange);
// //
// End of Events // End of Events
@@ -646,6 +631,8 @@ void MyFrame::OpenFile(bool bNewPage)
{ {
if(bNewPage || !m_notebook->GetCurrentPage()) if(bNewPage || !m_notebook->GetCurrentPage())
m_notebook->AddPage(new MyNotebookPage(m_notebook), fd.GetPath(), true); m_notebook->AddPage(new MyNotebookPage(m_notebook), fd.GetPath(), true);
else //don't forget to update notebook page title
m_notebook->SetPageText(m_notebook->GetSelection(), fd.GetPath());
if( !GetCurrentMediaCtrl()->Load(fd.GetPath()) ) if( !GetCurrentMediaCtrl()->Load(fd.GetPath()) )
wxMessageBox(wxT("Couldn't load file!")); wxMessageBox(wxT("Couldn't load file!"));
@@ -657,7 +644,6 @@ void MyFrame::OpenFile(bool bNewPage)
GetCurrentSlider()->SetRange(0, GetCurrentSlider()->SetRange(0,
(int)(GetCurrentMediaCtrl()->Length() / 1000)); (int)(GetCurrentMediaCtrl()->Length() / 1000));
} }
} }
@@ -704,6 +690,8 @@ void MyFrame::OpenURL(bool bNewPage)
{ {
if(bNewPage || !m_notebook->GetCurrentPage()) if(bNewPage || !m_notebook->GetCurrentPage())
m_notebook->AddPage(new MyNotebookPage(m_notebook), theURL, true); m_notebook->AddPage(new MyNotebookPage(m_notebook), theURL, true);
else //don't forget to update notebook page title
m_notebook->SetPageText(m_notebook->GetSelection(), theURL);
if( !GetCurrentMediaCtrl()->Load(wxURI(theURL)) ) if( !GetCurrentMediaCtrl()->Load(wxURI(theURL)) )
wxMessageBox(wxT("Couldn't load URL!")); wxMessageBox(wxT("Couldn't load URL!"));
@@ -906,15 +894,13 @@ MyNotebookPage::MyNotebookPage(wxNotebook* theBook) :
// Slider events // Slider events
// //
this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED, this->Connect(wxID_SLIDER, wxEVT_COMMAND_SLIDER_UPDATED,
(wxObjectEventFunction) (wxEventFunction) wxCommandEventHandler(MyNotebookPage::OnSeek));
(wxCommandEventFunction) &MyNotebookPage::OnSeek);
// //
// Media Control events // Media Control events
// //
this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_FINISHED, this->Connect(wxID_MEDIACTRL, wxEVT_MEDIA_FINISHED,
(wxObjectEventFunction) (wxEventFunction) wxMediaEventHandler(MyNotebookPage::OnMediaFinished));
(wxMediaEventFunction) &MyNotebookPage::OnMediaFinished);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------