]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/mediaplayer/mediaplayer.cpp
fix vertical mouse wheel event rotation value, sign was reversed in r74805
[wxWidgets.git] / samples / mediaplayer / mediaplayer.cpp
index aeba330fc55c2be2cf8ff862c0e51975d344a215..640bb152c78fcc8a15d546dfb008e2b2fa552cdc 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Ryan Norton
 // Modified by:
 // Created:     11/10/04
-// RCS-ID:      $Id$
 // Copyright:   (c) Ryan Norton
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Headers
 // ----------------------------------------------------------------------------
 
-#include "wx/mediactrl.h"   //for wxMediaCtrl
-#include "wx/filedlg.h"     //for opening files from OpenFile
-#include "wx/slider.h"      //for a slider for seeking within media
-#include "wx/sizer.h"       //for positioning controls/wxBoxSizer
-#include "wx/timer.h"       //timer for updating status bar
-#include "wx/textdlg.h"     //for getting user text from OpenURL/Debug
-#include "wx/notebook.h"    //for wxNotebook and putting movies in pages
-#include "wx/cmdline.h"     //for wxCmdLineParser (optional)
-#include "wx/listctrl.h"    //for wxListCtrl
-#include "wx/dnd.h"         //drag and drop for the playlist
-#include "wx/filename.h"    //For wxFileName::GetName()
-#include "wx/config.h"      //for native wxConfig
+#include "wx/mediactrl.h"   // for wxMediaCtrl
+#include "wx/filedlg.h"     // for opening files from OpenFile
+#include "wx/slider.h"      // for a slider for seeking within media
+#include "wx/sizer.h"       // for positioning controls/wxBoxSizer
+#include "wx/timer.h"       // timer for updating status bar
+#include "wx/textdlg.h"     // for getting user text from OpenURL/Debug
+#include "wx/notebook.h"    // for wxNotebook and putting movies in pages
+#include "wx/cmdline.h"     // for wxCmdLineParser (optional)
+#include "wx/listctrl.h"    // for wxListCtrl
+#include "wx/dnd.h"         // drag and drop for the playlist
+#include "wx/filename.h"    // For wxFileName::GetName()
+#include "wx/config.h"      // for native wxConfig
+#include "wx/vector.h"
+
+// Under MSW we have several different backends but when linking statically
+// they may be discarded by the linker (this definitely happens with MSVC) so
+// force linking them. You don't have to do this in your code if you don't plan
+// to use them, of course.
+#if defined(__WXMSW__) && !defined(WXUSINGDLL)
+    #include "wx/link.h"
+    wxFORCE_LINK_MODULE(wxmediabackend_am)
+    wxFORCE_LINK_MODULE(wxmediabackend_qt)
+    wxFORCE_LINK_MODULE(wxmediabackend_wmp10)
+#endif // static wxMSW build
+
+#ifndef wxHAS_IMAGES_IN_RESOURCES
+    #include "../sample.xpm"
+#endif
 
 // ----------------------------------------------------------------------------
 // Bail out if the user doesn't want one of the
 // things we need
 // ----------------------------------------------------------------------------
 
-// RN:  I'm not sure why this is here - even minimal doesn't check for
-//      wxUSE_GUI.  I may have added it myself though...
-#if !wxUSE_GUI
-#error "This is a GUI sample"
-#endif
-
 #if !wxUSE_MEDIACTRL || !wxUSE_MENUS || !wxUSE_SLIDER || !wxUSE_TIMER || \
     !wxUSE_NOTEBOOK || !wxUSE_LISTCTRL
 #error "Not all required elements are enabled.  Please modify setup.h!"
