source: GTP/trunk/Lib/Illum/GPUObscurancesGT/Libraries/wx/include/wx/mediactrl.h @ 1648

Revision 1648, 14.6 KB checked in by igarcia, 18 years ago (diff)
Line 
1///////////////////////////////////////////////////////////////////////////////
2// Name:        wx/mediactrl.h
3// Purpose:     wxMediaCtrl class
4// Author:      Ryan Norton <wxprojects@comcast.net>
5// Modified by:
6// Created:     11/07/04
7// RCS-ID:      $Id: mediactrl.h,v 1.25 2005/09/11 11:03:38 VZ Exp $
8// Copyright:   (c) Ryan Norton
9// Licence:     wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12// ============================================================================
13// Definitions
14// ============================================================================
15
16// ----------------------------------------------------------------------------
17// Header guard
18// ----------------------------------------------------------------------------
19#ifndef _WX_MEDIACTRL_H_
20#define _WX_MEDIACTRL_H_
21
22// ----------------------------------------------------------------------------
23// Pre-compiled header stuff
24// ----------------------------------------------------------------------------
25#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
26#pragma interface "mediactrl.h"
27#endif
28
29#include "wx/defs.h"
30
31// ----------------------------------------------------------------------------
32// Compilation guard
33// ----------------------------------------------------------------------------
34
35#if wxUSE_MEDIACTRL
36
37// ----------------------------------------------------------------------------
38// Includes
39// ----------------------------------------------------------------------------
40
41#include "wx/control.h"
42#include "wx/uri.h"
43
44// ============================================================================
45// Declarations
46// ============================================================================
47
48// ----------------------------------------------------------------------------
49//
50// Enumerations
51//
52// ----------------------------------------------------------------------------
53
54enum wxMediaState
55{
56    wxMEDIASTATE_STOPPED,
57    wxMEDIASTATE_PAUSED,
58    wxMEDIASTATE_PLAYING
59};
60
61enum wxMediaCtrlPlayerControls
62{
63    wxMEDIACTRLPLAYERCONTROLS_NONE           =   0,
64    //Step controls like fastfoward, step one frame etc.
65    wxMEDIACTRLPLAYERCONTROLS_STEP           =   1 << 0,
66    //Volume controls like the speaker icon, volume slider, etc.
67    wxMEDIACTRLPLAYERCONTROLS_VOLUME         =   1 << 1,
68    wxMEDIACTRLPLAYERCONTROLS_DEFAULT        =
69                    wxMEDIACTRLPLAYERCONTROLS_STEP |
70                    wxMEDIACTRLPLAYERCONTROLS_VOLUME
71};
72
73#define wxMEDIABACKEND_DIRECTSHOW   wxT("wxAMMediaBackend")
74#define wxMEDIABACKEND_MCI          wxT("wxMCIMediaBackend")
75#define wxMEDIABACKEND_QUICKTIME    wxT("wxQTMediaBackend")
76#define wxMEDIABACKEND_GSTREAMER    wxT("wxGStreamerMediaBackend")
77
78
79// ----------------------------------------------------------------------------
80//
81// wxMediaEvent
82//
83// ----------------------------------------------------------------------------
84
85class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
86{
87public:
88    // ------------------------------------------------------------------------
89    // wxMediaEvent Constructor
90    //
91    // Normal constructor, much the same as wxNotifyEvent
92    // ------------------------------------------------------------------------
93    wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
94        : wxNotifyEvent(commandType, winid)
95    {                                       }
96
97    // ------------------------------------------------------------------------
98    // wxMediaEvent Copy Constructor
99    //
100    // Normal copy constructor, much the same as wxNotifyEvent
101    // ------------------------------------------------------------------------
102    wxMediaEvent(const wxMediaEvent &clone)
103            : wxNotifyEvent(clone)
104    {                                       }
105
106    // ------------------------------------------------------------------------
107    // wxMediaEvent::Clone
108    //
109    // Allocates a copy of this object.
110    // Required for wxEvtHandler::AddPendingEvent
111    // ------------------------------------------------------------------------
112    virtual wxEvent *Clone() const
113    {   return new wxMediaEvent(*this);     }
114
115
116    // Put this class on wxWidget's RTTI table
117    DECLARE_DYNAMIC_CLASS(wxMediaEvent)
118};
119
120// ----------------------------------------------------------------------------
121//
122// wxMediaCtrl
123//
124// ----------------------------------------------------------------------------
125
126class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
127{
128public:
129    wxMediaCtrl() : m_imp(NULL), m_bLoaded(false)
130    {                                                                   }
131
132    wxMediaCtrl(wxWindow* parent, wxWindowID winid,
133                const wxString& fileName = wxEmptyString,
134                const wxPoint& pos = wxDefaultPosition,
135                const wxSize& size = wxDefaultSize,
136                long style = 0,
137                const wxString& szBackend = wxEmptyString,
138                const wxValidator& validator = wxDefaultValidator,
139                const wxString& name = wxT("mediaCtrl"))
140                : m_imp(NULL), m_bLoaded(false)
141    {   Create(parent, winid, fileName, pos, size, style,
142               szBackend, validator, name);                             }
143
144    wxMediaCtrl(wxWindow* parent, wxWindowID winid,
145                const wxURI& location,
146                const wxPoint& pos = wxDefaultPosition,
147                const wxSize& size = wxDefaultSize,
148                long style = 0,
149                const wxString& szBackend = wxEmptyString,
150                const wxValidator& validator = wxDefaultValidator,
151                const wxString& name = wxT("mediaCtrl"))
152                : m_imp(NULL), m_bLoaded(false)
153    {   Create(parent, winid, location, pos, size, style,
154               szBackend, validator, name);                             }
155
156    ~wxMediaCtrl();
157
158    bool Create(wxWindow* parent, wxWindowID winid,
159                const wxString& fileName = wxEmptyString,
160                const wxPoint& pos = wxDefaultPosition,
161                const wxSize& size = wxDefaultSize,
162                long style = 0,
163                const wxString& szBackend = wxEmptyString,
164                const wxValidator& validator = wxDefaultValidator,
165                const wxString& name = wxT("mediaCtrl"));
166
167    bool Create(wxWindow* parent, wxWindowID winid,
168                const wxURI& location,
169                const wxPoint& pos = wxDefaultPosition,
170                const wxSize& size = wxDefaultSize,
171                long style = 0,
172                const wxString& szBackend = wxEmptyString,
173                const wxValidator& validator = wxDefaultValidator,
174                const wxString& name = wxT("mediaCtrl"));
175
176    bool DoCreate(wxClassInfo* instance,
177                wxWindow* parent, wxWindowID winid,
178                const wxPoint& pos = wxDefaultPosition,
179                const wxSize& size = wxDefaultSize,
180                long style = 0,
181                const wxValidator& validator = wxDefaultValidator,
182                const wxString& name = wxT("mediaCtrl"));
183
184    bool Play();
185    bool Pause();
186    bool Stop();
187
188    bool Load(const wxString& fileName);
189
190    wxMediaState GetState();
191
192    wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
193    wxFileOffset Tell(); //FIXME: This should be const
194    wxFileOffset Length(); //FIXME: This should be const
195
196#if wxABI_VERSION >= 20601 /* 2.6.1+ only */
197    double GetPlaybackRate();           //All but MCI & GStreamer
198    bool SetPlaybackRate(double dRate); //All but MCI & GStreamer
199#endif
200
201#if wxABI_VERSION >= 20602 /* 2.6.2+ only */
202    bool Load(const wxURI& location);
203    bool Load(const wxURI& location, const wxURI& proxy);
204
205    wxFileOffset GetDownloadProgress();
206    wxFileOffset GetDownloadTotal();
207
208    double GetVolume();
209    bool   SetVolume(double dVolume);
210
211    bool    ShowPlayerControls(
212        wxMediaCtrlPlayerControls flags = wxMEDIACTRLPLAYERCONTROLS_DEFAULT);
213
214    //helpers for the wxPython people
215    bool LoadURI(const wxString& fileName)
216    {   return Load(wxURI(fileName));       }
217    bool LoadURIWithProxy(const wxString& fileName, const wxString& proxy)
218    {   return Load(wxURI(fileName), wxURI(proxy));       }
219#endif
220protected:
221    static wxClassInfo* NextBackend();
222
223    void OnMediaFinished(wxMediaEvent& evt);
224    virtual void DoMoveWindow(int x, int y, int w, int h);
225    wxSize DoGetBestSize() const;
226
227    //FIXME:  This is nasty... find a better way to work around
228    //inheritance issues
229#if defined(__WXMAC__) || defined(__WXCOCOA__)
230    friend class wxQTMediaBackend;
231#endif
232    class wxMediaBackend* m_imp;
233    bool m_bLoaded;
234
235    DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
236};
237
238// ----------------------------------------------------------------------------
239//
240// wxMediaBackend
241//
242// Derive from this and use standard wxWidgets RTTI
243// (DECLARE_DYNAMIC_CLASS and IMPLEMENT_CLASS) to make a backend
244// for wxMediaCtrl.  Backends are searched alphabetically -
245// the one with the earliest letter is tried first.
246//
247// Note that this is currently not API or ABI compatable -
248// so statically link or make the client compile on-site.
249//
250// ----------------------------------------------------------------------------
251
252class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
253{
254public:
255    wxMediaBackend()
256    {                                   }
257
258    virtual ~wxMediaBackend();
259
260    virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
261                               wxWindow* WXUNUSED(parent),
262                               wxWindowID WXUNUSED(winid),
263                               const wxPoint& WXUNUSED(pos),
264                               const wxSize& WXUNUSED(size),
265                               long WXUNUSED(style),
266                               const wxValidator& WXUNUSED(validator),
267                               const wxString& WXUNUSED(name))
268    {   return false;                   }
269
270    virtual bool Play()
271    {   return false;                   }
272    virtual bool Pause()
273    {   return false;                   }
274    virtual bool Stop()
275    {   return false;                   }
276
277    virtual bool Load(const wxString& WXUNUSED(fileName))
278    {   return false;                   }
279    virtual bool Load(const wxURI& WXUNUSED(location))
280    {   return false;                   }
281
282    virtual bool SetPosition(wxLongLong WXUNUSED(where))
283    {   return 0;                       }
284    virtual wxLongLong GetPosition()
285    {   return 0;                       }
286    virtual wxLongLong GetDuration()
287    {   return 0;                       }
288
289    virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
290                      int WXUNUSED(w), int WXUNUSED(h))
291    {                                   }
292    virtual wxSize GetVideoSize() const
293    {   return wxSize(0,0);             }
294
295    virtual double GetPlaybackRate()
296    {   return 0.0;                     }
297    virtual bool SetPlaybackRate(double WXUNUSED(dRate))
298    {   return false;                   }
299
300    virtual wxMediaState GetState()
301    {   return wxMEDIASTATE_STOPPED;    }
302
303    virtual double GetVolume()
304    {   return 0.0;                     }
305    virtual bool SetVolume(double WXUNUSED(dVolume))
306    {   return false;                   }
307
308    virtual bool Load(const wxURI& WXUNUSED(location),
309                      const wxURI& WXUNUSED(proxy))
310    {   return false;                   }
311
312    virtual bool   ShowPlayerControls(
313                    wxMediaCtrlPlayerControls WXUNUSED(flags))
314    {   return false;                   }
315    virtual bool   IsInterfaceShown()
316    {   return false;                   }
317
318    virtual wxLongLong GetDownloadProgress()
319    {    return 0;                      }
320    virtual wxLongLong GetDownloadTotal()
321    {    return 0;                      }
322
323    virtual void RESERVED8() {}
324    virtual void RESERVED9() {}
325
326    DECLARE_DYNAMIC_CLASS(wxMediaBackend)
327};
328
329
330//Event ID to give to our events
331#define wxMEDIA_FINISHED_ID    13000
332#define wxMEDIA_STOP_ID    13001
333
334//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
335DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
336DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP,     wxMEDIA_STOP_ID)
337
338//Function type(s) our events need
339typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
340
341#define wxMediaEventHandler(func) \
342    (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func)
343
344//Macro for usage with message maps
345#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
346#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
347
348#if wxABI_VERSION >= 20602 /* 2.6.2+ only */
349#   define wxMEDIA_LOADED_ID      13002
350    DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_LOADED,     wxMEDIA_LOADED_ID)
351#   define EVT_MEDIA_LOADED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_LOADED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
352#endif
353
354// ----------------------------------------------------------------------------
355// common backend base class used by many other backends
356// ----------------------------------------------------------------------------
357
358class WXDLLIMPEXP_MEDIA wxMediaBackendCommonBase : public wxMediaBackend
359{
360public:
361    // add a pending wxMediaEvent of the given type
362    void QueueEvent(wxEventType evtType);
363
364    // notify that the movie playback is finished
365    void QueueFinishEvent() { QueueEvent(wxEVT_MEDIA_FINISHED); }
366
367    // send the stop event and return true if it hasn't been vetoed
368    bool SendStopEvent();
369
370protected:
371    // call this when the movie size has changed but not because it has just
372    // been loaded (in this case, call NotifyMovieLoaded() below)
373    void NotifyMovieSizeChanged();
374
375    // call this when the movie is fully loaded
376    void NotifyMovieLoaded();
377
378
379    wxMediaCtrl *m_ctrl;      // parent control
380};
381
382// ----------------------------------------------------------------------------
383// End compilation gaurd
384// ----------------------------------------------------------------------------
385#endif // wxUSE_MEDIACTRL
386
387// ----------------------------------------------------------------------------
388// End header guard and header itself
389// ----------------------------------------------------------------------------
390#endif // _WX_MEDIACTRL_H_
391
392
Note: See TracBrowser for help on using the repository browser.