No resize border on WinCE by default
[wxWidgets.git] / include / wx / mediactrl.h
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$
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
54 enum wxMediaState
55 {
56 wxMEDIASTATE_STOPPED,
57 wxMEDIASTATE_PAUSED,
58 wxMEDIASTATE_PLAYING
59 };
60
61 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
62 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
63 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
64 #define wxMEDIABACKEND_GSTREAMER wxT("wxGStreamerMediaBackend")
65
66 // ----------------------------------------------------------------------------
67 //
68 // wxMediaEvent
69 //
70 // ----------------------------------------------------------------------------
71
72 class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
73 {
74 public:
75 // ------------------------------------------------------------------------
76 // wxMediaEvent Constructor
77 //
78 // Normal constructor, much the same as wxNotifyEvent
79 // ------------------------------------------------------------------------
80 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
81 : wxNotifyEvent(commandType, winid)
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
107 // ----------------------------------------------------------------------------
108 //
109 // wxMediaCtrl
110 //
111 // ----------------------------------------------------------------------------
112
113 class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
114 {
115 public:
116 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false)
117 { }
118
119 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
120 const wxString& fileName = wxEmptyString,
121 const wxPoint& pos = wxDefaultPosition,
122 const wxSize& size = wxDefaultSize,
123 long style = 0,
124 const wxString& szBackend = wxEmptyString,
125 const wxValidator& validator = wxDefaultValidator,
126 const wxString& name = wxT("mediaCtrl"))
127 : m_imp(NULL), m_bLoaded(false)
128 { Create(parent, winid, fileName, pos, size, style,
129 szBackend, validator, name); }
130
131 wxMediaCtrl(wxWindow* parent, wxWindowID winid,
132 const wxURI& location,
133 const wxPoint& pos = wxDefaultPosition,
134 const wxSize& size = wxDefaultSize,
135 long style = 0,
136 const wxString& szBackend = wxEmptyString,
137 const wxValidator& validator = wxDefaultValidator,
138 const wxString& name = wxT("mediaCtrl"))
139 : m_imp(NULL), m_bLoaded(false)
140 { Create(parent, winid, location, pos, size, style,
141 szBackend, validator, name); }
142
143 ~wxMediaCtrl();
144
145 bool Create(wxWindow* parent, wxWindowID winid,
146 const wxString& fileName = wxEmptyString,
147 const wxPoint& pos = wxDefaultPosition,
148 const wxSize& size = wxDefaultSize,
149 long style = 0,
150 const wxString& szBackend = wxEmptyString,
151 const wxValidator& validator = wxDefaultValidator,
152 const wxString& name = wxT("mediaCtrl"));
153
154 bool Create(wxWindow* parent, wxWindowID winid,
155 const wxURI& location,
156 const wxPoint& pos = wxDefaultPosition,
157 const wxSize& size = wxDefaultSize,
158 long style = 0,
159 const wxString& szBackend = wxEmptyString,
160 const wxValidator& validator = wxDefaultValidator,
161 const wxString& name = wxT("mediaCtrl")); //DirectShow only
162
163 bool DoCreate(wxClassInfo* instance,
164 wxWindow* parent, wxWindowID winid,
165 const wxPoint& pos = wxDefaultPosition,
166 const wxSize& size = wxDefaultSize,
167 long style = 0,
168 const wxValidator& validator = wxDefaultValidator,
169 const wxString& name = wxT("mediaCtrl"));
170
171 bool Play();
172 bool Pause();
173 bool Stop();
174
175 bool Load(const wxString& fileName);
176
177
178 wxMediaState GetState();
179
180 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
181 wxFileOffset Tell(); //FIXME: This should be const
182 wxFileOffset Length(); //FIXME: This should be const
183
184 //
185 // Unofficial parts of API
186 //
187 //DirectShow/GStreamer only. Quicktime too, but somewhat buggy...
188 bool Load(const wxURI& location);
189
190 double GetPlaybackRate(); //All but MCI & GStreamer
191 bool SetPlaybackRate(double dRate); //All but MCI & GStreamer
192
193 protected:
194 static wxClassInfo* NextBackend();
195
196 void OnMediaFinished(wxMediaEvent& evt);
197 virtual void DoMoveWindow(int x, int y, int w, int h);
198 wxSize DoGetBestSize() const;
199
200 //FIXME: This is nasty... find a better way to work around
201 //inheritance issues
202 #ifdef __WXMAC__
203 friend class wxQTMediaBackend;
204 #endif
205 #ifdef __WXCOCOA__
206 friend class wxQTMediaBackend;
207 #endif
208 class wxMediaBackend* m_imp;
209 bool m_bLoaded;
210
211 DECLARE_DYNAMIC_CLASS(wxMediaCtrl)
212 };
213
214 // ----------------------------------------------------------------------------
215 //
216 // wxMediaBackend
217 //
218 // Currently an internal class - API stability not guaranteed.
219 //
220 // ----------------------------------------------------------------------------
221
222 class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
223 {
224 public:
225 wxMediaBackend()
226 { }
227
228 virtual ~wxMediaBackend();
229
230 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
231 wxWindow* WXUNUSED(parent),
232 wxWindowID WXUNUSED(winid),
233 const wxPoint& WXUNUSED(pos),
234 const wxSize& WXUNUSED(size),
235 long WXUNUSED(style),
236 const wxValidator& WXUNUSED(validator),
237 const wxString& WXUNUSED(name))
238 { return false; }
239
240 virtual bool Play()
241 { return false; }
242 virtual bool Pause()
243 { return false; }
244 virtual bool Stop()
245 { return false; }
246
247 virtual bool Load(const wxString& WXUNUSED(fileName))
248 { return false; }
249 virtual bool Load(const wxURI& WXUNUSED(location))
250 { return false; }
251
252 virtual bool SetPosition(wxLongLong WXUNUSED(where))
253 { return 0; }
254 virtual wxLongLong GetPosition()
255 { return 0; }
256 virtual wxLongLong GetDuration()
257 { return 0; }
258
259 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
260 int WXUNUSED(w), int WXUNUSED(h))
261 { }
262 virtual wxSize GetVideoSize() const
263 { return wxSize(0,0); }
264
265 virtual double GetPlaybackRate()
266 { return 0.0; }
267 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
268 { return false; }
269
270 virtual wxMediaState GetState()
271 { return wxMEDIASTATE_STOPPED; }
272
273 DECLARE_DYNAMIC_CLASS(wxMediaBackend)
274 };
275
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
281 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
282 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
283
284 //Function type(s) our events need
285 typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
286
287 #define wxMediaEventHandler(func) \
288 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxMediaEventFunction, &func)
289
290 //Macro for usage with message maps
291 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
292 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, wxMediaEventHandler(fn), (wxObject *) NULL ),
293
294 // ----------------------------------------------------------------------------
295 // End compilation gaurd
296 // ----------------------------------------------------------------------------
297 #endif // wxUSE_MEDIACTRL
298
299 // ----------------------------------------------------------------------------
300 // End header guard and header itself
301 // ----------------------------------------------------------------------------
302 #endif // _WX_MEDIACTRL_H_
303
304