@@ -134,9 +143,17 @@ class wxMediaPlayerApp : public wxApp
 {
 public:
 #ifdef __WXMAC__
-    virtual void MacOpenFile(const wxString & fileName );
+    virtual void MacOpenFiles(const wxArrayString & fileNames );
 #endif
 
+#if wxUSE_CMDLINE_PARSER
+    virtual void OnInitCmdLine(wxCmdLineParser& parser);
+    virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
+
+    // Files specified on the command line, if any.
+    wxVector<wxString> m_params;
+#endif // wxUSE_CMDLINE_PARSER
+
     virtual bool OnInit();
 
 protected:
@@ -199,8 +216,8 @@ private:
     void DoOpenFile(const wxString& path, bool bNewPage);
     void DoPlayFile(const wxString& path);
 
-    class wxMediaPlayerTimer* m_timer;     //Timer to write info to status bar
-    wxNotebook* m_notebook;     //Notebook containing our pages
+    class wxMediaPlayerTimer* m_timer;     // Timer to write info to status bar
+    wxNotebook* m_notebook;     // Notebook containing our pages
 
     // Maybe I should use more accessors, but for simplicity
     // I'll allow the other classes access to our members
@@ -233,30 +250,30 @@ class wxMediaPlayerNotebookPage : public wxPanel
     void OnMediaFinished(wxMediaEvent& event);
 
 public:
-    bool IsBeingDragged();      //accessor for m_bIsBeingDragged
+    bool IsBeingDragged();      // accessor for m_bIsBeingDragged
 
-    //make wxMediaPlayerFrame able to access the private members
+    // make wxMediaPlayerFrame able to access the private members
     friend class wxMediaPlayerFrame;
 
-    int      m_nLastFileId;     //List ID of played file in listctrl
-    wxString m_szFile;          //Name of currently playing file/location
-
-    wxMediaCtrl* m_mediactrl;   //Our media control
-    class wxMediaPlayerListCtrl* m_playlist;  //Our playlist
-    wxSlider* m_slider;         //The slider below our media control
-    wxSlider* m_pbSlider;       //Lower-left slider for adjusting speed
-    wxSlider* m_volSlider;      //Lower-right slider for adjusting volume
-    int m_nLoops;               //Number of times media has looped
-    bool m_bLoop;               //Whether we are looping or not
-    bool m_bIsBeingDragged;     //Whether the user is dragging the scroll bar
-    wxMediaPlayerFrame* m_parentFrame;  //Main wxFrame of our sample
-    wxButton* m_prevButton;     //Go to previous file button
-    wxButton* m_playButton;     //Play/pause file button
-    wxButton* m_stopButton;     //Stop playing file button
-    wxButton* m_nextButton;     //Next file button
-    wxButton* m_vdButton;       //Volume down button
-    wxButton* m_vuButton;       //Volume up button
-    wxGauge*  m_gauge;          //Gauge to keep in line with slider
+    int      m_nLastFileId;     // List ID of played file in listctrl
+    wxString m_szFile;          // Name of currently playing file/location
+
+    wxMediaCtrl* m_mediactrl;   // Our media control
+    class wxMediaPlayerListCtrl* m_playlist;  // Our playlist
+    wxSlider* m_slider;         // The slider below our media control
+    wxSlider* m_pbSlider;       // Lower-left slider for adjusting speed
+    wxSlider* m_volSlider;      // Lower-right slider for adjusting volume
+    int m_nLoops;               // Number of times media has looped
+    bool m_bLoop;               // Whether we are looping or not
+    bool m_bIsBeingDragged;     // Whether the user is dragging the scroll bar
+    wxMediaPlayerFrame* m_parentFrame;  // Main wxFrame of our sample
+    wxButton* m_prevButton;     // Go to previous file button
+    wxButton* m_playButton;     // Play/pause file button
+    wxButton* m_stopButton;     // Stop playing file button
+    wxButton* m_nextButton;     // Next file button
+    wxButton* m_vdButton;       // Volume down button
+    wxButton* m_vuButton;       // Volume up button
+    wxGauge*  m_gauge;          // Gauge to keep in line with slider
 };
 
 // ----------------------------------------------------------------------------
@@ -266,13 +283,13 @@ public:
 class wxMediaPlayerTimer : public wxTimer
 {
 public:
-    //Ctor
+    // Ctor
     wxMediaPlayerTimer(wxMediaPlayerFrame* frame) {m_frame = frame;}
 
-    //Called each time the timer's timeout expires
+    // Called each time the timer's timeout expires
     void Notify();
 
-    wxMediaPlayerFrame* m_frame;       //The wxMediaPlayerFrame
+    wxMediaPlayerFrame* m_frame;       // The wxMediaPlayerFrame
 };
 
 // ----------------------------------------------------------------------------
@@ -326,8 +343,8 @@ public:
 // ----------------------------------------------------------------------------
 // wxPlayListDropTarget
 //
-//  Drop target for playlist (i.e. user drags a file from explorer unto
-//  playlist it adds the file)
+//  Drop target for playlist (i.e. allows users to drag a file from explorer into
+//  the playlist to add that file)
 // ----------------------------------------------------------------------------
 #if wxUSE_DRAG_AND_DROP
 class wxPlayListDropTarget : public wxFileDropTarget
@@ -395,10 +412,38 @@ const wxChar* wxGetMediaStateText(int nState)
 //
 // IMPLEMENT_APP does this, and also implements the platform-specific entry
 // routine, such as main or WinMain().  Use IMPLEMENT_APP_NO_MAIN if you do
-// not desire this behavior.
+// not desire this behaviour.
 // ----------------------------------------------------------------------------
 IMPLEMENT_APP(wxMediaPlayerApp)
 
