]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mediactrl.h
69acc08e9077ecd4d55cf934b51a2336c5051734
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mediactrl.h
3 // Purpose: wxMediaCtrl class
4 // Author: Ryan Norton <wxprojects@comcast.net>
8 // Copyright: (c) Ryan Norton
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
19 #ifndef _WX_MEDIACTRL_H_
20 #define _WX_MEDIACTRL_H_
22 // ----------------------------------------------------------------------------
23 // Pre-compiled header stuff
24 // ----------------------------------------------------------------------------
25 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
26 #pragma interface "mediactrl.h"
29 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 // ----------------------------------------------------------------------------
38 #include "wx/control.h"
41 // ============================================================================
43 // ============================================================================
45 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
58 enum wxMediaTimeFormat
60 wxMEDIATIMEFORMAT_TIME
63 #define wxMEDIABACKEND_DIRECTSHOW wxT("wxAMMediaBackend")
64 #define wxMEDIABACKEND_MCI wxT("wxMCIMediaBackend")
65 #define wxMEDIABACKEND_QUICKTIME wxT("wxQTMediaBackend")
67 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 class wxMediaCtrl
: public wxControl
76 wxMediaCtrl() : m_imp(NULL
), m_bLoaded(false), m_bLoop(false)
79 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
80 const wxString
& fileName
= wxT(""),
81 const wxPoint
& pos
= wxDefaultPosition
,
82 const wxSize
& size
= wxDefaultSize
,
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
); }
91 wxMediaCtrl(wxWindow
* parent
, wxWindowID id
,
92 const wxURI
& location
,
93 const wxPoint
& pos
= wxDefaultPosition
,
94 const wxSize
& size
= wxDefaultSize
,
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
); }
105 bool Create(wxWindow
* parent
, wxWindowID id
,
106 const wxString
& fileName
= wxT(""),
107 const wxPoint
& pos
= wxDefaultPosition
,
108 const wxSize
& size
= wxDefaultSize
,
110 const wxString
& szBackend
= wxT(""),
111 const wxValidator
& validator
= wxDefaultValidator
,
112 const wxString
& name
= wxT("mediaCtrl"));
114 bool Create(wxWindow
* parent
, wxWindowID id
,
115 const wxURI
& location
,
116 const wxPoint
& pos
= wxDefaultPosition
,
117 const wxSize
& size
= wxDefaultSize
,
119 const wxString
& szBackend
= wxT(""),
120 const wxValidator
& validator
= wxDefaultValidator
,
121 const wxString
& name
= wxT("mediaCtrl"));
123 bool DoCreate(wxClassInfo
* instance
,
124 wxWindow
* parent
, wxWindowID id
,
125 const wxPoint
& pos
= wxDefaultPosition
,
126 const wxSize
& size
= wxDefaultSize
,
128 const wxValidator
& validator
= wxDefaultValidator
,
129 const wxString
& name
= wxT("mediaCtrl"));
131 static wxClassInfo
* NextBackend();
138 bool Load(const wxString
& fileName
);
139 bool Load(const wxURI
& location
);
141 void Loop(bool bLoop
= true);
144 wxMediaState
GetState();
146 double GetPlaybackRate();
147 bool SetPlaybackRate(double dRate
);
149 bool SetPosition(wxLongLong where
);
150 wxLongLong
GetPosition();
151 wxLongLong
GetDuration();
154 void OnMediaFinished(const class wxMediaEvent
& evt
);
155 virtual void DoMoveWindow(int x
, int y
, int w
, int h
);
156 wxSize
DoGetBestSize() const;
158 class wxMediaBackend
* m_imp
;
162 DECLARE_DYNAMIC_CLASS(wxMediaCtrl
);
165 // ----------------------------------------------------------------------------
169 // Currently an internal class - API stability not gauranteed.
171 // ----------------------------------------------------------------------------
173 class wxMediaBackend
: public wxObject
179 virtual ~wxMediaBackend();
181 virtual bool CreateControl(wxControl
* ctrl
, wxWindow
* parent
,
183 const wxPoint
& pos
, const wxSize
& size
,
185 const wxValidator
& validator
,
186 const wxString
& name
)
196 virtual bool Load(const wxString
& WXUNUSED(fileName
))
198 virtual bool Load(const wxURI
& WXUNUSED(location
))
201 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
203 virtual wxLongLong
GetPosition()
205 virtual wxLongLong
GetDuration()
208 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
209 int WXUNUSED(w
), int WXUNUSED(h
))
211 virtual wxSize
GetVideoSize() const
212 { return wxSize(0,0); }
214 virtual double GetPlaybackRate()
216 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
219 virtual wxMediaState
GetState()
220 { return wxMEDIASTATE_STOPPED
; }
222 DECLARE_CLASS(wxMediaBackend
)
225 // ----------------------------------------------------------------------------
229 // ----------------------------------------------------------------------------
231 class WXDLLEXPORT wxMediaEvent
: public wxNotifyEvent
234 // ------------------------------------------------------------------------
235 // wxMediaEvent Constructor
237 // Normal constructor, much the same as wxNotifyEvent
238 // ------------------------------------------------------------------------
239 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
240 : wxNotifyEvent(commandType
, id
)
243 // ------------------------------------------------------------------------
244 // wxMediaEvent Copy Constructor
246 // Normal copy constructor, much the same as wxNotifyEvent
247 // ------------------------------------------------------------------------
248 wxMediaEvent(const wxMediaEvent
&clone
)
249 : wxNotifyEvent(clone
)
252 // ------------------------------------------------------------------------
253 // wxMediaEvent::Clone
255 // Allocates a copy of this object.
256 // Required for wxEvtHandler::AddPendingEvent
257 // ------------------------------------------------------------------------
258 virtual wxEvent
*Clone() const
259 { return new wxMediaEvent(*this); }
262 // Put this class on wxWidget's RTTI table
263 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
266 //Event ID to give to our events
267 #define wxMEDIA_FINISHED_ID 13000
268 #define wxMEDIA_STOP_ID 13001
270 //Define our event types - we need to call DEFINE_EVENT_TYPE(EVT) later
271 DECLARE_EVENT_TYPE(wxEVT_MEDIA_FINISHED
, wxMEDIA_FINISHED_ID
)
272 DECLARE_EVENT_TYPE(wxEVT_MEDIA_STOP
, wxMEDIA_STOP_ID
)
274 //Function type(s) our events need
275 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
277 //Macro for usage with message maps
278 #define EVT_MEDIA_FINISHED(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_FINISHED, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
279 #define EVT_MEDIA_STOP(winid, fn) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MEDIA_STOP, winid, wxID_ANY, (wxObjectEventFunction) (wxEventFunction) (wxMediaEventFunction) & fn, (wxObject *) NULL ),
281 // ----------------------------------------------------------------------------
282 // End compilation gaurd
283 // ----------------------------------------------------------------------------
284 #endif // wxUSE_MEDIACTRL
286 // ----------------------------------------------------------------------------
287 // End header guard and header itself
288 // ----------------------------------------------------------------------------
289 #endif // _WX_MEDIACTRL_H_