core/vgui/wx/wxVideoControl.h
Go to the documentation of this file.
00001 // This is core/vgui/wx/wxVideoControl.h
00002 #ifndef wxVideoControl_h_
00003 #define wxVideoControl_h_
00004 //:
00005 // \file
00006 // \brief  A control panel for frame-by-frame video navigation
00007 // \author Matt Leotta
00008 // \date   April 10, 2009
00009 //
00010 
00011 #include <wx/panel.h>
00012 #include <vgui/vgui_observable.h>
00013 #include <vcl_vector.h>
00014 
00015 // forward declarations
00016 class wxBitmapButton;
00017 class wxSlider;
00018 class wxTextCtrl;
00019 
00020 //: A control panel for frame-by-frame video navigation
00021 class wxVideoControl: public wxPanel, public vgui_observable
00022 {
00023   DECLARE_DYNAMIC_CLASS( wxVideoControl )
00024   DECLARE_EVENT_TABLE()
00025 
00026  public:
00027   // Constructors
00028   wxVideoControl();
00029   wxVideoControl(wxWindow* parent,
00030                  wxWindowID id = wxID_ANY,
00031                  const wxPoint& pos = wxDefaultPosition,
00032                  const wxSize& size = wxDefaultSize,
00033                  long style = wxVSCROLL|wxSUNKEN_BORDER|wxTAB_TRAVERSAL,
00034                  const wxString& name = wxT("wxVideoControl"));
00035 
00036   //: Creation
00037   bool Create(wxWindow* parent,
00038               wxWindowID id = wxID_ANY,
00039               const wxPoint& pos = wxDefaultPosition,
00040               const wxSize& size = wxDefaultSize,
00041               long style = wxVSCROLL|wxSUNKEN_BORDER|wxTAB_TRAVERSAL,
00042               const wxString& name = wxT("wxVideoControl"));
00043 
00044   // Destructor
00045   ~wxVideoControl();
00046 
00047   //: Initialises member variables
00048   void Init();
00049 
00050   //: Creates the controls and sizers
00051   void CreateControls();
00052 
00053 
00054   //: Event handler
00055   void OnSliderTrack( wxScrollEvent& event );
00056   //: Event handler
00057   void OnSliderChange( wxScrollEvent& event );
00058   //: Event handler
00059   void OnEnterText( wxCommandEvent& event );
00060   //: Event handler
00061   void OnButton( wxCommandEvent& event );
00062   //: Event handler
00063   void OnKeyDown( wxKeyEvent& event );
00064 
00065   //: Handle Textbox loss of focus
00066   // \note the "this" argument is invalid because this must be called from the wxTextCtrl itself
00067   void OnKillTextFocus( wxCommandEvent& event );
00068 
00069 
00070   //: Return the number of frames
00071   unsigned int num_frames() const { return num_frames_; }
00072 
00073   //: Return the current frame
00074   unsigned int frame() const { return frame_; }
00075 
00076   //: Set the number of frames
00077   void set_num_frames(unsigned int num_frames);
00078 
00079   //: Set the current frame
00080   void set_frame(unsigned int frame, bool send_message = true);
00081 
00082   //: Advance to next frame
00083   void next();
00084 
00085   //: Step to previous frame
00086   void prev();
00087 
00088   //: Start the video playing
00089   void play();
00090 
00091   //: Pause the video
00092   void pause();
00093 
00094   //: Return true if in play mode
00095   bool is_playing() const { return is_playing_; }
00096 
00097   //: Should we show tooltips?
00098   static bool ShowToolTips();
00099 
00100   //: These static memory address are used to identify vgui_message types
00101   static const char m_preview[];
00102   static const char m_seek[];
00103   static const char m_next[];
00104   static const char m_prev[];
00105   static const char m_play[];
00106   static const char m_pause[];
00107 
00108  private:
00109   wxBitmapButton* prev_button_;
00110   wxBitmapButton* play_button_;
00111   wxBitmapButton* next_button_;
00112   wxSlider* slider_;
00113   wxTextCtrl* frame_text_;
00114 
00115   unsigned int frame_;
00116   unsigned int num_frames_;
00117 
00118   //: used to disable sending of message
00119   bool send_messages_;
00120 
00121   //: is the video playing
00122   bool is_playing_;
00123 };
00124 
00125 
00126 #endif // wxVideoControl_h_