00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include "plugin.h"
00024 #include "viewobject.h"
00025
00026 #include "utils.h"
00027
00028 using namespace std;
00029
00030 STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
00031 DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
00032 LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
00033 {
00034 if( dwAspect & DVASPECT_CONTENT )
00035 {
00036 if( NULL == lprcBounds )
00037 return E_INVALIDARG;
00038
00039 BOOL releaseDC = FALSE;
00040 SIZEL size = _p_instance->getExtent();
00041
00042 if( NULL == ptd )
00043 {
00044 hicTargetDev = CreateDevDC(NULL);
00045 releaseDC = TRUE;
00046 }
00047 DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
00048
00049 RECTL bounds = { 0L, 0L, size.cx, size.cy };
00050
00051 int sdc = SaveDC(hdcDraw);
00052 SetMapMode(hdcDraw, MM_ANISOTROPIC);
00053 SetWindowOrgEx(hdcDraw, 0, 0, NULL);
00054 SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
00055 OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
00056 SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
00057 lprcBounds->bottom-lprcBounds->top, NULL);
00058
00059 _p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
00060 RestoreDC(hdcDraw, sdc);
00061
00062 if( releaseDC )
00063 DeleteDC(hicTargetDev);
00064
00065 return S_OK;
00066 }
00067 return E_NOTIMPL;
00068 };
00069
00070 STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
00071 PVOID pvAspect, LPDWORD pdwFreeze)
00072 {
00073 return E_NOTIMPL;
00074 };
00075
00076 STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
00077 LPADVISESINK *ppAdviseSink)
00078 {
00079 if( NULL != pdwAspect )
00080 *pdwAspect = _dwAspect;
00081
00082 if( NULL != padvf )
00083 *padvf = _advf;
00084
00085 if( NULL != ppAdviseSink )
00086 {
00087 *ppAdviseSink = _pAdvSink;
00088 if( NULL != _pAdvSink )
00089 _pAdvSink->AddRef();
00090 }
00091
00092 return S_OK;
00093 };
00094
00095 STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
00096 PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
00097 {
00098 return S_FALSE;
00099 };
00100
00101 STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
00102 LPADVISESINK pAdvSink)
00103 {
00104 if( NULL != pAdvSink )
00105 pAdvSink->AddRef();
00106
00107 if( NULL != _pAdvSink )
00108 _pAdvSink->Release();
00109
00110 _dwAspect = dwAspect;
00111 _advf = advf;
00112 _pAdvSink = pAdvSink;
00113
00114 if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
00115 {
00116 _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
00117 }
00118
00119 return S_OK;
00120 };
00121
00122 STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
00123 {
00124 return E_NOTIMPL;
00125 };
00126
00127 STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
00128 DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
00129 {
00130 if( dwAspect & DVASPECT_CONTENT )
00131 {
00132 *lpSizel = _p_instance->getExtent();
00133 return S_OK;
00134 }
00135 lpSizel->cx= 0L;
00136 lpSizel->cy= 0L;
00137 return E_NOTIMPL;
00138 };
00139