]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/mediactrl.h
Empty container and design description for native PalmOS wxPrefConfig. Remove MSW...
[wxWidgets.git] / include / wx / mediactrl.h
... / ...
CommitLineData
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
51enum wxMediaState
52{
53 wxMEDIASTATE_STOPPED,
54 wxMEDIASTATE_PAUSED,
55 wxMEDIASTATE_PLAYING
56};
57
58#define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
59#define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
60#define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
61
62// ----------------------------------------------------------------------------
63//
64// wxMediaEvent
65//
66// ----------------------------------------------------------------------------
67
68class WXDLLIMPEXP_MEDIA wxMediaEvent : public wxNotifyEvent
69{
70public:
71 // ------------------------------------------------------------------------
72 // wxMediaEvent Constructor
73 //
74 // Normal constructor, much the same as wxNotifyEvent
75 // ------------------------------------------------------------------------
76 wxMediaEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
77 : wxNotifyEvent(commandType, id)
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
103// ----------------------------------------------------------------------------
104//
105// wxMediaCtrl
106//
107// ----------------------------------------------------------------------------
108
109class WXDLLIMPEXP_MEDIA wxMediaCtrl : public wxControl
110{
111public:
112 wxMediaCtrl() : m_imp(NULL), m_bLoaded(false), m_bLoop(false)
113 { }
114
115 wxMediaCtrl(wxWindow* parent, wxWindowID id,
116 const wxString& fileName = wxT(""),
117 const wxPoint& pos = wxDefaultPosition,
118 const wxSize& size = wxDefaultSize,
119 long style = 0,
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)
124 { Create(parent, id, fileName, pos, size, style,
125 szBackend, validator, name); }
126
127 wxMediaCtrl(wxWindow* parent, wxWindowID id,
128 const wxURI& location,
129 const wxPoint& pos = wxDefaultPosition,
130 const wxSize& size = wxDefaultSize,
131 long style = 0,
132 const wxString& szBackend = wxT(""),
133 const wxValidator& validator = wxDefaultValidator,
134 const wxString& name = wxT("mediaCtrl"))
135 : m_imp(NULL), m_bLoop(false)
136 { Create(parent, id, location, pos, size, style,
137 szBackend, validator, name); }
138
139 ~wxMediaCtrl();
140
141 bool Create(wxWindow* parent, wxWindowID id,
142 const wxString& fileName = wxT(""),
143 const wxPoint& pos = wxDefaultPosition,
144 const wxSize& size = wxDefaultSize,
145 long style = 0,
146 const wxString& szBackend = wxT(""),
147 const wxValidator& validator = wxDefaultValidator,
148 const wxString& name = wxT("mediaCtrl"));
149
150 bool Create(wxWindow* parent, wxWindowID id,
151 const wxURI& location,
152 const wxPoint& pos = wxDefaultPosition,
153 const wxSize& size = wxDefaultSize,
154 long style = 0,
155 const wxString& szBackend = wxT(""),
156 const wxValidator& validator = wxDefaultValidator,
157 const wxString& name = wxT("mediaCtrl")); //DirectShow only
158
159 bool DoCreate(wxClassInfo* instance,
160 wxWindow* parent, wxWindowID id,
161 const wxPoint& pos = wxDefaultPosition,
162 const wxSize& size = wxDefaultSize,
163 long style = 0,
164 const wxValidator& validator = wxDefaultValidator,
165 const wxString& name = wxT("mediaCtrl"));
166
167 bool Play();
168 bool Pause();
169 bool Stop();
170
171 bool Load(const wxString& fileName);
172 bool Load(const wxURI& location); //DirectShow only
173
174 void Loop(bool bLoop = true);
175 bool IsLooped();
176
177 wxMediaState GetState();
178
179 double GetPlaybackRate(); //All but MCI
180 bool SetPlaybackRate(double dRate); //All but MCI
181
182 wxFileOffset Seek(wxFileOffset where, wxSeekMode mode = wxFromStart);
183 wxFileOffset Tell(); //FIXME: This should be const
184 wxFileOffset Length(); //FIXME: This should be const
185
186protected:
187 static wxClassInfo* NextBackend();
188
189 void OnMediaFinished(wxMediaEvent& evt);
190 virtual void DoMoveWindow(int x, int y, int w, int h);
191 wxSize DoGetBestSize() const;
192
193 class wxMediaBackend* m_imp;
194 bool m_bLoaded;
195 bool m_bLoop;
196
197 DECLARE_DYNAMIC_CLASS(wxMediaCtrl);
198};
199
200// ----------------------------------------------------------------------------
201//
202// wxMediaBackend
203//
204// Currently an internal class - API stability not guaranteed.
205//
206// ----------------------------------------------------------------------------
207
208class WXDLLIMPEXP_MEDIA wxMediaBackend : public wxObject
209{
210public:
211 wxMediaBackend()
212 { }
213
214 virtual ~wxMediaBackend();
215
216 virtual bool CreateControl(wxControl* WXUNUSED(ctrl),
217 wxWindow* WXUNUSED(parent),
218 wxWindowID WXUNUSED(id),
219 const wxPoint& WXUNUSED(pos),
220 const wxSize& WXUNUSED(size),
221 long WXUNUSED(style),
222 const wxValidator& WXUNUSED(validator),
223 const wxString& WXUNUSED(name))
224 { return false; }
225
226 virtual bool Play()
227 { return false; }
228 virtual bool Pause()
229 { return false; }
230 virtual bool Stop()
231 { return false; }
232
233 virtual bool Load(const wxString& WXUNUSED(fileName))
234 { return false; }
235 virtual bool Load(const wxURI& WXUNUSED(location))
236 { return false; }
237
238 virtual bool SetPosition(wxLongLong WXUNUSED(where))
239 { return 0; }
240 virtual wxLongLong GetPosition()
241 { return 0; }
242 virtual wxLongLong GetDuration()
243 { return 0; }
244
245 virtual void Move(int WXUNUSED(x), int WXUNUSED(y),
246 int WXUNUSED(w), int WXUNUSED(h))
247 { }
248 virtual wxSize GetVideoSize() const
249 { return wxSize(0,0); }
250
251 virtual double GetPlaybackRate()
252 { return 0.0; }
253 virtual bool SetPlaybackRate(double WXUNUSED(dRate))
254 { return false; }
255
256 virtual wxMediaState GetState()
257 { return wxMEDIASTATE_STOPPED; }
258
259 DECLARE_CLASS(wxMediaBackend)
260};
261
262//Event ID to give to our events
263#define wxMEDIA_FINISHED_ID 13000
264#define wxMEDIA_STOP_ID 13001
265
266//Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
267DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_FINISHED, wxMEDIA_FINISHED_ID)
268DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_MEDIA, wxEVT_MEDIA_STOP, wxMEDIA_STOP_ID)
269
270//Function type(s) our events need
271typedef void (wxEvtHandler::*wxMediaEventFunction)(wxMediaEvent&);
272
273//Macro for usage with message maps
274#define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
275#define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
276
277// ----------------------------------------------------------------------------
278// End compilation gaurd
279// ----------------------------------------------------------------------------
280#endif // wxUSE_MEDIACTRL
281
282// ----------------------------------------------------------------------------
283// End header guard and header itself
284// ----------------------------------------------------------------------------
285#endif // _WX_MEDIACTRL_H_
286
287