2000-03-05 14:03:21 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: mmboard.cpp
|
|
|
|
// Purpose: Multimedia Library sample
|
|
|
|
// Author: Guilhem Lavaux (created from minimal by J. Smart)
|
|
|
|
// Modified by:
|
|
|
|
// Created: 13/02/2000
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation "mmboard.cpp"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For compilers that support precompilation, includes "wx/wx.h".
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// for all others, include the necessary headers (this file is usually all you
|
2004-05-25 07:20:37 -04:00
|
|
|
// need because it includes almost all "standard" wxWidgets headers
|
2000-03-05 14:03:21 -05:00
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// ressources
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the application icon
|
2002-03-21 05:32:18 -05:00
|
|
|
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
|
2000-03-05 14:03:21 -05:00
|
|
|
#include "mondrian.xpm"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// include multimedia classes
|
|
|
|
#include "wx/mmedia/sndbase.h"
|
|
|
|
#ifdef __WIN32__
|
|
|
|
#include "wx/mmedia/sndwin.h"
|
|
|
|
#endif
|
|
|
|
#ifdef __UNIX__
|
|
|
|
#include "wx/mmedia/sndoss.h"
|
|
|
|
#include "wx/mmedia/sndesd.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/statline.h"
|
|
|
|
#include "wx/stattext.h"
|
|
|
|
|
|
|
|
// include personnal classes
|
|
|
|
#include "mmboard.h"
|
|
|
|
#include "mmbman.h"
|
|
|
|
|
|
|
|
#include "play.xpm"
|
|
|
|
#include "stop.xpm"
|
|
|
|
#include "eject.xpm"
|
|
|
|
#include "pause.xpm"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// private classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// Main Multimedia Board frame
|
|
|
|
class MMBoardFrame : public wxFrame
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// ctor(s)
|
|
|
|
MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
|
|
|
// dtor
|
|
|
|
~MMBoardFrame();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// event handlers
|
|
|
|
void OnQuit(wxCommandEvent& event);
|
|
|
|
void OnAbout(wxCommandEvent& event);
|
|
|
|
void OnOpen(wxCommandEvent& event);
|
|
|
|
void OnPlay(wxCommandEvent& event);
|
|
|
|
void OnStop(wxCommandEvent& event);
|
|
|
|
void OnPause(wxCommandEvent& event);
|
|
|
|
void OnEject(wxCommandEvent& event);
|
|
|
|
void OnRefreshInfo(wxEvent& event);
|
|
|
|
void OnSetPosition(wxCommandEvent& event);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
void OpenVideoWindow();
|
|
|
|
void CloseVideoWindow();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
private:
|
2004-05-25 07:20:37 -04:00
|
|
|
// any class wishing to process wxWidgets events must use this macro
|
2000-03-05 14:03:21 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
|
|
|
|
private:
|
2004-06-12 19:44:08 -04:00
|
|
|
void UpdateMMedInfo();
|
2000-03-05 14:03:21 -05:00
|
|
|
void UpdateInfoText();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
MMBoardFile *m_opened_file;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
wxSlider *m_positionSlider;
|
|
|
|
wxBitmapButton *m_playButton, *m_pauseButton, *m_stopButton, *m_ejectButton;
|
|
|
|
wxStaticText *m_fileType, *m_infoText;
|
|
|
|
wxWindow *m_video_window;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
wxPanel *m_panel;
|
|
|
|
wxSizer *m_sizer;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
wxTimer *m_refreshTimer;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// constants
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// IDs for the controls and the menu commands
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
// menu items
|
|
|
|
MMBoard_Quit = 1,
|
|
|
|
MMBoard_Open,
|
|
|
|
MMBoard_About,
|
|
|
|
MMBoard_PositionSlider,
|
|
|
|
MMBoard_PlayButton,
|
|
|
|
MMBoard_PauseButton,
|
|
|
|
MMBoard_ResumeButton,
|
|
|
|
MMBoard_StopButton,
|
|
|
|
MMBoard_EjectButton,
|
|
|
|
MMBoard_RefreshInfo
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2004-05-25 07:20:37 -04:00
|
|
|
// event tables and other macros for wxWidgets
|
2000-03-05 14:03:21 -05:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(MMBoardFrame, wxFrame)
|
|
|
|
EVT_MENU(MMBoard_Quit, MMBoardFrame::OnQuit)
|
|
|
|
EVT_MENU(MMBoard_About, MMBoardFrame::OnAbout)
|
|
|
|
EVT_MENU(MMBoard_Open, MMBoardFrame::OnOpen)
|
|
|
|
EVT_BUTTON(MMBoard_PlayButton, MMBoardFrame::OnPlay)
|
|
|
|
EVT_BUTTON(MMBoard_StopButton, MMBoardFrame::OnStop)
|
|
|
|
EVT_BUTTON(MMBoard_PauseButton, MMBoardFrame::OnPause)
|
2004-06-12 19:44:08 -04:00
|
|
|
EVT_BUTTON(MMBoard_EjectButton, MMBoardFrame::OnEject)
|
2000-03-05 14:03:21 -05:00
|
|
|
EVT_SLIDER(MMBoard_PositionSlider, MMBoardFrame::OnSetPosition)
|
|
|
|
EVT_CUSTOM(wxEVT_TIMER, MMBoard_RefreshInfo, MMBoardFrame::OnRefreshInfo)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
// Main board application launcher
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
IMPLEMENT_APP(MMBoardApp)
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the application class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool MMBoardApp::OnInit()
|
|
|
|
{
|
|
|
|
// create the main application window
|
2003-09-11 05:55:21 -04:00
|
|
|
MMBoardFrame *frame = new MMBoardFrame(_T("Multimedia Board"),
|
2000-03-05 14:03:21 -05:00
|
|
|
wxPoint(50, 50), wxSize(450, 340));
|
|
|
|
|
|
|
|
// and show it (the frames, unlike simple controls, are not shown when
|
|
|
|
// created initially)
|
2004-06-12 19:44:08 -04:00
|
|
|
frame->Show();
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
m_caps = TestMultimediaCaps();
|
|
|
|
|
|
|
|
if (!m_caps) {
|
2003-09-11 05:55:21 -04:00
|
|
|
wxMessageBox(_T("Your system has no multimedia capabilities. We are exiting now."), _T("Major error !"), wxOK | wxICON_ERROR, NULL);
|
2004-06-12 19:44:08 -04:00
|
|
|
return false;
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
wxString msg;
|
2003-09-11 05:55:21 -04:00
|
|
|
msg.Printf(_T("Detected : %s%s%s"), (m_caps & MM_SOUND_OSS) ? _T("OSS ") : _T(""),
|
2004-06-12 19:44:08 -04:00
|
|
|
(m_caps & MM_SOUND_ESD) ? _T("ESD ") : _T(""),
|
|
|
|
(m_caps & MM_SOUND_WIN) ? _T("WIN") : _T(""));
|
2000-03-05 14:03:21 -05:00
|
|
|
|
2003-09-11 05:55:21 -04:00
|
|
|
wxMessageBox(msg, _T("Good !"), wxOK | wxICON_INFORMATION, NULL);
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
// success: wxApp::OnRun() will be called which will enter the main message
|
2004-06-12 19:44:08 -04:00
|
|
|
// loop and the application will run. If we returned false here, the
|
2000-03-05 14:03:21 -05:00
|
|
|
// application would exit immediately.
|
2004-06-12 19:44:08 -04:00
|
|
|
return true;
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
wxUint8 MMBoardApp::TestMultimediaCaps()
|
|
|
|
{
|
|
|
|
wxSoundStream *dev;
|
|
|
|
wxUint8 caps;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
caps = 0;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
#ifdef __UNIX__
|
|
|
|
// We now test the ESD support
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
dev = new wxSoundStreamESD();
|
2004-06-12 19:44:08 -04:00
|
|
|
if (dev->GetError() == wxSOUND_NOERROR)
|
2000-03-05 14:03:21 -05:00
|
|
|
caps |= MM_SOUND_ESD;
|
|
|
|
delete dev;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// We test the OSS (Open Sound System) support.
|
2000-06-04 04:38:36 -04:00
|
|
|
// WARNING: There is a conflict between ESD and ALSA. We may be interrested
|
|
|
|
// in disabling the auto detection of OSS is ESD has been detected.
|
|
|
|
#if 1
|
|
|
|
if (!(caps & MM_SOUND_ESD)) {
|
|
|
|
#endif
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
dev = new wxSoundStreamOSS();
|
|
|
|
if (dev->GetError() == wxSOUND_NOERROR)
|
|
|
|
caps |= MM_SOUND_OSS;
|
|
|
|
delete dev;
|
2000-06-04 04:38:36 -04:00
|
|
|
#if 1
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
#endif
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
#ifdef __WIN32__
|
|
|
|
// We test the Windows sound support.
|
|
|
|
|
|
|
|
dev = new wxSoundStreamWin();
|
2000-03-08 03:32:31 -05:00
|
|
|
if (dev->GetError() == wxSOUND_NOERROR)
|
2000-03-05 14:03:21 -05:00
|
|
|
caps |= MM_SOUND_WIN;
|
|
|
|
delete dev;
|
|
|
|
#endif
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
return caps;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// main frame
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// frame constructor
|
|
|
|
MMBoardFrame::MMBoardFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
2004-06-12 19:44:08 -04:00
|
|
|
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size)
|
2000-03-05 14:03:21 -05:00
|
|
|
{
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// we need this in order to allow the about menu relocation, since ABOUT is
|
|
|
|
// not the default id of the about menu
|
|
|
|
wxApp::s_macAboutMenuItemId = MMBoard_About;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// set the frame icon
|
|
|
|
SetIcon(wxICON(mondrian));
|
|
|
|
|
|
|
|
// create a menu bar
|
2004-06-12 19:44:08 -04:00
|
|
|
wxMenu *menuFile = new wxMenu(wxEmptyString, wxMENU_TEAROFF);
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
// the "About" item should be in the help menu
|
|
|
|
wxMenu *helpMenu = new wxMenu;
|
|
|
|
helpMenu->Append(MMBoard_About, wxT("&About...\tCtrl-A"), wxT("Show about dialog"));
|
|
|
|
|
|
|
|
menuFile->Append(MMBoard_Open, wxT("&Open\tAlt-O"), wxT("Open file"));
|
|
|
|
menuFile->AppendSeparator();
|
|
|
|
menuFile->Append(MMBoard_Quit, wxT("E&xit\tAlt-X"), wxT("Quit this program"));
|
|
|
|
|
|
|
|
// now append the freshly created menu to the menu bar...
|
|
|
|
wxMenuBar *menuBar = new wxMenuBar();
|
|
|
|
menuBar->Append(menuFile, wxT("&File"));
|
|
|
|
menuBar->Append(helpMenu, wxT("&Help"));
|
|
|
|
|
|
|
|
// ... and attach this menu bar to the frame
|
|
|
|
SetMenuBar(menuBar);
|
|
|
|
|
|
|
|
#if wxUSE_STATUSBAR
|
|
|
|
// create a status bar just for fun (by default with 1 pane only)
|
|
|
|
CreateStatusBar(3);
|
2004-05-25 07:20:37 -04:00
|
|
|
SetStatusText(wxT("Welcome to wxWidgets!"));
|
2000-03-05 14:03:21 -05:00
|
|
|
#endif // wxUSE_STATUSBAR
|
|
|
|
|
|
|
|
// Misc variables
|
|
|
|
m_opened_file = NULL;
|
|
|
|
|
2004-06-12 19:44:08 -04:00
|
|
|
m_panel = new wxPanel(this, wxID_ANY);
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
// Initialize main slider
|
|
|
|
m_positionSlider = new wxSlider( m_panel, MMBoard_PositionSlider, 0, 0, 60,
|
2004-06-16 11:22:59 -04:00
|
|
|
wxDefaultPosition, wxSize(300, wxDefaultSize.y),
|
2004-06-12 19:44:08 -04:00
|
|
|
wxSL_HORIZONTAL | wxSL_AUTOTICKS);
|
2000-03-05 14:03:21 -05:00
|
|
|
m_positionSlider->SetPageSize(60); // 60 secs
|
2004-06-12 19:44:08 -04:00
|
|
|
m_positionSlider->Disable();
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// Initialize info panel
|
2004-06-12 19:44:08 -04:00
|
|
|
wxPanel *infoPanel = new wxPanel( m_panel, wxID_ANY);
|
2000-03-05 14:03:21 -05:00
|
|
|
infoPanel->SetBackgroundColour(*wxBLACK);
|
|
|
|
infoPanel->SetForegroundColour(*wxWHITE);
|
|
|
|
|
|
|
|
wxBoxSizer *infoSizer = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
2004-06-12 19:44:08 -04:00
|
|
|
m_fileType = new wxStaticText(infoPanel, wxID_ANY, wxEmptyString);
|
|
|
|
wxStaticLine *line = new wxStaticLine(infoPanel, wxID_ANY);
|
|
|
|
m_infoText = new wxStaticText(infoPanel, wxID_ANY, wxEmptyString);
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
UpdateInfoText();
|
|
|
|
|
|
|
|
infoSizer->Add(m_fileType, 0, wxGROW | wxALL, 1);
|
|
|
|
infoSizer->Add(line, 0, wxGROW | wxCENTRE, 20);
|
|
|
|
infoSizer->Add(m_infoText, 0, wxGROW | wxALL, 1);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
infoPanel->SetSizer(infoSizer);
|
|
|
|
|
|
|
|
// Bitmap button panel
|
|
|
|
wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2002-04-08 06:50:14 -04:00
|
|
|
wxBitmap play_bmp(play_back_xpm);
|
|
|
|
wxBitmap stop_bmp(stop_back_xpm);
|
|
|
|
wxBitmap eject_bmp(eject_xpm);
|
|
|
|
wxBitmap pause_bmp(pause_xpm);
|
2000-03-05 14:03:21 -05:00
|
|
|
|
2002-04-08 06:50:14 -04:00
|
|
|
m_playButton = new wxBitmapButton(m_panel, MMBoard_PlayButton, play_bmp);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_playButton->Disable();
|
2002-04-08 06:50:14 -04:00
|
|
|
m_pauseButton = new wxBitmapButton(m_panel, MMBoard_PauseButton, pause_bmp);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_pauseButton->Disable();
|
2002-04-08 06:50:14 -04:00
|
|
|
m_stopButton = new wxBitmapButton(m_panel, MMBoard_StopButton, stop_bmp);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_stopButton->Disable();
|
2002-04-08 06:50:14 -04:00
|
|
|
m_ejectButton = new wxBitmapButton(m_panel, MMBoard_EjectButton, eject_bmp);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_ejectButton->Disable();
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
buttonSizer->Add(m_playButton, 0, wxALL, 2);
|
2004-06-12 19:44:08 -04:00
|
|
|
buttonSizer->Add(m_pauseButton, 0, wxALL, 2);
|
2000-03-05 14:03:21 -05:00
|
|
|
buttonSizer->Add(m_stopButton, 0, wxALL, 2);
|
|
|
|
buttonSizer->Add(m_ejectButton, 0, wxALL, 2);
|
|
|
|
|
|
|
|
// Top sizer
|
|
|
|
m_sizer = new wxBoxSizer(wxVERTICAL);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0);
|
2000-03-05 14:03:21 -05:00
|
|
|
m_sizer->Add(m_positionSlider, 0, wxCENTRE | wxGROW | wxALL, 2);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0);
|
2000-03-05 14:03:21 -05:00
|
|
|
m_sizer->Add(buttonSizer, 0, wxALL, 0);
|
2004-06-12 19:44:08 -04:00
|
|
|
m_sizer->Add(new wxStaticLine(m_panel, wxID_ANY), 0, wxGROW | wxCENTRE, 0);
|
2000-03-05 14:03:21 -05:00
|
|
|
m_sizer->Add(infoPanel, 1, wxCENTRE | wxGROW, 0);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
m_panel->SetSizer(m_sizer);
|
|
|
|
m_sizer->Fit(this);
|
|
|
|
m_sizer->SetSizeHints(this);
|
|
|
|
|
|
|
|
// Timer
|
|
|
|
m_refreshTimer = new wxTimer(this, MMBoard_RefreshInfo);
|
|
|
|
|
|
|
|
// Video window
|
|
|
|
m_video_window = NULL;
|
|
|
|
|
|
|
|
// Multimedia file
|
|
|
|
m_opened_file = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
MMBoardFrame::~MMBoardFrame()
|
|
|
|
{
|
|
|
|
if (m_opened_file)
|
|
|
|
delete m_opened_file;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
delete m_refreshTimer;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OpenVideoWindow()
|
|
|
|
{
|
|
|
|
if (m_video_window)
|
|
|
|
return;
|
|
|
|
|
2004-06-12 19:44:08 -04:00
|
|
|
m_video_window = new wxWindow(m_panel, wxID_ANY, wxDefaultPosition, wxSize(200, 200));
|
2000-03-05 14:03:21 -05:00
|
|
|
m_video_window->SetBackgroundColour(*wxBLACK);
|
|
|
|
m_sizer->Prepend(m_video_window, 2, wxGROW | wxSHRINK | wxCENTRE, 1);
|
|
|
|
|
|
|
|
m_sizer->Fit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::CloseVideoWindow()
|
|
|
|
{
|
|
|
|
if (!m_video_window)
|
|
|
|
return;
|
Deprecated wxSizer::Remove( wxWindow* ), s/Remove/Detach/ in most places.
Made wxSizer child list typesafe. I've not added the wxList implicit
conversion kludge yet, let's see who complains first perhaps..
Deprecated wxSizer::{G,S}etOption in favour of {G,S}etProportion in line
with the parameter name change in the docs.
Added {G,S}etSpacer consistent with the accessors for windows/sizers.
Made all wxSizer index parameters size_t -- we support no sensible
interpretation for negative indexes in them. Hopefully this will
cause no real problems, but code doing (eg. Remove( 0 )) will need
to change to use 0u to resolve the ambiguity with overloaded members.
This is probably a Good Thing though, ymmv.
s/FALSE/false/g ; s/TRUE/true/g ; s/wxASSERT/wxASSERT_MSG/g in sizer.{cpp,h}
Fixed (I hope) the brokenness in wxSizer::Show -- I have no code to test
this yet, so it's a blind change, but spacers should now be hidden correctly
instead of ignored, and it should be properly reversable over multiple
calls now too.
removed pointless private scoping around DECLARE_CLASS macros.
Replace 0's I added previously with NULL -- not like that will end the
email thread either..
Added Add( wxSizerItem * ) & co. There are probably a couple of other
places we can usefully do something like this too. Stopped short of
refactoring everything to raise some issues about sizer method recursion
on -dev.
Updated wxSizer docs some more, they are still incomplete but getting
better.
wrapped KeyCode in wxDEPRECATED, converted all (gtk build) instances
to GetKeyCode. There may be a few left for other ports.
Fixed a couple of other random compile warnings along the way.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-01-07 05:22:07 -05:00
|
|
|
|
|
|
|
m_sizer->Detach( m_video_window );
|
2000-03-05 14:03:21 -05:00
|
|
|
delete m_video_window;
|
|
|
|
m_video_window = NULL;
|
Deprecated wxSizer::Remove( wxWindow* ), s/Remove/Detach/ in most places.
Made wxSizer child list typesafe. I've not added the wxList implicit
conversion kludge yet, let's see who complains first perhaps..
Deprecated wxSizer::{G,S}etOption in favour of {G,S}etProportion in line
with the parameter name change in the docs.
Added {G,S}etSpacer consistent with the accessors for windows/sizers.
Made all wxSizer index parameters size_t -- we support no sensible
interpretation for negative indexes in them. Hopefully this will
cause no real problems, but code doing (eg. Remove( 0 )) will need
to change to use 0u to resolve the ambiguity with overloaded members.
This is probably a Good Thing though, ymmv.
s/FALSE/false/g ; s/TRUE/true/g ; s/wxASSERT/wxASSERT_MSG/g in sizer.{cpp,h}
Fixed (I hope) the brokenness in wxSizer::Show -- I have no code to test
this yet, so it's a blind change, but spacers should now be hidden correctly
instead of ignored, and it should be properly reversable over multiple
calls now too.
removed pointless private scoping around DECLARE_CLASS macros.
Replace 0's I added previously with NULL -- not like that will end the
email thread either..
Added Add( wxSizerItem * ) & co. There are probably a couple of other
places we can usefully do something like this too. Stopped short of
refactoring everything to raise some issues about sizer method recursion
on -dev.
Updated wxSizer docs some more, they are still incomplete but getting
better.
wrapped KeyCode in wxDEPRECATED, converted all (gtk build) instances
to GetKeyCode. There may be a few left for other ports.
Fixed a couple of other random compile warnings along the way.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2003-01-07 05:22:07 -05:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
m_sizer->Fit(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// event handlers
|
|
|
|
|
|
|
|
void MMBoardFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2004-06-12 19:44:08 -04:00
|
|
|
// true is to force the frame to close
|
|
|
|
Close(true);
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxString msg;
|
2004-05-25 07:20:37 -04:00
|
|
|
msg.Printf( wxT("wxWidgets Multimedia board v1.0a, wxMMedia v2.0a:\n")
|
|
|
|
wxT("an example of the capabilities of the wxWidgets multimedia classes.\n")
|
2004-06-12 19:44:08 -04:00
|
|
|
wxT("Copyright 1999, 2000, Guilhem Lavaux.\n"));
|
|
|
|
|
2003-09-11 05:55:21 -04:00
|
|
|
wxMessageBox(msg, _T("About MMBoard"), wxOK | wxICON_INFORMATION, this);
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnOpen(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxString selected_file;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
if (m_opened_file) {
|
|
|
|
if (!m_opened_file->IsStopped()) {
|
|
|
|
wxCommandEvent event2;
|
|
|
|
OnStop(event2);
|
|
|
|
}
|
|
|
|
delete m_opened_file;
|
|
|
|
}
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// select a file to be opened
|
2003-09-11 05:55:21 -04:00
|
|
|
selected_file = wxLoadFileSelector(_T("multimedia"), _T("*"), NULL, this);
|
2000-03-05 14:03:21 -05:00
|
|
|
if (selected_file.IsNull())
|
|
|
|
return;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
m_opened_file = MMBoardManager::Open(selected_file);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// Change the range values of the slider.
|
|
|
|
MMBoardTime length;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
length = m_opened_file->GetLength();
|
|
|
|
m_positionSlider->SetRange(0, length.hours * 3600 + length.minutes * 60 + length.seconds);
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// Update misc info
|
|
|
|
UpdateMMedInfo();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2004-07-19 11:14:07 -04:00
|
|
|
#if wxUSE_STATUSBAR
|
2000-03-05 14:03:21 -05:00
|
|
|
SetStatusText(selected_file, 2);
|
2004-07-19 11:14:07 -04:00
|
|
|
#endif // wxUSE_STATUSBAR
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// Update info text
|
|
|
|
UpdateInfoText();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// Enable a few buttons
|
2004-06-12 19:44:08 -04:00
|
|
|
m_playButton->Enable();
|
|
|
|
m_ejectButton->Enable();
|
|
|
|
m_positionSlider->Enable();
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
if (m_opened_file->NeedWindow()) {
|
|
|
|
OpenVideoWindow();
|
|
|
|
m_opened_file->SetWindow(m_video_window);
|
|
|
|
} else
|
|
|
|
CloseVideoWindow();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::UpdateInfoText()
|
|
|
|
{
|
|
|
|
wxString infotext1, infotext2;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
if (m_opened_file) {
|
|
|
|
infotext1 = wxT("File type:\n\t");
|
|
|
|
infotext1 += m_opened_file->GetStringType() + wxT("\n");
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
infotext2 = wxT("File informations:\n\n");
|
|
|
|
infotext2 += m_opened_file->GetStringInformation();
|
|
|
|
} else {
|
|
|
|
infotext1 = wxT("File type: \n\tNo file opened");
|
|
|
|
infotext2 = wxT("File informations:\nNo information\n\n\n\n\n");
|
|
|
|
}
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
m_fileType->SetLabel(infotext1);
|
|
|
|
m_infoText->SetLabel(infotext2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::UpdateMMedInfo()
|
|
|
|
{
|
|
|
|
MMBoardTime current, length;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
if (m_opened_file) {
|
|
|
|
current = m_opened_file->GetPosition();
|
|
|
|
length = m_opened_file->GetLength();
|
|
|
|
} else {
|
|
|
|
current.hours = current.minutes = current.seconds = 0;
|
|
|
|
length = current;
|
|
|
|
}
|
|
|
|
|
2004-07-19 11:14:07 -04:00
|
|
|
#if wxUSE_STATUSBAR
|
2000-03-05 14:03:21 -05:00
|
|
|
// We refresh the status bar
|
2004-07-19 11:14:07 -04:00
|
|
|
wxString temp_string;
|
2000-03-05 14:03:21 -05:00
|
|
|
temp_string.Printf(wxT("%02d:%02d / %02d:%02d"), current.hours * 60 + current.minutes,
|
|
|
|
current.seconds, length.hours * 60 + length.minutes, length.seconds);
|
|
|
|
SetStatusText(temp_string, 1);
|
2004-07-19 11:14:07 -04:00
|
|
|
#else
|
|
|
|
wxUnusedVar(length);
|
|
|
|
#endif // wxUSE_STATUSBAR
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
// We set the slider position
|
|
|
|
m_positionSlider->SetValue(current.hours * 3600 + current.minutes * 60 + current.seconds);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Playing management, refreshers, ...
|
|
|
|
|
|
|
|
void MMBoardFrame::OnRefreshInfo(wxEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
UpdateMMedInfo();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
|
|
|
if (m_opened_file->IsStopped())
|
|
|
|
{
|
2000-03-05 14:03:21 -05:00
|
|
|
m_refreshTimer->Stop();
|
2004-06-12 19:44:08 -04:00
|
|
|
m_playButton->Enable();
|
|
|
|
m_stopButton->Disable();
|
|
|
|
m_pauseButton->Disable();
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnPlay(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
2004-06-12 19:44:08 -04:00
|
|
|
m_stopButton->Enable();
|
|
|
|
m_pauseButton->Enable();
|
|
|
|
m_playButton->Disable();
|
|
|
|
|
|
|
|
if (m_opened_file->IsPaused())
|
|
|
|
{
|
2000-03-05 14:03:21 -05:00
|
|
|
m_opened_file->Resume();
|
|
|
|
return;
|
|
|
|
}
|
2004-06-12 19:44:08 -04:00
|
|
|
|
|
|
|
m_refreshTimer->Start(1000, false);
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
m_opened_file->Play();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
|
|
|
m_stopButton->Enable();
|
|
|
|
m_pauseButton->Enable();
|
|
|
|
m_playButton->Disable();
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnStop(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_opened_file->Stop();
|
|
|
|
m_refreshTimer->Stop();
|
|
|
|
|
2004-06-12 19:44:08 -04:00
|
|
|
m_stopButton->Disable();
|
|
|
|
m_playButton->Enable();
|
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
UpdateMMedInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnPause(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_opened_file->Pause();
|
2004-06-12 19:44:08 -04:00
|
|
|
|
|
|
|
m_playButton->Enable();
|
|
|
|
m_pauseButton->Disable();
|
2000-03-05 14:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnEject(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
m_opened_file->Stop();
|
|
|
|
|
|
|
|
delete m_opened_file;
|
|
|
|
m_opened_file = NULL;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
|
|
|
m_playButton->Disable();
|
|
|
|
m_pauseButton->Disable();
|
|
|
|
m_stopButton->Disable();
|
|
|
|
m_ejectButton->Disable();
|
|
|
|
m_positionSlider->Disable();
|
2000-03-05 14:03:21 -05:00
|
|
|
|
|
|
|
UpdateInfoText();
|
|
|
|
UpdateMMedInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MMBoardFrame::OnSetPosition(wxCommandEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxUint32 itime;
|
|
|
|
MMBoardTime btime;
|
2004-06-12 19:44:08 -04:00
|
|
|
|
2000-03-05 14:03:21 -05:00
|
|
|
itime = m_positionSlider->GetValue();
|
|
|
|
btime.seconds = itime % 60;
|
|
|
|
btime.minutes = (itime / 60) % 60;
|
|
|
|
btime.hours = itime / 3600;
|
|
|
|
m_opened_file->SetPosition(btime);
|
|
|
|
|
|
|
|
UpdateMMedInfo();
|
|
|
|
}
|
|
|
|
|