+// ----------------------------------------------------------------------------
+// wxMediaPlayerApp command line parsing
+// ----------------------------------------------------------------------------
+
+#if wxUSE_CMDLINE_PARSER
+
+void wxMediaPlayerApp::OnInitCmdLine(wxCmdLineParser& parser)
+{
+    wxApp::OnInitCmdLine(parser);
+
+    parser.AddParam("input files",
+                    wxCMD_LINE_VAL_STRING,
+                    wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE);
+}
+
+bool wxMediaPlayerApp::OnCmdLineParsed(wxCmdLineParser& parser)
+{
+    if ( !wxApp::OnCmdLineParsed(parser) )
+        return false;
+
+    for (size_t paramNr=0; paramNr < parser.GetParamCount(); ++paramNr)
+        m_params.push_back(parser.GetParam(paramNr));
+
+    return true;
+}
+
+#endif // wxUSE_CMDLINE_PARSER
+
 // ----------------------------------------------------------------------------
 // wxMediaPlayerApp::OnInit
 //
@@ -420,44 +465,25 @@ bool wxMediaPlayerApp::OnInit()
     frame->Show(true);
 
 #if wxUSE_CMDLINE_PARSER
-    //
-    //  What this does is get all the command line arguments
-    //  and treat each one as a file to put to the initial playlist
-    //
-    wxCmdLineEntryDesc cmdLineDesc[2];
-    cmdLineDesc[0].kind = wxCMD_LINE_PARAM;
-    cmdLineDesc[0].shortName = NULL;
-    cmdLineDesc[0].longName = NULL;
-    cmdLineDesc[0].description = "input files";
-    cmdLineDesc[0].type = wxCMD_LINE_VAL_STRING;
-    cmdLineDesc[0].flags = wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE;
-
-    cmdLineDesc[1].kind = wxCMD_LINE_NONE;
-
-    //gets the passed media files from cmd line
-    wxCmdLineParser parser (cmdLineDesc, argc, argv);
-
-    // get filenames from the commandline
-    if (parser.Parse() == 0)
+    if ( !m_params.empty() )
     {
-        for (size_t paramNr=0; paramNr < parser.GetParamCount(); ++paramNr)
-        {
-            frame->AddToPlayList((parser.GetParam (paramNr)));
-        }
-        wxCommandEvent theEvent(wxEVT_COMMAND_MENU_SELECTED, wxID_NEXT);
+        for ( size_t n = 0; n < m_params.size(); n++ )
+            frame->AddToPlayList(m_params[n]);
+
+        wxCommandEvent theEvent(wxEVT_MENU, wxID_NEXT);
         frame->AddPendingEvent(theEvent);
     }
-#endif
+#endif // wxUSE_CMDLINE_PARSER
 
     return true;
 }
 
 #ifdef __WXMAC__
 
-void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
+void wxMediaPlayerApp::MacOpenFiles(const wxArrayString & fileNames )
 {
-    //Called when a user drags a file over our app
-    m_frame->DoOpenFile(fileName, true /* new page */);
+    // Called when a user drags files over our app
+    m_frame->DoOpenFile(fileNames[0], true /* new page */);
 }
 
 #endif // __WXMAC__
@@ -481,6 +507,8 @@ void wxMediaPlayerApp::MacOpenFile(const wxString & fileName )
 wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
        : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,600))
 {
+    SetIcon(wxICON(sample));
+
     //
     //  Create Menus
     //
@@ -524,7 +552,7 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
                      wxT("Select a backend manually"));
 
     helpMenu->Append(wxID_ABOUT,
-                     wxT("&About...\tF1"),
+                     wxT("&About\tF1"),
                      wxT("Show about dialog"));
 
 
@@ -622,46 +650,46 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
     //
     // Menu events
     //
-    this->Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_EXIT, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnQuit));
 
-    this->Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_ABOUT, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnAbout));
 
-    this->Connect(wxID_LOOP, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_LOOP, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnLoop));
 
-    this->Connect(wxID_SHOWINTERFACE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_SHOWINTERFACE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnShowInterface));
 
-    this->Connect(wxID_OPENFILENEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_OPENFILENEWPAGE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnOpenFileNewPage));
 
-    this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_OPENFILESAMEPAGE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnOpenFileSamePage));
 
-    this->Connect(wxID_OPENURLNEWPAGE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_OPENURLNEWPAGE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnOpenURLNewPage));
 
-    this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_OPENURLSAMEPAGE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnOpenURLSamePage));
 
-    this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_CLOSECURRENTPAGE, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnCloseCurrentPage));
 
-    this->Connect(wxID_PLAY, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_PLAY, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnPlay));
 
-    this->Connect(wxID_STOP, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_STOP, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnStop));
 
-    this->Connect(wxID_NEXT, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_NEXT, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnNext));
 
-    this->Connect(wxID_PREV, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_PREV, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnPrev));
 
