1 /*****************************************************************************
2 * viewobject.cpp: 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 *****************************************************************************/
24 #include "viewobject.h"
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)
34 if( dwAspect & DVASPECT_CONTENT )
36 if( NULL == lprcBounds )
39 BOOL releaseDC = FALSE;
40 SIZEL size = _p_instance->getExtent();
44 hicTargetDev = CreateDevDC(NULL);
47 DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
49 RECTL bounds = { 0L, 0L, size.cx, size.cy };
51 int sdc = SaveDC(hdcDraw);
52 SetMapMode(hdcDraw, MM_ANISOTROPIC);
53 SetWindowOrgEx(hdcDraw, 0, 0, NULL);
54 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
55 OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
56 SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
57 lprcBounds->bottom-lprcBounds->top, NULL);
59 _p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
60 RestoreDC(hdcDraw, sdc);
63 DeleteDC(hicTargetDev);
70 STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
71 PVOID pvAspect, LPDWORD pdwFreeze)
76 STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
77 LPADVISESINK *ppAdviseSink)
79 if( NULL != pdwAspect )
80 *pdwAspect = _dwAspect;
85 if( NULL != ppAdviseSink )
87 *ppAdviseSink = _pAdvSink;
88 if( NULL != _pAdvSink )
95 STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
96 PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
101 STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
102 LPADVISESINK pAdvSink)
104 if( NULL != pAdvSink )
107 if( NULL != _pAdvSink )
108 _pAdvSink->Release();
110 _dwAspect = dwAspect;
112 _pAdvSink = pAdvSink;
114 if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
116 _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
122 STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
127 STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
128 DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
130 if( dwAspect & DVASPECT_CONTENT )
132 *lpSizel = _p_instance->getExtent();