]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mediactrl.h
Doc fixes A-M edition. Thanks to Arnout for pointing these out. Also I fixed some...
[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
ff4aedc5
RN
29// ----------------------------------------------------------------------------
30// Compilation guard
31// ----------------------------------------------------------------------------
32#if wxUSE_MEDIACTRL
33
34// ----------------------------------------------------------------------------
35// Includes
36// ----------------------------------------------------------------------------
37
38#include "wx/control.h"
39#include "wx/uri.h"
40
41// ============================================================================
42// Declarations
43// ============================================================================
44
45// ----------------------------------------------------------------------------
46//
47// Enumerations
48//
49// ----------------------------------------------------------------------------
50
51enum wxMediaState
52{
53 wxMEDIASTATE_STOPPED,
54 wxMEDIASTATE_PAUSED,
55 wxMEDIASTATE_PLAYING
56};
57
ff4aedc5
RN
58#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
59#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
60#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
61
226ec5a7
WS
62// ----------------------------------------------------------------------------
63//
64// wxMediaEvent
65//
66// ----------------------------------------------------------------------------
67
ff2b312f 68class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
226ec5a7
WS
69{
70public:
71 // ------------------------------------------------------------------------
72 // wxMediaEvent Constructor
73 //
74 // Normal constructor, much the same as wxNotifyEvent
75 // ------------------------------------------------------------------------
4fc81cbc
RN
76 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
77 : wxNotifyEvent(commandType, winid)
226ec5a7
WS
78 { }
79
80 // ------------------------------------------------------------------------
81 // wxMediaEvent Copy Constructor
82 //
83 // Normal copy constructor, much the same as wxNotifyEvent
84 // ------------------------------------------------------------------------
85 wxMediaEvent(const wxMediaEvent &clone)
86 : wxNotifyEvent(clone)
87 { }
88
89 // ------------------------------------------------------------------------
90 // wxMediaEvent::Clone
91 //
92 // Allocates a copy of this object.
93 // Required for wxEvtHandler::AddPendingEvent
94 // ------------------------------------------------------------------------
95 virtual wxEvent *Clone() const
96 { return new wxMediaEvent(*this); }
97
98
99 // Put this class on wxWidget's RTTI table
100 DECLARE_DYNAMIC_CLASS(wxMediaEvent)
101};
102
ff4aedc5
RN
103// ----------------------------------------------------------------------------
104//
105// wxMediaCtrl
106//
107// ----------------------------------------------------------------------------
108
ff2b312f 109class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
ff4aedc5
RN
110{
111public:
112 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
113 { }
114
4fc81cbc 115 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
ff4aedc5 116 const wxString& fileName = wxT(""),
226ec5a7 117 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 118 const wxSize& size = wxDefaultSize,
226ec5a7 119 long style = 0,
ff4aedc5
RN
120 const wxString& szBackend = wxT(""),
121 const wxValidator& validator = wxDefaultValidator,
122 const wxString& name = wxT("mediaCtrl"))
123 : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
4fc81cbc 124 { Create(parent, winid, fileName, pos, size, style,
ff4aedc5
RN
125 szBackend, validator, name); }
126
4fc81cbc 127 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
ff4aedc5 128 const wxURI& location,
226ec5a7 129 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 130 const wxSize& size = wxDefaultSize,
226ec5a7 131 long style = 0,
ff4aedc5
RN
132 const wxString& szBackend = wxT(""),
133 const wxValidator& validator = wxDefaultValidator,
134 const wxString& name = wxT("mediaCtrl"))
135 : m_imp(NULL), m_bLoop(false)
4fc81cbc 136 { Create(parent, winid, location, pos, size, style,
ff4aedc5
RN
137 szBackend, validator, name); }
138
139 ~wxMediaCtrl();
140
4fc81cbc 141 bool Create(wxWindow* parent, wxWindowID winid,
ff4aedc5 142 const wxString& fileName = wxT(""),
226ec5a7 143 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 144 const wxSize& size = wxDefaultSize,
226ec5a7 145 long style = 0,
ff4aedc5
RN
146 const wxString& szBackend = wxT(""),
147 const wxValidator& validator = wxDefaultValidator,
148 const wxString& name = wxT("mediaCtrl"));
149
4fc81cbc 150 bool Create(wxWindow* parent, wxWindowID winid,
ff4aedc5 151 const wxURI& location,
226ec5a7 152 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 153 const wxSize& size = wxDefaultSize,
226ec5a7 154 long style = 0,
ff4aedc5
RN
155 const wxString& szBackend = wxT(""),
156 const wxValidator& validator = wxDefaultValidator,
9180b535 157 const wxString& name = wxT("mediaCtrl")); //DirectShow only
ff4aedc5
RN
158
159 bool DoCreate(wxClassInfo* instance,
4fc81cbc 160 wxWindow* parent, wxWindowID winid,
226ec5a7 161 const wxPoint& pos = wxDefaultPosition,
ff4aedc5 162 const wxSize& size = wxDefaultSize,
226ec5a7 163 long style = 0,
ff4aedc5
RN
164 const wxValidator& validator = wxDefaultValidator,
165 const wxString& name = wxT("mediaCtrl"));
166
ff4aedc5
RN
167 bool Play();
168 bool Pause();
169 bool Stop();
170
171 bool Load(const wxString& fileName);
9180b535 172 bool Load(const wxURI& location); //DirectShow only
ff4aedc5
RN
173
174 void Loop(bool bLoop = true);
175 bool IsLooped();
176
177 wxMediaState GetState();
178
9180b535
RN
179 double GetPlaybackRate(); //All but MCI
180 bool SetPlaybackRate(double dRate); //All but MCI
973dc0a8 181
9180b535
RN
182 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
183 wxFileOffset Tell(); //FIXME: This should be const
184 wxFileOffset Length(); //FIXME: This should be const
973dc0a8 185
ff4aedc5 186protected:
973dc0a8
RN
187 static wxClassInfo* NextBackend();
188
226ec5a7 189 void OnMediaFinished(wxMediaEvent& evt);
ff4aedc5
RN
190 virtual void DoMoveWindow(int x, int y, int w, int h);
191 wxSize DoGetBestSize() const;
192
3b5023b9 193#ifdef __WXMAC__
ecd20d4a 194 friend class wxQTMediaBackend;
4fc81cbc
RN
195#endif
196#ifdef __WXCOCOA__
197 friend class wxQTMediaBackend;
3b5023b9 198#endif
ff4aedc5
RN
199 class wxMediaBackend* m_imp;
200 bool m_bLoaded;
201 bool m_bLoop;
202
3839f37e 203 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
ff4aedc5
RN
204};
205
206// ----------------------------------------------------------------------------
207//
208// wxMediaBackend
209//
9180b535 210// Currently an internal class - API stability not guaranteed.
ff4aedc5
RN
211//
212// ----------------------------------------------------------------------------
213
ff2b312f 214class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
ff4aedc5
RN
215{
216public:
217 wxMediaBackend()
218 { }
219
220 virtual ~wxMediaBackend();
221
226ec5a7
WS
222 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
223 wxWindow* WXUNUSED(parent),
4fc81cbc 224 wxWindowID WXUNUSED(winid),
226ec5a7 225 const wxPoint& WXUNUSED(pos),
78450975 226 const wxSize& WXUNUSED(size),
226ec5a7 227 long WXUNUSED(style),
78450975
RN
228 const wxValidator& WXUNUSED(validator),
229 const wxString& WXUNUSED(name))
ff4aedc5
RN
230 { return false; }
231
226ec5a7 232 virtual bool Play()
ff4aedc5 233 { return false; }
226ec5a7 234 virtual bool Pause()
ff4aedc5 235 { return false; }
226ec5a7 236 virtual bool Stop()
ff4aedc5
RN
237 { return false; }
238
226ec5a7 239 virtual bool Load(const wxString& WXUNUSED(fileName))
ff4aedc5 240 { return false; }
226ec5a7 241 virtual bool Load(const wxURI& WXUNUSED(location))
ff4aedc5
RN
242 { return false; }
243
226ec5a7 244 virtual bool SetPosition(wxLongLong WXUNUSED(where))
ff4aedc5 245 { return 0; }
226ec5a7 246 virtual wxLongLong GetPosition()
ff4aedc5 247 { return 0; }
226ec5a7 248 virtual wxLongLong GetDuration()
ff4aedc5
RN
249 { return 0; }
250
226ec5a7
WS
251 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
252 int WXUNUSED(w), int WXUNUSED(h))
ff4aedc5 253 { }
226ec5a7 254 virtual wxSize GetVideoSize() const
ff4aedc5
RN
255 { return wxSize(0,0); }
256
226ec5a7 257 virtual double GetPlaybackRate()
ff4aedc5 258 { return 0.0; }
226ec5a7 259 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
ff4aedc5
RN
260 { return false; }
261
262 virtual wxMediaState GetState()
263 { return wxMEDIASTATE_STOPPED; }
264
3839f37e 265 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
ff4aedc5
RN
266};
267
ff4aedc5
RN
268//Event ID to give to our events
269#define wxMEDIA_FINISHED_ID 13000
270#define wxMEDIA_STOP_ID 13001
271
272//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
c220a8ec
RD
273DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
274DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
ff4aedc5
RN
275
276//Function type(s) our events need
277typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
278
279//Macro for usage with message maps
280#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
281#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
282
283// ----------------------------------------------------------------------------
284// End compilation gaurd
285// ----------------------------------------------------------------------------
286#endif // wxUSE_MEDIACTRL
287
288// ----------------------------------------------------------------------------
289// End header guard and header itself
290// ----------------------------------------------------------------------------
291#endif // _WX_MEDIACTRL_H_
292
293