-    this->Connect(wxID_SELECTBACKEND, wxEVT_COMMAND_MENU_SELECTED,
+    this->Connect(wxID_SELECTBACKEND, wxEVT_MENU,
                   wxCommandEventHandler(wxMediaPlayerFrame::OnSelectBackend));
 
     //
@@ -685,30 +713,40 @@ wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
     //  Create an initial notebook page so the user has something
     //  to work with without having to go file->open every time :).
     //
-    wxMediaPlayerNotebookPage* page = 
+    wxMediaPlayerNotebookPage* page =
         new wxMediaPlayerNotebookPage(this, m_notebook);
     m_notebook->AddPage(page,
                         wxT(""),
                         true);
 
-    //
-    //  Here we load the our configuration -
-    //  in our case we load all the files that were left in
-    //  the playlist the last time the user closed our application
-    //
-    //  As an exercise to the reader try modifying it so that
-    //  it properly loads the playlist for each page without
-    //  conflicting (loading the same data) with the other ones.
-    //
-    wxConfig conf;
-    wxString key, outstring;
-    for(int i = 0; ; ++i)
+
+    // Don't load previous files if we have some specified on the command line,
+    // we wouldn't play them otherwise (they'd have to be inserted into the
+    // play list at the beginning instead of being appended but we don't
+    // support this).
+#if wxUSE_CMDLINE_PARSER
+    if ( wxGetApp().m_params.empty() )
+#endif // wxUSE_CMDLINE_PARSER
     {
-        key.clear();
-        key << i;
-        if(!conf.Read(key, &outstring))
-            break;
-        page->m_playlist->AddToPlayList(outstring);
+        //
+        //  Here we load the our configuration -
+        //  in our case we load all the files that were left in
+        //  the playlist the last time the user closed our application
+        //
+        //  As an exercise to the reader try modifying it so that
+        //  it properly loads the playlist for each page without
+        //  conflicting (loading the same data) with the other ones.
+        //
+        wxConfig conf;
+        wxString key, outstring;
+        for(int i = 0; ; ++i)
+        {
+            key.clear();
+            key << i;
+            if(!conf.Read(key, &outstring))
+                break;
+            page->m_playlist->AddToPlayList(outstring);
+        }
     }
 
     //
@@ -770,7 +808,7 @@ wxMediaPlayerFrame::~wxMediaPlayerFrame()
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnClose(wxCloseEvent& event)
 {
-    event.Skip(); //really close the frame
+    event.Skip(); // really close the frame
 }
 
 // ----------------------------------------------------------------------------
@@ -807,14 +845,14 @@ void wxMediaPlayerFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
     wxString msg;
     msg.Printf( wxT("This is a test of wxMediaCtrl.\n\n")
 
-                wxT("Intructions:\n")
+                wxT("Instructions:\n")
 
                 wxT("The top slider shows the current the current position, ")
                 wxT("which you can change by dragging and releasing it.\n")
 
                 wxT("The gauge (progress bar) shows the progress in ")
                 wxT("downloading data of the current file - it may always be ")
-                wxT("Empty due to lack of support from the current backend.\n")
+                wxT("empty due to lack of support from the current backend.\n")
 
                 wxT("The lower-left slider controls the volume and the lower-")
                 wxT("right slider controls the playback rate/speed of the ")
@@ -855,11 +893,11 @@ void wxMediaPlayerFrame::OnShowInterface(wxCommandEvent& event)
             wxMEDIACTRLPLAYERCONTROLS_DEFAULT :
              wxMEDIACTRLPLAYERCONTROLS_NONE)    )
     {
-        //error - uncheck and warn user
+        // error - uncheck and warn user
         wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE);
         wxASSERT(pSIItem);
         pSIItem->Check(!event.IsChecked());
-        
+
         if(event.IsChecked())
             wxMessageBox(wxT("Could not show player controls"));
         else
@@ -921,11 +959,11 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage)
             true);
     }
 
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     if(currentpage->m_nLastFileId != -1)
-        currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId, 
+        currentpage->m_playlist->SetItemState(currentpage->m_nLastFileId,
                                               0, wxLIST_STATE_SELECTED);
 
     wxListItem newlistitem;
@@ -959,7 +997,7 @@ void wxMediaPlayerFrame::DoOpenFile(const wxString& path, bool bNewPage)
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     wxListItem listitem;
@@ -974,7 +1012,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
       )
     {
         if(currentpage->m_mediactrl->GetState() == wxMEDIASTATE_PLAYING)
-    {
+        {
             if( !currentpage->m_mediactrl->Pause() )
                 wxMessageBox(wxT("Couldn't pause movie!"));
         }
@@ -986,7 +1024,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
     }
     else
     {
-        int nNewId = listitem.GetData() ? listitem.GetId() : 
+        int nNewId = listitem.GetData() ? listitem.GetId() :
                             currentpage->m_playlist->GetItemCount()-1;
         m_notebook->SetPageText(m_notebook->GetSelection(),
                                 wxFileName(path).GetName());
@@ -1023,9 +1061,9 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
 
         currentpage->m_nLastFileId = nNewId;
         currentpage->m_szFile = path;
-        currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, 
+        currentpage->m_playlist->SetItem(currentpage->m_nLastFileId,
                                          1, wxFileName(path).GetName());
-        currentpage->m_playlist->SetItem(currentpage->m_nLastFileId, 
+        currentpage->m_playlist->SetItem(currentpage->m_nLastFileId,
                                          2, wxT(""));
     }
 }
@@ -1038,7 +1076,7 @@ void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnMediaLoaded(wxMediaEvent& WXUNUSED(evt))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     if( !currentpage->m_mediactrl->Play() )
@@ -1065,7 +1103,7 @@ void wxMediaPlayerFrame::OnSelectBackend(wxCommandEvent& WXUNUSED(evt))
 {
     wxString sBackend = wxGetTextFromUser(wxT("Enter backend to use"));
 
-    if(sBackend.empty() == false)  //could have been cancelled by the user
+    if(sBackend.empty() == false)  // could have been cancelled by the user
     {
         int sel = m_notebook->GetSelection();
 
@@ -1079,7 +1117,7 @@ void wxMediaPlayerFrame::OnSelectBackend(wxCommandEvent& WXUNUSED(evt))
                                                         ), wxT(""), true);
 
         DoOpenFile(
-            ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile, 
+            ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile,
             false);
     }
 }
@@ -1118,7 +1156,7 @@ void wxMediaPlayerFrame::OpenURL(bool bNewPage)
         wxT("Enter the URL that has the movie to play")
                                      );
 
-    if(sUrl.empty() == false) //could have been cancelled by user
+    if(sUrl.empty() == false) // could have been cancelled by user
     {
         DoOpenFile(sUrl, bNewPage);
     }
@@ -1158,7 +1196,7 @@ void wxMediaPlayerFrame::OnCloseCurrentPage(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     wxListItem listitem;
@@ -1170,7 +1208,7 @@ void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
                                          wxLIST_NEXT_ALL,
                                          wxLIST_STATE_DONTCARE)) == -1)
         {
-            //no items in list
+            // no items in list
             wxMessageBox(wxT("No items in playlist!"));
     }
         else
@@ -1181,7 +1219,7 @@ void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
         listitem.SetState(listitem.GetState() | wxLIST_STATE_SELECTED);
             currentpage->m_playlist->SetItem(listitem);
             wxASSERT(listitem.GetData());
-            DoPlayFile((*((wxString*) listitem.GetData())));            
+            DoPlayFile((*((wxString*) listitem.GetData())));
     }
     }
     else
@@ -1200,9 +1238,9 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event)
 {
    if(event.GetKeyCode() == WXK_BACK/*DELETE*/)
     {
-        wxMediaPlayerNotebookPage* currentpage = 
+        wxMediaPlayerNotebookPage* currentpage =
             (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
-       //delete all selected items
+       // delete all selected items
        while(true)
        {
            wxInt32 nSelectedItem = currentpage->m_playlist->GetNextItem(
@@ -1219,7 +1257,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event)
        }
     }
 
-   //Could be wxGetTextFromUser or something else important
+   // Could be wxGetTextFromUser or something else important
    if(event.GetEventObject() != this)
        event.Skip();
 }
@@ -1235,7 +1273,7 @@ void wxMediaPlayerFrame::OnKeyDown(wxKeyEvent& event)
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     if( !currentpage->m_mediactrl->Stop() )
@@ -1255,13 +1293,13 @@ void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     wxListItem listitem;
     currentpage->m_playlist->GetSelectedItem(listitem);
     if(listitem.GetData())
-    DoPlayFile((*((wxString*) listitem.GetData())));
+        DoPlayFile((*((wxString*) listitem.GetData())));
     else
         wxMessageBox(wxT("No selected item!"));
 }
@@ -1274,7 +1312,7 @@ void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     if (currentpage->m_playlist->GetItemCount() == 0)
@@ -1291,21 +1329,21 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
         currentpage->m_playlist->SetItemState(nSelectedItem, 0, wxLIST_STATE_SELECTED);
     }
 
-    if (nLastSelectedItem == -1) 
+    if (nLastSelectedItem == -1)
     {
-        //nothing selected, default to the file before the currently playing one
+        // nothing selected, default to the file before the currently playing one
         if(currentpage->m_nLastFileId == 0)
             nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1;
     else
             nLastSelectedItem = currentpage->m_nLastFileId - 1;
     }
-    else if (nLastSelectedItem == 0) 
+    else if (nLastSelectedItem == 0)
         nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1;
     else
         nLastSelectedItem -= 1;
 
     if(nLastSelectedItem == currentpage->m_nLastFileId)
-        return; //already playing... nothing to do
+        return; // already playing... nothing to do
 
     wxListItem listitem;
     listitem.SetId(nLastSelectedItem);
