#include "WxMoviePlayer.hpp"
BEGIN_EVENT_TABLE( WxMoviePlayer, wxWindow )
EVT_PAINT( WxMoviePlayer::OnPaint )
EVT_TIMER( TIMER_ID, WxMoviePlayer::OnTimer )
EVT_CHAR( WxMoviePlayer::OnKey )
END_EVENT_TABLE()
The first thing we do is to set up the callbacks that will be associated with individual events. This is done
by macros provided by the wxWidgets framework.
25
WxMoviePlayer::WxMoviePlayer(
wxWindow* parent,
const wxPoint& pos,
const wxSize& size
) : wxWindow( parent, -1, pos, size, wxSIMPLE_BORDER ) {
m_timer = NULL;
m_parent = parent;
}
When the movie player is created, its timer element is NULL (we will set that up when we actually have a
video open). We do take note of the parent of the player, however. (In this case, that parent will be the
wxFrame we created to put it in.) We will need to know who the parent frame is when it comes time to
closing the application in response to the ESC key.
void WxMoviePlayer::OnPaint( wxPaintEvent& event ) {
wxPaintDC dc( this );
if( !dc.Ok() ) return;
int x,y,w,h;
dc.BeginDrawing();
dc.GetClippingBox( &x, &y, &w, &h );
dc.DrawBitmap( m_wx_bmp, x, y );
dc.EndDrawing();
return;
}
The WxMoviePlayer::OnPaint() routine is called whenever the window needs to be repainted on
screen. You will notice that when we execute WxMoviePlayer::OnPaint(), the information we need
to actually do the painting is assumed ...