]> git.sesse.net Git - vlc/blobdiff - activex/viewobject.cpp
Removes trailing spaces. Removes tabs.
[vlc] / activex / viewobject.cpp
index 313139b8aac66d9cd98c8616ec1d388f305073b7..a194ff71af2d77dee01ae2eb815b230b91f85c7b 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * viewobject.cpp: ActiveX control for VLC
  *****************************************************************************
- * Copyright (C) 2005 VideoLAN
+ * Copyright (C) 2005 the VideoLAN team
  *
  * Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
  *
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #include "plugin.h"
 #include "viewobject.h"
 
-#include <iostream>
+#include "utils.h"
 
 using namespace std;
 
@@ -31,25 +31,38 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
         DVTARGETDEVICE *ptd, HDC hicTargetDev, HDC hdcDraw, LPCRECTL lprcBounds,
         LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue)
 {
-    switch( dwAspect )
+    if( dwAspect & DVASPECT_CONTENT )
     {
-        case DVASPECT_CONTENT:
-            if( _p_instance->getVisible() )
-            {
-                RECT bounds;
-                bounds.left   = lprcBounds->left;
-                bounds.top    = lprcBounds->top;
-                bounds.right  = lprcBounds->right;
-                bounds.bottom = lprcBounds->bottom;
-                _p_instance->onPaint(hdcDraw, bounds, bounds);
-            }
-            return S_OK;
-        case DVASPECT_THUMBNAIL:
-            break;
-        case DVASPECT_ICON:
-            break;
-        case DVASPECT_DOCPRINT:
-            break;
+        if( NULL == lprcBounds )
+            return E_INVALIDARG;
+
+        BOOL releaseDC = FALSE;
+        SIZEL size = _p_instance->getExtent();
+
+        if( NULL == ptd )
+        {
+            hicTargetDev = CreateDevDC(NULL);
+            releaseDC = TRUE;
+        }
+        DPFromHimetric(hicTargetDev, (LPPOINT)&size, 1);
+
+        RECTL bounds = { 0L, 0L, size.cx, size.cy };
+
+        int sdc = SaveDC(hdcDraw);
+        SetMapMode(hdcDraw, MM_ANISOTROPIC);
+        SetWindowOrgEx(hdcDraw, 0, 0, NULL);
+        SetWindowExtEx(hdcDraw, size.cx, size.cy, NULL);
+        OffsetViewportOrgEx(hdcDraw, lprcBounds->left, lprcBounds->top, NULL);
+        SetViewportExtEx(hdcDraw, lprcBounds->right-lprcBounds->left,
+                lprcBounds->bottom-lprcBounds->top, NULL);
+
+        _p_instance->onDraw(ptd, hicTargetDev, hdcDraw, &bounds, lprcWBounds);
+        RestoreDC(hdcDraw, sdc);
+
+        if( releaseDC )
+            DeleteDC(hicTargetDev);
+
+        return S_OK;
     }
     return E_NOTIMPL;
 };
@@ -57,28 +70,53 @@ STDMETHODIMP VLCViewObject::Draw(DWORD dwAspect, LONG lindex, PVOID pvAspect,
 STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
         PVOID pvAspect, LPDWORD pdwFreeze)
 {
-    if( NULL != pvAspect )
-        return E_INVALIDARG;
-
-    return OLE_E_BLANK;
+    return E_NOTIMPL;
 };
 
 STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
         LPADVISESINK *ppAdviseSink)
 {
-    return E_NOTIMPL;
+    if( NULL != pdwAspect )
+        *pdwAspect = _dwAspect;
+
+    if( NULL != padvf )
+        *padvf = _advf;
+
+    if( NULL != ppAdviseSink )
+    {
+        *ppAdviseSink = _pAdvSink;
+        if( NULL != _pAdvSink )
+            _pAdvSink->AddRef();
+    }
+
+    return S_OK;
 };
 
-STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex, 
+STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
         PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
 {
-    return E_NOTIMPL;
+    return S_FALSE;
 };
 
 STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
         LPADVISESINK pAdvSink)
 {
-    return OLE_E_ADVISENOTSUPPORTED;
+    if( NULL != pAdvSink )
+        pAdvSink->AddRef();
+
+    if( NULL != _pAdvSink )
+        _pAdvSink->Release();
+
+    _dwAspect = dwAspect;
+    _advf = advf;
+    _pAdvSink = pAdvSink;
+
+    if( (dwAspect & DVASPECT_CONTENT) && (advf & ADVF_PRIMEFIRST) && (NULL != _pAdvSink) )
+    {
+        _pAdvSink->OnViewChange(DVASPECT_CONTENT, -1);
+    }
+
+    return S_OK;
 };
 
 STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
@@ -86,3 +124,16 @@ STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
     return E_NOTIMPL;
 };
 
+STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex,
+        DVTARGETDEVICE *ptd, LPSIZEL lpSizel)
+{
+    if( dwAspect & DVASPECT_CONTENT )
+    {
+        *lpSizel = _p_instance->getExtent();
+        return S_OK;
+    }
+    lpSizel->cx= 0L;
+    lpSizel->cy= 0L;
+    return E_NOTIMPL;
+};
+