@@ -1327,7 +1365,7 @@ void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     if (currentpage->m_playlist->GetItemCount() == 0)
@@ -1349,7 +1387,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
         if(currentpage->m_nLastFileId == currentpage->m_playlist->GetItemCount() - 1)
         nLastSelectedItem = 0;
     else
-            nLastSelectedItem = currentpage->m_nLastFileId + 1;                
+            nLastSelectedItem = currentpage->m_nLastFileId + 1;
     }
     else if (nLastSelectedItem == currentpage->m_playlist->GetItemCount() - 1)
             nLastSelectedItem = 0;
@@ -1357,7 +1395,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
             nLastSelectedItem += 1;
 
     if(nLastSelectedItem == currentpage->m_nLastFileId)
-        return; //already playing... nothing to do
+        return; // already playing... nothing to do
 
     wxListItem listitem;
     listitem.SetMask(wxLIST_MASK_TEXT |  wxLIST_MASK_DATA);
@@ -1379,7 +1417,7 @@ void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     double dVolume = currentpage->m_mediactrl->GetVolume();
@@ -1393,7 +1431,7 @@ void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event))
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
 
     double dVolume = currentpage->m_mediactrl->GetVolume();
@@ -1419,82 +1457,79 @@ void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event))
 // ----------------------------------------------------------------------------
 void wxMediaPlayerTimer::Notify()
 {
-    wxMediaPlayerNotebookPage* currentpage = 
+    wxMediaPlayerNotebookPage* currentpage =
         (wxMediaPlayerNotebookPage*) m_frame->m_notebook->GetCurrentPage();
     wxMediaCtrl* currentMediaCtrl = currentpage->m_mediactrl;
 
-    if(currentpage)
-    {
-        // Number of minutes/seconds total
-        wxLongLong llLength = currentpage->m_mediactrl->Length();
-        int nMinutes = (int) (llLength / 60000).GetValue();
-        int nSeconds = (int) ((llLength % 60000)/1000).GetValue();
+    // Number of minutes/seconds total
+    wxLongLong llLength = currentpage->m_mediactrl->Length();
+    int nMinutes = (int) (llLength / 60000).GetValue();
+    int nSeconds = (int) ((llLength % 60000)/1000).GetValue();
 
-        // Duration string (i.e. MM:SS)
-        wxString sDuration;
-        sDuration.Printf(wxT("%2i:%02i"), nMinutes, nSeconds);
+    // Duration string (i.e. MM:SS)
+    wxString sDuration;
+    sDuration.Printf(wxT("%2i:%02i"), nMinutes, nSeconds);
 
 
-        // Number of minutes/seconds total
-        wxLongLong llTell = currentpage->m_mediactrl->Tell();
-        nMinutes = (int) (llTell / 60000).GetValue();
-        nSeconds = (int) ((llTell % 60000)/1000).GetValue();
+    // Number of minutes/seconds total
+    wxLongLong llTell = currentpage->m_mediactrl->Tell();
+    nMinutes = (int) (llTell / 60000).GetValue();
+    nSeconds = (int) ((llTell % 60000)/1000).GetValue();
 
-        // Position string (i.e. MM:SS)
-        wxString sPosition;
-        sPosition.Printf(wxT("%2i:%02i"), nMinutes, nSeconds);
+    // Position string (i.e. MM:SS)
+    wxString sPosition;
+    sPosition.Printf(wxT("%2i:%02i"), nMinutes, nSeconds);
 
 
-        // Set the third item in the listctrl entry to the duration string
-        if(currentpage->m_nLastFileId >= 0)
-            currentpage->m_playlist->SetItem(
-                    currentpage->m_nLastFileId, 2, sDuration);
+    // Set the third item in the listctrl entry to the duration string
+    if(currentpage->m_nLastFileId >= 0)
+        currentpage->m_playlist->SetItem(
+                currentpage->m_nLastFileId, 2, sDuration);
 
-        // Setup the slider and gauge min/max values
-        currentpage->m_slider->SetRange(0, (int)(llLength / 1000).GetValue());
-        currentpage->m_gauge->SetRange(100);
+    // Setup the slider and gauge min/max values
+    currentpage->m_slider->SetRange(0, (int)(llLength / 1000).GetValue());
+    currentpage->m_gauge->SetRange(100);
 
 
-        // if the slider is not being dragged then update it with the song position
-        if(currentpage->IsBeingDragged() == false)
-            currentpage->m_slider->SetValue((long)(llTell / 1000).GetValue());
+    // if the slider is not being dragged then update it with the song position
+    if(currentpage->IsBeingDragged() == false)
+        currentpage->m_slider->SetValue((long)(llTell / 1000).GetValue());
 
 
-        // Update the gauge with the download progress
-        wxLongLong llDownloadProgress =
-            currentpage->m_mediactrl->GetDownloadProgress();
-        wxLongLong llDownloadTotal =
-            currentpage->m_mediactrl->GetDownloadTotal();
+    // Update the gauge with the download progress
+    wxLongLong llDownloadProgress =
+        currentpage->m_mediactrl->GetDownloadProgress();
+    wxLongLong llDownloadTotal =
+        currentpage->m_mediactrl->GetDownloadTotal();
 
-        if(llDownloadTotal.GetValue() != 0)
-        {
-            currentpage->m_gauge->SetValue(
-                (int) ((llDownloadProgress * 100) / llDownloadTotal).GetValue()
-                                          );
-        }
+    if(llDownloadTotal.GetValue() != 0)
+    {
+        currentpage->m_gauge->SetValue(
+            (int) ((llDownloadProgress * 100) / llDownloadTotal).GetValue()
+                                      );
+    }
 
-        // GetBestSize holds the original video size
-        wxSize videoSize = currentMediaCtrl->GetBestSize();
+    // GetBestSize holds the original video size
+    wxSize videoSize = currentMediaCtrl->GetBestSize();
 
-        // Now the big part - set the status bar text to
-        // hold various metadata about the media
+    // Now the big part - set the status bar text to
+    // hold various metadata about the media
 #if wxUSE_STATUSBAR
-        m_frame->SetStatusText(wxString::Format(
-                        wxT("Size(x,y):%i,%i ")
-                        wxT("Position:%s/%s Speed:%1.1fx ")
-                        wxT("State:%s Loops:%i D/T:[%i]/[%i] V:%i%%"),
-                        videoSize.x,
-                        videoSize.y,
-                        sPosition.c_str(),
-                        sDuration.c_str(),
-                        currentMediaCtrl->GetPlaybackRate(),
-                        wxGetMediaStateText(currentpage->m_mediactrl->GetState()),
-                        currentpage->m_nLoops,
-                        (int)llDownloadProgress.GetValue(),
-                        (int)llDownloadTotal.GetValue(),
-                        (int)(currentpage->m_mediactrl->GetVolume() * 100)));
+    m_frame->SetStatusText(wxString::Format(
+                    wxT("Size(x,y):%i,%i ")
+                    wxT("Position:%s/%s Speed:%1.1fx ")
+                    wxT("State:%s Loops:%i D/T:[%i]/[%i] V:%i%%"),
+                    videoSize.x,
+                    videoSize.y,
+                    sPosition.c_str(),
+                    sDuration.c_str(),
+                    currentMediaCtrl->GetPlaybackRate(),
+                    wxGetMediaStateText(currentpage->m_mediactrl->GetState()),
+                    currentpage->m_nLoops,
+                    (int)llDownloadProgress.GetValue(),
+                    (int)llDownloadTotal.GetValue(),
+                    (int)(currentpage->m_mediactrl->GetVolume() * 100)));
 #endif // wxUSE_STATUSBAR
-    }
 }
 
 // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -1530,13 +1565,11 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //
 
     //
