Swedish translation update by Daniel Nylander
[vlc.git] / activex / plugin.h
blobc2612e4879d7da3e9928a4147d2926d034e5f5be
1 /*****************************************************************************
2 * plugin.h: ActiveX control for VLC
3 *****************************************************************************
4 * Copyright (C) 2005 the VideoLAN team
6 * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef __PLUGIN_H__
24 #define __PLUGIN_H__
26 #include <ole2.h>
27 #include <olectl.h>
29 #include <vlc/libvlc.h>
31 extern "C" const GUID CLSID_VLCPlugin;
32 extern "C" const GUID CLSID_VLCPlugin2;
33 extern "C" const GUID LIBID_AXVLC;
34 extern "C" const GUID DIID_DVLCEvents;
36 class VLCPluginClass : public IClassFactory
39 public:
41 VLCPluginClass(LONG *p_class_ref, HINSTANCE hInstance, REFCLSID rclsid);
43 /* IUnknown methods */
44 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
45 STDMETHODIMP_(ULONG) AddRef(void);
46 STDMETHODIMP_(ULONG) Release(void);
48 /* IClassFactory methods */
49 STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
50 STDMETHODIMP LockServer(BOOL fLock);
52 REFCLSID getClassID(void) { return (REFCLSID)_classid; };
54 LPCTSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
55 HINSTANCE getHInstance(void) const { return _hinstance; };
56 LPPICTURE getInPlacePict(void) const
57 { if( NULL != _inplace_picture) _inplace_picture->AddRef(); return _inplace_picture; };
59 protected:
61 virtual ~VLCPluginClass();
63 private:
65 LPLONG _p_class_ref;
66 HINSTANCE _hinstance;
67 CLSID _classid;
68 ATOM _inplace_wndclass_atom;
69 LPPICTURE _inplace_picture;
72 class VLCPlugin : public IUnknown
75 public:
77 VLCPlugin(VLCPluginClass *p_class, LPUNKNOWN pUnkOuter);
79 /* IUnknown methods */
80 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
81 STDMETHODIMP_(ULONG) AddRef(void);
82 STDMETHODIMP_(ULONG) Release(void);
84 /* custom methods */
85 HRESULT getTypeLib(LCID lcid, ITypeLib **pTL) { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
86 REFCLSID getClassID(void) { return _p_class->getClassID(); };
87 REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
90 ** persistant properties
92 void setMRL(BSTR mrl)
94 SysFreeString(_bstr_mrl);
95 _bstr_mrl = SysAllocStringLen(mrl, SysStringLen(mrl));
96 setDirty(TRUE);
98 const BSTR getMRL(void) { return _bstr_mrl; };
100 inline void setAutoPlay(BOOL autoplay)
102 _b_autoplay = autoplay;
103 setDirty(TRUE);
105 inline BOOL getAutoPlay(void) { return _b_autoplay; };
107 inline void setAutoLoop(BOOL autoloop)
109 _b_autoloop = autoloop;
110 setDirty(TRUE);
112 inline BOOL getAutoLoop(void) { return _b_autoloop;};
114 void setVolume(int volume);
115 int getVolume(void) { return _i_volume; };
117 void setBackColor(OLE_COLOR backcolor);
118 OLE_COLOR getBackColor(void) { return _i_backcolor; };
120 void setVisible(BOOL fVisible);
121 BOOL getVisible(void) { return _b_visible; };
122 BOOL isVisible(void) { return _b_visible || (! _b_usermode); };
124 inline void setStartTime(int time)
126 _i_time = time;
127 setDirty(TRUE);
129 inline int getStartTime(void) { return _i_time; };
131 void setTime(int time);
132 int getTime(void) { return _i_time; };
134 void setBaseURL(BSTR url)
136 SysFreeString(_bstr_baseurl);
137 _bstr_baseurl = SysAllocStringLen(url, SysStringLen(url));
138 setDirty(TRUE);
140 const BSTR getBaseURL(void) { return _bstr_baseurl; };
142 // control size in HIMETRIC
143 inline void setExtent(const SIZEL& extent)
145 _extent = extent;
146 setDirty(TRUE);
148 const SIZEL& getExtent(void) { return _extent; };
150 // transient properties
151 inline void setMute(BOOL mute) { _b_mute = mute; };
153 inline void setPicture(LPPICTURE pict)
155 if( NULL != _p_pict )
156 _p_pict->Release();
157 if( NULL != pict )
158 _p_pict->AddRef();
159 _p_pict = pict;
162 inline LPPICTURE getPicture(void)
164 if( NULL != _p_pict )
165 _p_pict->AddRef();
166 return _p_pict;
169 BOOL hasFocus(void);
170 void setFocus(BOOL fFocus);
172 inline UINT getCodePage(void) { return _i_codepage; };
173 inline void setCodePage(UINT cp)
175 // accept new codepage only if it works on this system
176 size_t mblen = WideCharToMultiByte(cp,
177 0, L"test", -1, NULL, 0, NULL, NULL);
178 if( mblen > 0 )
179 _i_codepage = cp;
182 inline BOOL isUserMode(void) { return _b_usermode; };
183 inline void setUserMode(BOOL um) { _b_usermode = um; };
185 inline BOOL isDirty(void) { return _b_dirty; };
186 inline void setDirty(BOOL dirty) { _b_dirty = dirty; };
188 inline BOOL isRunning(void) { return NULL != _p_libvlc; };
189 HRESULT getVLCObject(int *i_vlc);
190 HRESULT getVLC(libvlc_instance_t** p_vlc);
191 void setErrorInfo(REFIID riid, const char *description);
193 // control geometry within container
194 RECT getPosRect(void) { return _posRect; };
195 inline HWND getInPlaceWindow(void) const { return _inplacewnd; };
196 BOOL isInPlaceActive(void);
199 ** container events
201 HRESULT onInit(void);
202 HRESULT onLoad(void);
203 HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
204 HRESULT onInPlaceDeactivate(void);
205 HRESULT onAmbientChanged(LPUNKNOWN pContainer, DISPID dispID);
206 HRESULT onClose(DWORD dwSaveOption);
207 void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
208 void onDraw(DVTARGETDEVICE * ptd, HDC hicTargetDev,
209 HDC hdcDraw, LPCRECTL lprcBounds, LPCRECTL lprcWBounds);
210 void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
213 ** control events
215 void freezeEvents(BOOL freeze);
216 void firePropChangedEvent(DISPID dispid);
217 void fireOnPlayEvent(void);
218 void fireOnPauseEvent(void);
219 void fireOnStopEvent(void);
221 // controlling IUnknown interface
222 LPUNKNOWN pUnkOuter;
224 protected:
226 virtual ~VLCPlugin();
228 private:
230 //implemented interfaces
231 class VLCOleObject *vlcOleObject;
232 class VLCOleControl *vlcOleControl;
233 class VLCOleInPlaceObject *vlcOleInPlaceObject;
234 class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
235 class VLCPersistStreamInit *vlcPersistStreamInit;
236 class VLCPersistStorage *vlcPersistStorage;
237 class VLCPersistPropertyBag *vlcPersistPropertyBag;
238 class VLCProvideClassInfo *vlcProvideClassInfo;
239 class VLCConnectionPointContainer *vlcConnectionPointContainer;
240 class VLCObjectSafety *vlcObjectSafety;
241 class VLCControl *vlcControl;
242 class VLCControl2 *vlcControl2;
243 class VLCViewObject *vlcViewObject;
244 class VLCDataObject *vlcDataObject;
245 class VLCSupportErrorInfo *vlcSupportErrorInfo;
247 // in place activated window (Plugin window)
248 HWND _inplacewnd;
250 VLCPluginClass* _p_class;
251 ULONG _i_ref;
253 libvlc_instance_t* _p_libvlc;
254 UINT _i_codepage;
255 BOOL _b_usermode;
256 RECT _posRect;
257 LPPICTURE _p_pict;
259 // persistable properties
260 BSTR _bstr_baseurl;
261 BSTR _bstr_mrl;
262 BOOL _b_autoplay;
263 BOOL _b_autoloop;
264 BOOL _b_visible;
265 BOOL _b_mute;
266 int _i_volume;
267 int _i_time;
268 SIZEL _extent;
269 OLE_COLOR _i_backcolor;
270 // indicates whether properties needs persisting
271 BOOL _b_dirty;
274 #endif