WXUNUSED warning fixes - unicode compilo fix
[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 // ----------------------------------------------------------------------------
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
51 enum wxMediaState
52 {
53 wxMEDIASTATE_STOPPED,
54 wxMEDIASTATE_PAUSED,
55 wxMEDIASTATE_PLAYING
56 };
57
58 enum wxMediaTimeFormat
59 {
60 wxMEDIATIMEFORMAT_TIME
61 };
62
63 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
64 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
65 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
66
67 // ----------------------------------------------------------------------------
68 //
69 // wxMediaCtrl
70 //
71 // ----------------------------------------------------------------------------
72
73 class wxMediaCtrl : public wxControl
74 {
75 public:
76 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
77 { }
78
79 wxMediaCtrl(wxWindow* parent, wxWindowID id,
80 const wxString& fileName = wxT(""),
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
83 long style = 0,
84 const wxString& szBackend = wxT(""),
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxT("mediaCtrl"))
87 : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
88 { Create(parent, id, fileName, pos, size, style,
89 szBackend, validator, name); }
90
91 wxMediaCtrl(wxWindow* parent, wxWindowID id,
92 const wxURI& location,
93 const wxPoint& pos = wxDefaultPosition,
94 const wxSize& size = wxDefaultSize,
95 long style = 0,
96 const wxString& szBackend = wxT(""),
97 const wxValidator& validator = wxDefaultValidator,
98 const wxString& name = wxT("mediaCtrl"))
99 : m_imp(NULL), m_bLoop(false)
100 { Create(parent, id, location, pos, size, style,
101 szBackend, validator, name); }
102
103 ~wxMediaCtrl();
104
105 bool Create(wxWindow* parent, wxWindowID id,
106 const wxString& fileName = wxT(""),
107 const wxPoint& pos = wxDefaultPosition,
108 const wxSize& size = wxDefaultSize,
109 long style = 0,
110 const wxString& szBackend = wxT(""),
111 const wxValidator& validator = wxDefaultValidator,
112 const wxString& name = wxT("mediaCtrl"));
113
114 bool Create(wxWindow* parent, wxWindowID id,
115 const wxURI& location,
116 const wxPoint& pos = wxDefaultPosition,
117 const wxSize& size = wxDefaultSize,
118 long style = 0,
119 const wxString& szBackend = wxT(""),
120 const wxValidator& validator = wxDefaultValidator,
121 const wxString& name = wxT("mediaCtrl"));
122
123 bool DoCreate(wxClassInfo* instance,
124 wxWindow* parent, wxWindowID id,
125 const wxPoint& pos = wxDefaultPosition,
126 const wxSize& size = wxDefaultSize,
127 long style = 0,
128 const wxValidator& validator = wxDefaultValidator,
129 const wxString& name = wxT("mediaCtrl"));
130
131 static wxClassInfo* NextBackend();
132
133
134 bool Play();
135 bool Pause();
136 bool Stop();
137
138 bool Load(const wxString& fileName);
139 bool Load(const wxURI& location);
140
141 void Loop(bool bLoop = true);
142 bool IsLooped();
143
144 wxMediaState GetState();
145
146 double GetPlaybackRate();
147 bool SetPlaybackRate(double dRate);
148
149 bool SetPosition(wxLongLong where);
150 wxLongLong GetPosition();
151 wxLongLong GetDuration();
152
153 protected:
154 void OnMediaFinished(const class wxMediaEvent& evt);
155 virtual void DoMoveWindow(int x, int y, int w, int h);
156 wxSize DoGetBestSize() const;
157
158 class wxMediaBackend* m_imp;
159 bool m_bLoaded;
160 bool m_bLoop;
161
162 DECLARE_DYNAMIC_CLASS(wxMediaCtrl);
163 };
164
165 // ----------------------------------------------------------------------------
166 //
167 // wxMediaBackend
168 //
169 // Currently an internal class - API stability not gauranteed.
170 //
171 // ----------------------------------------------------------------------------
172
173 class wxMediaBackend : public wxObject
174 {
175 public:
176 wxMediaBackend()
177 { }
178
179 virtual ~wxMediaBackend();
180
181 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
182 wxWindow* WXUNUSED(parent),
183 wxWindowID WXUNUSED(id),
184 const wxPoint& WXUNUSED(pos),
185 const wxSize& WXUNUSED(size),
186 long WXUNUSED(style),
187 const wxValidator& WXUNUSED(validator),
188 const wxString& WXUNUSED(name))
189 { return false; }
190
191 virtual bool Play()
192 { return false; }
193 virtual bool Pause()
194 { return false; }
195 virtual bool Stop()
196 { return false; }
197
198 virtual bool Load(const wxString& WXUNUSED(fileName))
199 { return false; }
200 virtual bool Load(const wxURI& WXUNUSED(location))
201 { return false; }
202
203 virtual bool SetPosition(wxLongLong WXUNUSED(where))
204 { return 0; }
205 virtual wxLongLong GetPosition()
206 { return 0; }
207 virtual wxLongLong GetDuration()
208 { return 0; }
209
210 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
211 int WXUNUSED(w), int WXUNUSED(h))
212 { }
213 virtual wxSize GetVideoSize() const
214 { return wxSize(0,0); }
215
216 virtual double GetPlaybackRate()
217 { return 0.0; }
218 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
219 { return false; }
220
221 virtual wxMediaState GetState()
222 { return wxMEDIASTATE_STOPPED; }
223
224 DECLARE_CLASS(wxMediaBackend)
225 };
226
227 // ----------------------------------------------------------------------------
228 //
229 // wxMediaEvent
230 //
231 // ----------------------------------------------------------------------------
232
233 class WXDLLEXPORT wxMediaEvent : public wxNotifyEvent
234 {
235 public:
236 // ------------------------------------------------------------------------
237 // wxMediaEvent Constructor
238 //
239 // Normal constructor, much the same as wxNotifyEvent
240 // ------------------------------------------------------------------------
241 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
242 : wxNotifyEvent(commandType, id)
243 { }
244
245 // ------------------------------------------------------------------------
246 // wxMediaEvent Copy Constructor
247 //
248 // Normal copy constructor, much the same as wxNotifyEvent
249 // ------------------------------------------------------------------------
250 wxMediaEvent(const wxMediaEvent &clone)
251 : wxNotifyEvent(clone)
252 { }
253
254 // ------------------------------------------------------------------------
255 // wxMediaEvent::Clone
256 //
257 // Allocates a copy of this object.
258 // Required for wxEvtHandler::AddPendingEvent
259 // ------------------------------------------------------------------------
260 virtual wxEvent *Clone() const
261 { return new wxMediaEvent(*this); }
262
263
264 // Put this class on wxWidget's RTTI table
265 DECLARE_DYNAMIC_CLASS(wxMediaEvent)
266 };
267
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
273 DECLARE_EVENT_TYPE(wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
274 DECLARE_EVENT_TYPE(wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
275
276 //Function type(s) our events need
277 typedef 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