-    //  Create and attach the sizer
+    //  Create and attach a 2-column grid sizer
     //
-    wxFlexGridSizer* sizer = new wxFlexGridSizer(2, 1, 0, 0);
-    this->SetSizer(sizer);
-    this->SetAutoLayout(true);
-    sizer->AddGrowableRow(0);
+    wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
     sizer->AddGrowableCol(0);
+    this->SetSizer(sizer);
 
     //
     //  Create our media control
@@ -1546,14 +1579,14 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //  Make sure creation was successful
     bool bOK = m_mediactrl->Create(this, wxID_MEDIACTRL, wxEmptyString,
                                     wxDefaultPosition, wxDefaultSize, 0,
-//you could specify a macrod backend here like
+// you could specify a macro backend here like
 //  wxMEDIABACKEND_WMP10);
 //        wxT("wxPDFMediaBackend"));
                                    szBackend);
-//you could change the cursor here like
+// you could change the cursor here like
 //    m_mediactrl->SetCursor(wxCURSOR_BLANK);
-//note that this may not effect it if SetPlayerControls
-//is set to something else than wxMEDIACTRLPLAYERCONTROLS_NONE
+// note that this may not effect it if SetPlayerControls
+// is set to something else than wxMEDIACTRLPLAYERCONTROLS_NONE
     wxASSERT_MSG(bOK, wxT("Could not create media control!"));
     wxUnusedVar(bOK);
 
@@ -1565,11 +1598,11 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     m_playlist = new wxMediaPlayerListCtrl();
     m_playlist->Create(this, wxID_LISTCTRL, wxDefaultPosition,
                     wxDefaultSize,
-                    wxLC_REPORT //wxLC_LIST
+                    wxLC_REPORT // wxLC_LIST
                     | wxSUNKEN_BORDER);
 
     //  Set the background of our listctrl to white
