]> git.sesse.net Git - vlc/blob - activex/plugin.h
Avoid \r\n problems between platforms
[vlc] / activex / plugin.h
1 /*****************************************************************************
2  * plugin.h: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 VideoLAN
5  *
6  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
7  *
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.
12  *
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.
17  *
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
21  *****************************************************************************/
22
23 #ifndef __PLUGIN_H__
24 #define __PLUGIN_H__
25
26 #include <ole2.h>
27 #include <olectl.h>
28
29 #include <vlc/vlc.h>
30
31 extern const GUID CLSID_VLCPlugin; 
32 extern const GUID LIBID_AXVLC; 
33 extern const GUID DIID_DVLCEvents; 
34
35 class VLCPluginClass : public IClassFactory
36 {
37
38 public:
39
40     VLCPluginClass(LONG *p_class_ref,HINSTANCE hInstance);
41
42     /* IUnknown methods */
43     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
44     STDMETHODIMP_(ULONG) AddRef(void);
45     STDMETHODIMP_(ULONG) Release(void);
46
47     /* IClassFactory methods */
48     STDMETHODIMP CreateInstance(IUnknown *pUnkOuter, REFIID riid, void **ppv);
49     STDMETHODIMP LockServer(BOOL fLock);
50
51     LPCSTR getInPlaceWndClassName(void) const { return TEXT("VLC Plugin In-Place"); };
52     LPCSTR getVideoWndClassName(void) const { return TEXT("VLC Plugin Video"); };
53     HINSTANCE getHInstance(void) const { return _hinstance; };
54     HBITMAP getInPlacePict(void) const { return _inplace_hbitmap; };
55
56 protected:
57
58     virtual ~VLCPluginClass();
59
60 private:
61
62     LPLONG      _p_class_ref;
63     HINSTANCE   _hinstance;
64     ATOM        _inplace_wndclass_atom;
65     ATOM        _video_wndclass_atom;
66     HBITMAP     _inplace_hbitmap;
67 };
68
69 class VLCPlugin : public IUnknown
70 {
71
72 public:
73
74     VLCPlugin(VLCPluginClass *p_class);
75
76     /* IUnknown methods */
77     STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
78     STDMETHODIMP_(ULONG) AddRef(void);
79     STDMETHODIMP_(ULONG) Release(void);
80
81     /* custom methods */
82     HRESULT getTypeLib(LCID lcid, ITypeLib **pTL)
83         { return LoadRegTypeLib(LIBID_AXVLC, 1, 0, lcid, pTL); };
84     REFCLSID getClassID(void) { return (REFCLSID)CLSID_VLCPlugin; };
85     REFIID getDispEventID(void) { return (REFIID)DIID_DVLCEvents; };
86
87     HRESULT onInitNew(void);
88     HRESULT onClose(DWORD dwSaveOption);
89
90     BOOL isInPlaceActive(void);
91     HRESULT onActivateInPlace(LPMSG lpMesg, HWND hwndParent, LPCRECT lprcPosRect, LPCRECT lprcClipRect);
92     HRESULT onInPlaceDeactivate(void);
93     HWND getInPlaceWindow(void) const { return _inplacewnd; };
94
95     BOOL hasFocus(void);
96     void setFocus(BOOL fFocus);
97
98     UINT getCodePage(void) { return _codepage; };
99     void setCodePage(UINT cp) { _codepage = cp; };
100
101     int  getVLCObject(void) { return _i_vlc; };
102
103     // control properties
104     void setSourceURL(const char *url) { _psz_src = strdup(url); };
105     void setAutoStart(BOOL autostart) { _b_autostart = autostart; };
106     void setLoopMode(BOOL loopmode) { _b_loopmode = loopmode; };
107     void setMute(BOOL mute) {
108         if( mute && _i_vlc )
109         {
110             VLC_VolumeMute(_i_vlc);
111         }
112     };
113     void setSendEvents(BOOL sendevents) { _b_sendevents = sendevents; };
114     void setVisible(BOOL fVisible);
115     BOOL getVisible(void) { return _b_visible; };
116
117     // container events
118     void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
119     void onPaint(PAINTSTRUCT &ps, RECT &pr);
120
121     // control events
122     void firePropChangedEvent(DISPID dispid);
123     void fireOnPlayEvent(void);
124     void fireOnPauseEvent(void);
125     void fireOnStopEvent(void);
126
127 protected:
128
129     virtual ~VLCPlugin();
130
131 private:
132
133     void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect);
134
135     //implemented interfaces
136     class VLCOleObject *vlcOleObject;
137     class VLCOleControl *vlcOleControl;
138     class VLCOleInPlaceObject *vlcOleInPlaceObject;
139     class VLCOleInPlaceActiveObject *vlcOleInPlaceActiveObject;
140     class VLCPersistStreamInit *vlcPersistStreamInit;
141     class VLCPersistStorage *vlcPersistStorage;
142     class VLCPersistPropertyBag *vlcPersistPropertyBag;
143     class VLCProvideClassInfo *vlcProvideClassInfo;
144     class VLCConnectionPointContainer *vlcConnectionPointContainer;
145     class VLCObjectSafety *vlcObjectSafety;
146     class VLCControl *vlcControl;
147
148     // in place activated window (Clipping window)
149     HWND _inplacewnd;
150     // video window (Drawing window)
151     HWND _videownd;
152     RECT _bounds;
153
154     VLCPluginClass *_p_class;
155     ULONG _i_ref;
156
157     UINT _codepage;
158     char *_psz_src;
159     BOOL _b_autostart;
160     BOOL _b_loopmode;
161     BOOL _b_visible;
162     BOOL _b_sendevents;
163     int _i_vlc;
164 };
165
166 #endif
167