]> git.sesse.net Git - vlc/blob - activex/viewobject.cpp
Make Zorglub less unhappy
[vlc] / activex / viewobject.cpp
1 /*****************************************************************************
2  * viewobject.cpp: ActiveX control for VLC
3  *****************************************************************************
4  * Copyright (C) 2005 the VideoLAN team
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 #include "plugin.h"
24 #include "viewobject.h"
25
26 #include "utils.h"
27
28 using namespace std;
29
30 STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
31         DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
32         LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
33 {
34     if( dwAspect & DVASPECT_CONTENT )
35     {
36         RECT bounds;
37         bounds.left   = lprcBounds->left;
38         bounds.top    = lprcBounds->top;
39         bounds.right  = lprcBounds->right;
40         bounds.bottom = lprcBounds->bottom;
41         _p_instance->onPaint(hdcDraw, bounds, bounds);
42         return S_OK;
43     }
44     return E_NOTIMPL;
45 };
46
47 STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
48         PVOID pvAspect, LPDWORD pdwFreeze)
49 {
50     if( NULL != pvAspect )
51         return E_INVALIDARG;
52
53     return E_NOTIMPL;
54 };
55
56 STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
57         LPADVISESINK *ppAdviseSink)
58 {
59     if( NULL != pdwAspect )
60         *pdwAspect = _dwAspect;
61
62     if( NULL != padvf )
63         *padvf = _advf;
64
65     if( NULL != ppAdviseSink )
66     {
67         *ppAdviseSink = _pAdvSink;
68         if( NULL != _pAdvSink )
69             _pAdvSink->AddRef();
70     }
71
72     return S_OK;
73 };
74
75 STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex, 
76         PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
77 {
78     return S_FALSE;
79 };
80
81 STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
82         LPADVISESINK pAdvSink)
83 {
84
85     if( NULL != pAdvSink )
86         pAdvSink->AddRef();
87
88     if( NULL != _pAdvSink )
89         _pAdvSink->Release();
90
91     _dwAspect = dwAspect;
92     _advf = advf;
93     _pAdvSink = pAdvSink;
94
95     if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
96     {
97         _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
98     }
99
100     return S_OK;
101 };
102
103 STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
104 {
105     return E_NOTIMPL;
106 };
107
108 STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
109         DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
110 {
111     if( dwAspect & DVASPECT_CONTENT )
112     {
113         *lpSizel = _p_instance->getExtent();
114         return S_OK;
115     }
116     lpSizel->cx= 0L;
117     lpSizel->cy= 0L;
118     return E_NOTIMPL;
119 };
120