#include "wx/filename.h" //For wxFileName::GetName()
#include "wx/config.h" //for native wxConfig
+#ifndef __WXMSW__
+ #include "../sample.xpm"
+#endif
+
// ----------------------------------------------------------------------------
// Bail out if the user doesn't want one of the
// things we need
wxMediaPlayerFrame::wxMediaPlayerFrame(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(600,600))
{
+ SetIcon(wxICON(sample));
+
//
// Create Menus
//
// 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(""),
wxMenuItem* pSIItem = GetMenuBar()->FindItem(wxID_SHOWINTERFACE);
wxASSERT(pSIItem);
pSIItem->Check(!event.IsChecked());
-
+
if(event.IsChecked())
wxMessageBox(wxT("Could not show player controls"));
else
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;
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::DoPlayFile(const wxString& path)
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem;
}
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());
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(""));
}
}
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnMediaLoaded(wxMediaEvent& WXUNUSED(evt))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if( !currentpage->m_mediactrl->Play() )
), wxT(""), true);
DoOpenFile(
- ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile,
+ ((wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage())->m_szFile,
false);
}
}
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem;
listitem.SetState(listitem.GetState() | wxLIST_STATE_SELECTED);
currentpage->m_playlist->SetItem(listitem);
wxASSERT(listitem.GetData());
- DoPlayFile((*((wxString*) listitem.GetData())));
+ DoPlayFile((*((wxString*) listitem.GetData())));
}
}
else
{
if(event.GetKeyCode() == WXK_BACK/*DELETE*/)
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
//delete all selected items
while(true)
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnStop(wxCommandEvent& WXUNUSED(evt))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if( !currentpage->m_mediactrl->Stop() )
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnChangeSong(wxListEvent& WXUNUSED(evt))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
wxListItem listitem;
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnPrev(wxCommandEvent& WXUNUSED(event))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if (currentpage->m_playlist->GetItemCount() == 0)
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
if(currentpage->m_nLastFileId == 0)
else
nLastSelectedItem = currentpage->m_nLastFileId - 1;
}
- else if (nLastSelectedItem == 0)
+ else if (nLastSelectedItem == 0)
nLastSelectedItem = currentpage->m_playlist->GetItemCount() - 1;
else
nLastSelectedItem -= 1;
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnNext(wxCommandEvent& WXUNUSED(event))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
if (currentpage->m_playlist->GetItemCount() == 0)
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;
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnVolumeDown(wxCommandEvent& WXUNUSED(event))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
double dVolume = currentpage->m_mediactrl->GetVolume();
// ----------------------------------------------------------------------------
void wxMediaPlayerFrame::OnVolumeUp(wxCommandEvent& WXUNUSED(event))
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_notebook->GetCurrentPage();
double dVolume = currentpage->m_mediactrl->GetVolume();
// ----------------------------------------------------------------------------
void wxMediaPlayerTimer::Notify()
{
- wxMediaPlayerNotebookPage* currentpage =
+ wxMediaPlayerNotebookPage* currentpage =
(wxMediaPlayerNotebookPage*) m_frame->m_notebook->GetCurrentPage();
wxMediaCtrl* currentMediaCtrl = currentpage->m_mediactrl;
//
//
- // Create and attach the sizer
+ // Create and attach a 2-column grid sizer
//
- wxFlexGridSizer* sizer = new wxFlexGridSizer(2, 1, 0, 0);
- this->SetSizer(sizer);
- sizer->AddGrowableRow(0);
+ wxFlexGridSizer* sizer = new wxFlexGridSizer(2);
sizer->AddGrowableCol(0);
+ this->SetSizer(sizer);
//
// Create our media control
wxGA_HORIZONTAL | wxGA_SMOOTH);
sizer->Add(m_gauge, 0, wxALIGN_CENTER_HORIZONTAL|wxALL|wxEXPAND , 5);
+
//
// Create the speed/volume sliders
//
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
//