-    m_playlist->SetBackgroundColour(wxColour(255,255,255));
+    m_playlist->SetBackgroundColour(*wxWHITE);
 
     //  The layout of the headers of the listctrl are like
     //  |   | File               |  Length
@@ -1586,9 +1619,9 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //  Column two is the name of the file
     //
     //  Column three is the length in seconds of the file
-    m_playlist->InsertColumn(0,_(""), wxLIST_FORMAT_CENTER, 20);
-    m_playlist->InsertColumn(1,_("File"), wxLIST_FORMAT_LEFT, /*wxLIST_AUTOSIZE_USEHEADER*/305);
-    m_playlist->InsertColumn(2,_("Length"), wxLIST_FORMAT_CENTER, 75);
+    m_playlist->AppendColumn(_(""), wxLIST_FORMAT_CENTER, 20);
+    m_playlist->AppendColumn(_("File"), wxLIST_FORMAT_LEFT, /*wxLIST_AUTOSIZE_USEHEADER*/305);
+    m_playlist->AppendColumn(_("Length"), wxLIST_FORMAT_CENTER, 75);
 
 #if wxUSE_DRAG_AND_DROP
     m_playlist->SetDropTarget(new wxPlayListDropTarget(*m_playlist));
@@ -1612,11 +1645,18 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     m_vuButton = new wxButton();
 
     m_prevButton->Create(this, wxID_BUTTONPREV, wxT("|<"));
+    m_prevButton->SetToolTip("Previous");
     m_playButton->Create(this, wxID_BUTTONPLAY, wxT(">"));
+    m_playButton->SetToolTip("Play");
     m_stopButton->Create(this, wxID_BUTTONSTOP, wxT("[]"));
+    m_stopButton->SetToolTip("Stop");
     m_nextButton->Create(this, wxID_BUTTONNEXT, wxT(">|"));
+    m_nextButton->SetToolTip("Next");
     m_vdButton->Create(this, wxID_BUTTONVD, wxT("(("));
+    m_vdButton->SetToolTip("Volume down");
     m_vuButton->Create(this, wxID_BUTTONVU, wxT("))"));
+    m_vuButton->SetToolTip("Volume up");
+
     vertsizer->Add(m_prevButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
     vertsizer->Add(m_playButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
     vertsizer->Add(m_stopButton, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
@@ -1630,9 +1670,9 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //
     //  Create our slider
     //
-    m_slider = new wxSlider(this, wxID_SLIDER, 0, //init
-                            0, //start
-                            0, //end
+    m_slider = new wxSlider(this, wxID_SLIDER, 0, // init
+                            0, // start
+                            1, // end, dummy but must be greater than start
                             wxDefaultPosition, wxDefaultSize,
                             wxSL_HORIZONTAL );
     sizer->Add(m_slider, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);
@@ -1645,6 +1685,7 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
                         wxGA_HORIZONTAL | wxGA_SMOOTH);
     sizer->Add(m_gauge, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);
 
+
     //
     //  Create the speed/volume sliders
     //
@@ -1665,10 +1706,13 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     horsizer3->Add(m_pbSlider, 1, wxALL, 5);
     sizer->Add(horsizer3, 1, wxCENTRE | wxALL, 5);
 
+    // Now that we have all our rows make some of them growable
+    sizer->AddGrowableRow(0);
+
     //
     // ListCtrl events
     //
-    this->Connect( wxID_LISTCTRL, wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
+    this->Connect( wxID_LISTCTRL, wxEVT_LIST_ITEM_ACTIVATED,
         wxListEventHandler(wxMediaPlayerFrame::OnChangeSong),
         (wxObject*)0, parentFrame);
 
@@ -1702,22 +1746,22 @@ wxMediaPlayerNotebookPage::wxMediaPlayerNotebookPage(wxMediaPlayerFrame* parentF
     //
     // Button events
     //
-    this->Connect( wxID_BUTTONPREV, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONPREV, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnPrev),
         (wxObject*)0, parentFrame);
-    this->Connect( wxID_BUTTONPLAY, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONPLAY, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnPlay),
         (wxObject*)0, parentFrame);
-    this->Connect( wxID_BUTTONSTOP, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONSTOP, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnStop),
         (wxObject*)0, parentFrame);
-    this->Connect( wxID_BUTTONNEXT, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONNEXT, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnNext),
         (wxObject*)0, parentFrame);
-    this->Connect( wxID_BUTTONVD, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONVD, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnVolumeDown),
         (wxObject*)0, parentFrame);
-    this->Connect( wxID_BUTTONVU, wxEVT_COMMAND_BUTTON_CLICKED,
+    this->Connect( wxID_BUTTONVU, wxEVT_BUTTON,
         wxCommandEventHandler(wxMediaPlayerFrame::OnVolumeUp),
         (wxObject*)0, parentFrame);
 }