#ifndef WX_OPEN_CV_H
#define WX_OPEN_CV_H

#include <boost/shared_ptr.hpp>
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#include <memory>

#include "Capture.h"
#include "PlayerUI.h"

#include "media-playback-pause.xpm"
#include "media-playback-start.xpm"
#include "media-playback-stop.xpm"
#include "media-skip-backward.xpm"
#include "media-skip-forward.xpm"
#include "media-seek-forward.xpm"
#include "media-seek-backward.xpm"

#define ID_TIMER 20000

using namespace std;
using namespace boost;

class Player :
	public PlayerUI
{

private:
	wxTimer timer;
	shared_ptr<Capture> capture;

public:

	Player(wxWindow *parent, wxWindowID winid = wxID_ANY , const wxPoint& pos = wxDefaultPosition , const wxSize& size  = wxDefaultSize , long style = wxTAB_TRAVERSAL | wxNO_BORDER, const wxString& name = wxPanelNameStr);
	
	void customCreation();

	void onTimer(wxTimerEvent & evt);

	void refreshCanvas()
	{
		leftMediaCanvas->Refresh(false);
		//rightMediaCanvas->Refresh(false);
	}

	virtual void onSliderScroll(wxScrollEvent & evt);
	virtual void onStop(wxCommandEvent & evt);
	virtual void onPlay(wxCommandEvent & evt);
	virtual void onRewindButtonClick( wxCommandEvent& event );
	virtual void onForwardButtonClick( wxCommandEvent& event );

	shared_ptr<Capture> getCapture() const { return capture; }
	void setCapture(shared_ptr<Capture> val) { 
		capture = val; 

 		leftMediaCanvas->SetBestFittingSize(wxSize(capture->getWidth(),capture->getHeight()));
		leftMediaCanvas->setCapture(capture);
		leftMediaCanvas->Show();

		customCreation();

		timer.Start(1000/capture->getFrameRate());
	}

	OpenCVGLCanvas * getLeftCanvas() {
		return leftMediaCanvas;
	}

	~Player(void);

	DECLARE_EVENT_TABLE()
};

#endif



