viewobject.cpp
上传用户:kjfoods
上传日期:2020-07-06
资源大小:29949k
文件大小:4k
源码类别:

midi

开发平台:

Unix_Linux

  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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  21.  *****************************************************************************/
  22. #include "plugin.h"
  23. #include "viewobject.h"
  24. #include "utils.h"
  25. using namespace std;
  26. STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
  27.         DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
  28.         LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
  29. {
  30.     if( dwAspect & DVASPECT_CONTENT )
  31.     {
  32.         if( NULL == lprcBounds )
  33.             return E_INVALIDARG;
  34.         BOOL releaseDC = FALSE;
  35.         SIZEL size = _p_instance->getExtent();
  36.         if( NULL == ptd )
  37.         {
  38.             hicTargetDev = CreateDevDC(NULL);
  39.             releaseDC = TRUE;
  40.         }
  41.         DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
  42.         RECTL bounds = { 0L, 0L, size.cx, size.cy };
  43.         int sdc = SaveDC(hdcDraw);
  44.         SetMapMode(hdcDraw, MM_ANISOTROPIC);
  45.         SetWindowOrgEx(hdcDraw, 0, 0, NULL);
  46.         SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
  47.         OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
  48.         SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
  49.                 lprcBounds->bottom-lprcBounds->top, NULL);
  50.         _p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
  51.         RestoreDC(hdcDraw, sdc);
  52.         if( releaseDC )
  53.             DeleteDC(hicTargetDev);
  54.         return S_OK;
  55.     }
  56.     return E_NOTIMPL;
  57. };
  58. STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
  59.         PVOID pvAspect, LPDWORD pdwFreeze)
  60. {
  61.     return E_NOTIMPL;
  62. };
  63. STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
  64.         LPADVISESINK *ppAdviseSink)
  65. {
  66.     if( NULL != pdwAspect )
  67.         *pdwAspect = _dwAspect;
  68.     if( NULL != padvf )
  69.         *padvf = _advf;
  70.     if( NULL != ppAdviseSink )
  71.     {
  72.         *ppAdviseSink = _pAdvSink;
  73.         if( NULL != _pAdvSink )
  74.             _pAdvSink->AddRef();
  75.     }
  76.     return S_OK;
  77. };
  78. STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
  79.         PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
  80. {
  81.     return S_FALSE;
  82. };
  83. STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
  84.         LPADVISESINK pAdvSink)
  85. {
  86.     if( NULL != pAdvSink )
  87.         pAdvSink->AddRef();
  88.     if( NULL != _pAdvSink )
  89.         _pAdvSink->Release();
  90.     _dwAspect = dwAspect;
  91.     _advf = advf;
  92.     _pAdvSink = pAdvSink;
  93.     if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
  94.     {
  95.         _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
  96.     }
  97.     return S_OK;
  98. };
  99. STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
  100. {
  101.     return E_NOTIMPL;
  102. };
  103. STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
  104.         DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
  105. {
  106.     if( dwAspect & DVASPECT_CONTENT )
  107.     {
  108.         *lpSizel = _p_instance->getExtent();
  109.         return S_OK;
  110.     }
  111.     lpSizel->cx= 0L;
  112.     lpSizel->cy= 0L;
  113.     return E_NOTIMPL;
  114. };