]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mediactrl.h
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
* 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
))
198 virtual bool Load(const wxString
& WXUNUSED(fileName
))
200 virtual bool Load(const wxURI
& WXUNUSED(location
))
203 virtual bool SetPosition(wxLongLong
WXUNUSED(where
))
205 virtual wxLongLong
GetPosition()
207 virtual wxLongLong
GetDuration()
210 virtual void Move(int WXUNUSED(x
), int WXUNUSED(y
),
211 int WXUNUSED(w
), int WXUNUSED(h
))
213 virtual wxSize
GetVideoSize() const
214 { return wxSize(0,0); }
216 virtual double GetPlaybackRate()
218 virtual bool SetPlaybackRate(double WXUNUSED(dRate
))
221 virtual wxMediaState
GetState()
222 { return wxMEDIASTATE_STOPPED
; }
224 DECLARE_CLASS(wxMediaBackend
)
227 // ----------------------------------------------------------------------------
231 // ----------------------------------------------------------------------------
233 class WXDLLEXPORT wxMediaEvent
: public wxNotifyEvent
236 // ------------------------------------------------------------------------
237 // wxMediaEvent Constructor
239 // Normal constructor, much the same as wxNotifyEvent
240 // ------------------------------------------------------------------------
241 wxMediaEvent(wxEventType commandType
= wxEVT_NULL
, int id
= 0)
242 : wxNotifyEvent(commandType
, id
)
245 // ------------------------------------------------------------------------
246 // wxMediaEvent Copy Constructor
248 // Normal copy constructor, much the same as wxNotifyEvent
249 // ------------------------------------------------------------------------
250 wxMediaEvent(const wxMediaEvent
&clone
)
251 : wxNotifyEvent(clone
)
254 // ------------------------------------------------------------------------
255 // wxMediaEvent::Clone
257 // Allocates a copy of this object.
258 // Required for wxEvtHandler::AddPendingEvent
259 // ------------------------------------------------------------------------
260 virtual wxEvent
*Clone() const
261 { return new wxMediaEvent(*this); }
264 // Put this class on wxWidget's RTTI table
265 DECLARE_DYNAMIC_CLASS(wxMediaEvent
)
268 //Event ID to give to our events
269 #define wxMEDIA_FINISHED_ID 13000
270 #define wxMEDIA_STOP_ID 13001
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
)
276 //Function type(s) our events need
277 typedef void (wxEvtHandler::*wxMediaEventFunction
)(wxMediaEvent
&);
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 ),
283 // ----------------------------------------------------------------------------
284 // End compilation gaurd
285 // ----------------------------------------------------------------------------
286 #endif // wxUSE_MEDIACTRL
288 // ----------------------------------------------------------------------------
289 // End header guard and header itself
290 // ----------------------------------------------------------------------------
291 #endif // _WX_MEDIACTRL_H_