]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mediactrl.h
eVC3 compatibility workaround.
[wxWidgets.git] / include / wx / mediactrl.h
CommitLineData
ff4aedc5 1///////////////////////////////////////////////////////////////////////////////
1a680109
RN
2// Name: wx/mediactrl.h
3// Purpose: wxMediaCtrl class
4// Author: Ryan Norton <wxprojects@comcast.net>
226ec5a7 5// Modified by:
1a680109
RN
6// Created: 11/07/04
7// RCS-ID: $Id$
8// Copyright: (c) Ryan Norton
9// Licence: wxWindows licence
ff4aedc5 10///////////////////////////////////////////////////////////////////////////////
1a680109 11
ff4aedc5
RN
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"
72259e00
RL
27#endif
28
2ecf902b
WS
29#include "wx/defs.h"
30
ff4aedc5
RN
31// ----------------------------------------------------------------------------
32// Compilation guard
33// ----------------------------------------------------------------------------
2ecf902b 34
ff4aedc5
RN
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
ff4aedc5
RN
61#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
62#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
63#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
ce756cb0 64#define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
ff4aedc5 65
226ec5a7
WS
66// ----------------------------------------------------------------------------
67//
68// wxMediaEvent
69//
70// ----------------------------------------------------------------------------
71
ff2b312f 72class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
226ec5a7
WS
73{
74public:
75 // ------------------------------------------------------------------------
76 // wxMediaEvent Constructor
77 //
78 // Normal constructor, much the same as wxNotifyEvent
79 // ------------------------------------------------------------------------
4fc81cbc
RN
80 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
81 : wxNotifyEvent(commandType, winid)
226ec5a7
WS
82 { }
83
84 // ------------------------------------------------------------------------
85 // wxMediaEvent Copy Constructor
86 //
87 // Normal copy constructor, much the same as wxNotifyEvent
88 // ------------------------------------------------------------------------
89 wxMediaEvent(const wxMediaEvent &clone)
90 : wxNotifyEvent(clone)
91 { }
92
93 // ------------------------------------------------------------------------
94 // wxMediaEvent::Clone
95 //
96 // Allocates a copy of this object.
97 // Required for wxEvtHandler::AddPendingEvent
98 // ------------------------------------------------------------------------
99 virtual wxEvent *Clone() const
100 { return new wxMediaEvent(*this); }
101
102
103 // Put this class on wxWidget's RTTI table
104 DECLARE_DYNAMIC_CLASS(wxMediaEvent)
105};
106
ff4aedc5
RN
107// ----------------------------------------------------------------------------
108//
109// wxMediaCtrl
110//
111// ----------------------------------------------------------------------------
112
ff2b312f 113class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
ff4aedc5
RN
114{
115public:
bc036010 116 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false)
ff4aedc5
RN
117 { }
118
4fc81cbc 119 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
8b5d5223 120 const wxString& fileName = wxEmptyString,
226ec5a7 121 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 122 const wxSize& size = wxDefaultSize,
226ec5a7 123 long style = 0,
8b5d5223 124 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
125 const wxValidator& validator = wxDefaultValidator,
126 const wxString& name = wxT("mediaCtrl"))
bc036010 127 : m_imp(NULL), m_bLoaded(false)
4fc81cbc 128 { Create(parent, winid, fileName, pos, size, style,
ff4aedc5
RN
129 szBackend, validator, name); }
130
4fc81cbc 131 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
ff4aedc5 132 const wxURI& location,
226ec5a7 133 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 134 const wxSize& size = wxDefaultSize,
226ec5a7 135 long style = 0,
8b5d5223 136 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
137 const wxValidator& validator = wxDefaultValidator,
138 const wxString& name = wxT("mediaCtrl"))
bc036010 139 : m_imp(NULL), m_bLoaded(false)
4fc81cbc 140 { Create(parent, winid, location, pos, size, style,
ff4aedc5
RN
141 szBackend, validator, name); }
142
143 ~wxMediaCtrl();
144
4fc81cbc 145 bool Create(wxWindow* parent, wxWindowID winid,
8b5d5223 146 const wxString& fileName = wxEmptyString,
226ec5a7 147 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 148 const wxSize& size = wxDefaultSize,
226ec5a7 149 long style = 0,
8b5d5223 150 const wxString& szBackend = wxEmptyString,
ff4aedc5
RN
151 const wxValidator& validator = wxDefaultValidator,
152 const wxString& name = wxT("mediaCtrl"));
153
4fc81cbc 154 bool Create(wxWindow* parent, wxWindowID winid,
ff4aedc5 155 const wxURI& location,
226ec5a7 156 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 157 const wxSize& size = wxDefaultSize,
226ec5a7 158 long style = 0,
8b5d5223 159 const wxString& szBackend = wxEmptyString,
ff4aedc5 160 const wxValidator& validator = wxDefaultValidator,
9180b535 161 const wxString& name = wxT("mediaCtrl")); //DirectShow only
ff4aedc5
RN
162
163 bool DoCreate(wxClassInfo* instance,
4fc81cbc 164 wxWindow* parent, wxWindowID winid,
226ec5a7 165 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 166 const wxSize& size = wxDefaultSize,
226ec5a7 167 long style = 0,
ff4aedc5
RN
168 const wxValidator& validator = wxDefaultValidator,
169 const wxString& name = wxT("mediaCtrl"));
170
ff4aedc5
RN
171 bool Play();
172 bool Pause();
173 bool Stop();
174
175 bool Load(const wxString& fileName);
ff4aedc5 176
ff4aedc5
RN
177
178 wxMediaState GetState();
179
9180b535
RN
180 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
181 wxFileOffset Tell(); //FIXME: This should be const
182 wxFileOffset Length(); //FIXME: This should be const
973dc0a8 183
bc036010 184 //
2ecf902b 185 // Unofficial parts of API
bc036010
RN
186 //
187 //DirectShow/GStreamer only. Quicktime too, but somewhat buggy...
2ecf902b 188 bool Load(const wxURI& location);
bc036010
RN
189
190 double GetPlaybackRate(); //All but MCI & GStreamer
191 bool SetPlaybackRate(double dRate); //All but MCI & GStreamer
192
6f8c67e7
JS
193 double GetVolume(); //DirectShow only
194 bool SetVolume(double dVolume); //DirectShow only
195
ff4aedc5 196protected:
973dc0a8
RN
197 static wxClassInfo* NextBackend();
198
226ec5a7 199 void OnMediaFinished(wxMediaEvent& evt);
ff4aedc5
RN
200 virtual void DoMoveWindow(int x, int y, int w, int h);
201 wxSize DoGetBestSize() const;
202
bc036010
RN
203 //FIXME: This is nasty... find a better way to work around
204 //inheritance issues
3b5023b9 205#ifdef __WXMAC__
ecd20d4a 206 friend class wxQTMediaBackend;
4fc81cbc
RN
207#endif
208#ifdef __WXCOCOA__
209 friend class wxQTMediaBackend;
3b5023b9 210#endif
ff4aedc5
RN
211 class wxMediaBackend* m_imp;
212 bool m_bLoaded;
ff4aedc5 213
3839f37e 214 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
ff4aedc5
RN
215};
216
217// ----------------------------------------------------------------------------
218//
219// wxMediaBackend
220//
9180b535 221// Currently an internal class - API stability not guaranteed.
ff4aedc5
RN
222//
223// ----------------------------------------------------------------------------
224
ff2b312f 225class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
ff4aedc5
RN
226{
227public:
228 wxMediaBackend()
229 { }
230
231 virtual ~wxMediaBackend();
232
226ec5a7
WS
233 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
234 wxWindow* WXUNUSED(parent),
4fc81cbc 235 wxWindowID WXUNUSED(winid),
226ec5a7 236 const wxPoint& WXUNUSED(pos),
78450975 237 const wxSize& WXUNUSED(size),
226ec5a7 238 long WXUNUSED(style),
78450975
RN
239 const wxValidator& WXUNUSED(validator),
240 const wxString& WXUNUSED(name))
ff4aedc5
RN
241 { return false; }
242
226ec5a7 243 virtual bool Play()
ff4aedc5 244 { return false; }
226ec5a7 245 virtual bool Pause()
ff4aedc5 246 { return false; }
226ec5a7 247 virtual bool Stop()
ff4aedc5
RN
248 { return false; }
249
226ec5a7 250 virtual bool Load(const wxString& WXUNUSED(fileName))
ff4aedc5 251 { return false; }
226ec5a7 252 virtual bool Load(const wxURI& WXUNUSED(location))
ff4aedc5
RN
253 { return false; }
254
226ec5a7 255 virtual bool SetPosition(wxLongLong WXUNUSED(where))
ff4aedc5 256 { return 0; }
226ec5a7 257 virtual wxLongLong GetPosition()
ff4aedc5 258 { return 0; }
226ec5a7 259 virtual wxLongLong GetDuration()
ff4aedc5
RN
260 { return 0; }
261
226ec5a7
WS
262 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
263 int WXUNUSED(w), int WXUNUSED(h))
ff4aedc5 264 { }
226ec5a7 265 virtual wxSize GetVideoSize() const
c47addef 266 { return wxSize(0,0); }
ff4aedc5 267
226ec5a7 268 virtual double GetPlaybackRate()
ff4aedc5 269 { return 0.0; }
226ec5a7 270 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
ff4aedc5
RN
271 { return false; }
272
273 virtual wxMediaState GetState()
274 { return wxMEDIASTATE_STOPPED; }
275
6f8c67e7
JS
276 virtual double GetVolume()
277 { return 0.0; }
278 virtual bool SetVolume(double WXUNUSED(dVolume))
279 { return false; }
280
07323ed6
RN
281 virtual void RESERVED3() {}
282 virtual void RESERVED4() {}
283 virtual void RESERVED5() {}
284 virtual void RESERVED6() {}
285 virtual void RESERVED7() {}
286 virtual void RESERVED8() {}
287 virtual void RESERVED9() {}
288
3839f37e 289 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
ff4aedc5
RN
290};
291
ff4aedc5
RN
292//Event ID to give to our events
293#define wxMEDIA_FINISHED_ID 13000
294#define wxMEDIA_STOP_ID 13001
295
296//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
c220a8ec
RD
297DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
298DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
ff4aedc5
RN
299
300//Function type(s) our events need
301typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
302
4153a503
RN
303#define wxMediaEventHandler(func) \
304 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func)
305
ff4aedc5 306//Macro for usage with message maps
4153a503
RN
307#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
308#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
ff4aedc5
RN
309
310// ----------------------------------------------------------------------------
311// End compilation gaurd
312// ----------------------------------------------------------------------------
313#endif // wxUSE_MEDIACTRL
314
315// ----------------------------------------------------------------------------
316// End header guard and header itself
317// ----------------------------------------------------------------------------
318#endif // _WX_MEDIACTRL_H_
319
320