]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mediactrl.h
removed just added UnsetVirtualSize(), it's not needed finally
[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
ff4aedc5 193protected:
973dc0a8
RN
194 static wxClassInfo* NextBackend();
195
226ec5a7 196 void OnMediaFinished(wxMediaEvent& evt);
ff4aedc5
RN
197 virtual void DoMoveWindow(int x, int y, int w, int h);
198 wxSize DoGetBestSize() const;
199
bc036010
RN
200 //FIXME: This is nasty... find a better way to work around
201 //inheritance issues
3b5023b9 202#ifdef __WXMAC__
ecd20d4a 203 friend class wxQTMediaBackend;
4fc81cbc
RN
204#endif
205#ifdef __WXCOCOA__
206 friend class wxQTMediaBackend;
3b5023b9 207#endif
ff4aedc5
RN
208 class wxMediaBackend* m_imp;
209 bool m_bLoaded;
ff4aedc5 210
3839f37e 211 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
ff4aedc5
RN
212};
213
214// ----------------------------------------------------------------------------
215//
216// wxMediaBackend
217//
9180b535 218// Currently an internal class - API stability not guaranteed.
ff4aedc5
RN
219//
220// ----------------------------------------------------------------------------
221
ff2b312f 222class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
ff4aedc5
RN
223{
224public:
225 wxMediaBackend()
226 { }
227
228 virtual ~wxMediaBackend();
229
226ec5a7
WS
230 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
231 wxWindow* WXUNUSED(parent),
4fc81cbc 232 wxWindowID WXUNUSED(winid),
226ec5a7 233 const wxPoint& WXUNUSED(pos),
78450975 234 const wxSize& WXUNUSED(size),
226ec5a7 235 long WXUNUSED(style),
78450975
RN
236 const wxValidator& WXUNUSED(validator),
237 const wxString& WXUNUSED(name))
ff4aedc5
RN
238 { return false; }
239
226ec5a7 240 virtual bool Play()
ff4aedc5 241 { return false; }
226ec5a7 242 virtual bool Pause()
ff4aedc5 243 { return false; }
226ec5a7 244 virtual bool Stop()
ff4aedc5
RN
245 { return false; }
246
226ec5a7 247 virtual bool Load(const wxString& WXUNUSED(fileName))
ff4aedc5 248 { return false; }
226ec5a7 249 virtual bool Load(const wxURI& WXUNUSED(location))
ff4aedc5
RN
250 { return false; }
251
226ec5a7 252 virtual bool SetPosition(wxLongLong WXUNUSED(where))
ff4aedc5 253 { return 0; }
226ec5a7 254 virtual wxLongLong GetPosition()
ff4aedc5 255 { return 0; }
226ec5a7 256 virtual wxLongLong GetDuration()
ff4aedc5
RN
257 { return 0; }
258
226ec5a7
WS
259 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
260 int WXUNUSED(w), int WXUNUSED(h))
ff4aedc5 261 { }
226ec5a7 262 virtual wxSize GetVideoSize() const
c47addef 263 { return wxSize(0,0); }
ff4aedc5 264
226ec5a7 265 virtual double GetPlaybackRate()
ff4aedc5 266 { return 0.0; }
226ec5a7 267 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
ff4aedc5
RN
268 { return false; }
269
270 virtual wxMediaState GetState()
271 { return wxMEDIASTATE_STOPPED; }
272
3839f37e 273 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
ff4aedc5
RN
274};
275
ff4aedc5
RN
276//Event ID to give to our events
277#define wxMEDIA_FINISHED_ID 13000
278#define wxMEDIA_STOP_ID 13001
279
280//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
c220a8ec
RD
281DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
282DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
ff4aedc5
RN
283
284//Function type(s) our events need
285typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
286
287//Macro for usage with message maps
288#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
289#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
290
291// ----------------------------------------------------------------------------
292// End compilation gaurd
293// ----------------------------------------------------------------------------
294#endif // wxUSE_MEDIACTRL
295
296// ----------------------------------------------------------------------------
297// End header guard and header itself
298// ----------------------------------------------------------------------------
299#endif // _WX_MEDIACTRL_H_
300
301