Commit b9057a61 authored by Damien Fouilleul's avatar Damien Fouilleul

- all: intitial offscreen drawing support (mostly for printing)....

- all: intitial offscreen drawing support (mostly for printing). Unfortunately, video output cannot be printed at this stage, and to support it, interfacing with a video filter such as the 'snapshot' filter is required to do a still capture.
parent f6a33c0d
...@@ -32,6 +32,8 @@ SOURCES_activex = \ ...@@ -32,6 +32,8 @@ SOURCES_activex = \
connectioncontainer.h \ connectioncontainer.h \
objectsafety.cpp \ objectsafety.cpp \
objectsafety.h \ objectsafety.h \
viewobject.cpp \
viewobject.h \
vlccontrol.cpp \ vlccontrol.cpp \
vlccontrol.h \ vlccontrol.h \
plugin.cpp \ plugin.cpp \
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "connectioncontainer.h" #include "connectioncontainer.h"
#include "objectsafety.h" #include "objectsafety.h"
#include "vlccontrol.h" #include "vlccontrol.h"
#include "viewobject.h"
#include "utils.h" #include "utils.h"
...@@ -81,8 +82,10 @@ static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam ...@@ -81,8 +82,10 @@ static LRESULT CALLBACK VLCVideoClassWndProc(HWND hWnd, UINT uMsg, WPARAM wParam
RECT pr; RECT pr;
if( GetUpdateRect(hWnd, &pr, FALSE) ) if( GetUpdateRect(hWnd, &pr, FALSE) )
{ {
RECT bounds;
GetClientRect(hWnd, &bounds);
BeginPaint(hWnd, &ps); BeginPaint(hWnd, &ps);
p_instance->onPaint(ps, pr); p_instance->onPaint(ps.hdc, bounds, pr);
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
} }
return 0L; return 0L;
...@@ -246,6 +249,7 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class) : ...@@ -246,6 +249,7 @@ VLCPlugin::VLCPlugin(VLCPluginClass *p_class) :
vlcConnectionPointContainer = new VLCConnectionPointContainer(this); vlcConnectionPointContainer = new VLCConnectionPointContainer(this);
vlcObjectSafety = new VLCObjectSafety(this); vlcObjectSafety = new VLCObjectSafety(this);
vlcControl = new VLCControl(this); vlcControl = new VLCControl(this);
vlcViewObject = new VLCViewObject(this);
}; };
VLCPlugin::~VLCPlugin() VLCPlugin::~VLCPlugin()
...@@ -253,6 +257,7 @@ VLCPlugin::~VLCPlugin() ...@@ -253,6 +257,7 @@ VLCPlugin::~VLCPlugin()
vlcOleInPlaceObject->UIDeactivate(); vlcOleInPlaceObject->UIDeactivate();
vlcOleInPlaceObject->InPlaceDeactivate(); vlcOleInPlaceObject->InPlaceDeactivate();
delete vlcViewObject;
delete vlcControl; delete vlcControl;
delete vlcObjectSafety; delete vlcObjectSafety;
delete vlcConnectionPointContainer; delete vlcConnectionPointContainer;
...@@ -372,6 +377,12 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv) ...@@ -372,6 +377,12 @@ STDMETHODIMP VLCPlugin::QueryInterface(REFIID riid, void **ppv)
*ppv = reinterpret_cast<LPVOID>(vlcControl); *ppv = reinterpret_cast<LPVOID>(vlcControl);
return NOERROR; return NOERROR;
} }
else if( IID_IViewObject == riid )
{
AddRef();
*ppv = reinterpret_cast<LPVOID>(vlcViewObject);
return NOERROR;
}
*ppv = NULL; *ppv = NULL;
...@@ -702,19 +713,19 @@ BOOL VLCPlugin::hasFocus(void) ...@@ -702,19 +713,19 @@ BOOL VLCPlugin::hasFocus(void)
return GetActiveWindow() == _inplacewnd; return GetActiveWindow() == _inplacewnd;
}; };
void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr) void VLCPlugin::onPaint(HDC hdc, const RECT &bounds, const RECT &pr)
{ {
/* /*
** if VLC is playing, it may not display any VIDEO content ** if VLC is playing, it may not display any VIDEO content
** hence, draw control logo ** hence, draw control logo
*/ */
int width = _bounds.right-_bounds.left; int width = bounds.right-bounds.left;
int height = _bounds.bottom-_bounds.top; int height = bounds.bottom-bounds.top;
HBITMAP pict = _p_class->getInPlacePict(); HBITMAP pict = _p_class->getInPlacePict();
if( NULL != pict ) if( NULL != pict )
{ {
HDC hdcPict = CreateCompatibleDC(ps.hdc); HDC hdcPict = CreateCompatibleDC(hdc);
if( NULL != hdcPict ) if( NULL != hdcPict )
{ {
BITMAP bm; BITMAP bm;
...@@ -728,26 +739,26 @@ void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr) ...@@ -728,26 +739,26 @@ void VLCPlugin::onPaint(PAINTSTRUCT &ps, RECT &pr)
if( dstHeight > height-4 ) if( dstHeight > height-4 )
dstHeight = height-4; dstHeight = height-4;
int dstX = (width-dstWidth)/2; int dstX = bounds.left+(width-dstWidth)/2;
int dstY = (height-dstHeight)/2; int dstY = bounds.top+(height-dstHeight)/2;
SelectObject(hdcPict, pict); SelectObject(hdcPict, pict);
StretchBlt(ps.hdc, dstX, dstY, dstWidth, dstHeight, StretchBlt(hdc, dstX, dstY, dstWidth, dstHeight,
hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY); hdcPict, 0, 0, bm.bmWidth, bm.bmHeight, SRCCOPY);
DeleteDC(hdcPict); DeleteDC(hdcPict);
ExcludeClipRect(ps.hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY); ExcludeClipRect(hdc, dstX, dstY, dstWidth+dstX, dstHeight+dstY);
} }
} }
} }
FillRect(ps.hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH)); FillRect(hdc, &pr, (HBRUSH)GetStockObject(WHITE_BRUSH));
SelectObject(ps.hdc, GetStockObject(BLACK_BRUSH)); SelectObject(hdc, GetStockObject(BLACK_BRUSH));
MoveToEx(ps.hdc, 0, 0, NULL); MoveToEx(hdc, bounds.left, bounds.top, NULL);
LineTo(ps.hdc, width-1, 0); LineTo(hdc, bounds.left+width-1, bounds.top);
LineTo(ps.hdc, width-1, height-1); LineTo(hdc, bounds.left+width-1, bounds.top+height-1);
LineTo(ps.hdc, 0, height-1); LineTo(hdc, bounds.left, bounds.top+height-1);
LineTo(ps.hdc, 0, 0); LineTo(hdc, bounds.left, bounds.top);
}; };
void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
......
...@@ -118,7 +118,7 @@ public: ...@@ -118,7 +118,7 @@ public:
// container events // container events
void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect); void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect);
void onPaint(PAINTSTRUCT &ps, RECT &pr); void onPaint(HDC hdc, const RECT &bounds, const RECT &pr);
// control events // control events
void firePropChangedEvent(DISPID dispid); void firePropChangedEvent(DISPID dispid);
...@@ -146,6 +146,7 @@ private: ...@@ -146,6 +146,7 @@ private:
class VLCConnectionPointContainer *vlcConnectionPointContainer; class VLCConnectionPointContainer *vlcConnectionPointContainer;
class VLCObjectSafety *vlcObjectSafety; class VLCObjectSafety *vlcObjectSafety;
class VLCControl *vlcControl; class VLCControl *vlcControl;
class VLCViewObject *vlcViewObject;
// in place activated window (Clipping window) // in place activated window (Clipping window)
HWND _inplacewnd; HWND _inplacewnd;
......
/*****************************************************************************
* viewobject.cpp: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 VideoLAN
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#include "plugin.h"
#include "viewobject.h"
#include <iostream>
using namespace std;
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 )
{
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;
}
return E_NOTIMPL;
};
STDMETHODIMP VLCViewObject::Freeze(DWORD dwAspect, LONG lindex,
PVOID pvAspect, LPDWORD pdwFreeze)
{
if( NULL != pvAspect )
return E_INVALIDARG;
return OLE_E_BLANK;
};
STDMETHODIMP VLCViewObject::GetAdvise(LPDWORD pdwAspect, LPDWORD padvf,
LPADVISESINK *ppAdviseSink)
{
return E_NOTIMPL;
};
STDMETHODIMP VLCViewObject::GetColorSet(DWORD dwAspect, LONG lindex,
PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet)
{
return E_NOTIMPL;
};
STDMETHODIMP VLCViewObject::SetAdvise(DWORD dwAspect, DWORD advf,
LPADVISESINK pAdvSink)
{
return OLE_E_ADVISENOTSUPPORTED;
};
STDMETHODIMP VLCViewObject::Unfreeze(DWORD dwFreeze)
{
return E_NOTIMPL;
};
/*****************************************************************************
* persiststorage.h: ActiveX control for VLC
*****************************************************************************
* Copyright (C) 2005 VideoLAN
*
* Authors: Damien Fouilleul <Damien.Fouilleul@laposte.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.
*****************************************************************************/
#ifndef __VIEWOBJECT_H__
#define __VIEWOBJECT_H__
#include <oleidl.h>
class VLCViewObject : public IViewObject
{
public:
VLCViewObject(VLCPlugin *p_instance) : _p_instance(p_instance) {};
virtual ~VLCViewObject() {};
// IUnknown methods
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)
{
if( (NULL != ppv)
&& (IID_IUnknown == riid)
&& (IID_IPersist == riid)
&& (IID_IViewObject == riid) ) {
AddRef();
*ppv = reinterpret_cast<LPVOID>(this);
return NOERROR;
}
return _p_instance->QueryInterface(riid, ppv);
};
STDMETHODIMP_(ULONG) AddRef(void) { return _p_instance->AddRef(); };
STDMETHODIMP_(ULONG) Release(void) { return _p_instance->Release(); };
// IViewObject methods
STDMETHODIMP Draw(DWORD,LONG,PVOID,DVTARGETDEVICE*,HDC,HDC,LPCRECTL,LPCRECTL,BOOL(CALLBACK *)(DWORD),DWORD);
STDMETHODIMP Freeze(DWORD,LONG,PVOID,LPDWORD);
STDMETHODIMP GetAdvise(LPDWORD,LPDWORD,LPADVISESINK *);
STDMETHODIMP GetColorSet(DWORD,LONG,PVOID,DVTARGETDEVICE *,HDC,LPLOGPALETTE *);
STDMETHODIMP SetAdvise(DWORD,DWORD,LPADVISESINK);
STDMETHODIMP Unfreeze(DWORD);
private:
VLCPlugin *_p_instance;
};
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment