Changeset 1b75d79ed2680352f5ed1f67d57e9c205dd73162

Show
Ignore:
Timestamp:
04/18/05 13:35:18 (3 years ago)
Author:
Damien Fouilleul <damienf@videolan.org>
git-committer:
Damien Fouilleul <damienf@videolan.org> 1113824118 +0000
git-parent:

[ad67acad03c34bf97e9815c476fc1071902ea633]

git-author:
Damien Fouilleul <damienf@videolan.org> 1113824118 +0000
Message:

- source cleanup
- few bugs fixed
- added suport to Ole Extent measurments to improve compatibilty

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • AUTHORS

    ra6cb895 r1b75d79  
    344344S: France 
    345345 
     346N: Damien Fouilleul 
     347E: Damien.Fouilleul@laposte.net 
     348C: Quovodis 
     349D: ActiveX control 
     350S: Germany 
     351 
  • activex/README.TXT

    r18631b5 r1b75d79  
    6868InstallDir="C:\Program Files\VideoLAN\VLC" 
    6969 
    70 The InstallDir must contain the 'plugins' directory. 
     70The InstallDir must be the parent directory of the 'plugins' directory. 
    7171 
    7272WARNING: Both control and plugins must come from the same build source tree. 
  • activex/oleobject.cpp

    r1591dec r1b75d79  
    226226STDMETHODIMP VLCOleObject::GetExtent(DWORD dwDrawAspect, SIZEL *pSizel) 
    227227{ 
     228    if( NULL == pSizel ) 
     229        return E_POINTER; 
     230 
     231    if( dwDrawAspect & DVASPECT_CONTENT ) 
     232    { 
     233        *pSizel = _p_instance->getExtent(); 
     234        return S_OK; 
     235    } 
     236    pSizel->cx= 0L; 
     237    pSizel->cy= 0L; 
    228238    return E_NOTIMPL; 
    229239}; 
     
    315325STDMETHODIMP VLCOleObject::SetExtent(DWORD dwDrawAspect, SIZEL *pSizel) 
    316326{ 
     327    if( NULL == pSizel ) 
     328        return E_POINTER; 
     329 
     330    if( dwDrawAspect & DVASPECT_CONTENT ) 
     331    { 
     332        _p_instance->setExtent(*pSizel); 
     333 
     334        if( _p_instance->isInPlaceActive() ) 
     335        { 
     336            LPOLEINPLACESITE p_inPlaceSite; 
     337 
     338            if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleInPlaceSite, (void**)&p_inPlaceSite)) ) 
     339            { 
     340                LPOLECONTROLSITE p_controlSite; 
     341                RECT posRect = _p_instance->getPosRect(); 
     342 
     343                if( SUCCEEDED(_p_clientsite->QueryInterface(IID_IOleControlSite, (void**)&p_controlSite)) ) 
     344                { 
     345                    // use HIMETRIC to container transform 
     346                    POINTL extent = { pSizel->cx, pSizel->cy }; 
     347                    POINTF container; 
     348                    if( SUCCEEDED(p_controlSite->TransformCoords(&extent, 
     349                                    &container, XFORMCOORDS_SIZE|XFORMCOORDS_HIMETRICTOCONTAINER)) ) 
     350                    { 
     351                        posRect.right  = ((LONG)container.x)+posRect.left; 
     352                        posRect.bottom = ((LONG)container.y)+posRect.top; 
     353                    } 
     354                    p_controlSite->Release(); 
     355                } 
     356                else { 
     357                    // use HIMETRIC to display transform  
     358                    HDC hDC = CreateDevDC(NULL); 
     359                    posRect.right = (pSizel->cx*GetDeviceCaps(hDC, LOGPIXELSX)/2540L)+posRect.left; 
     360                    posRect.bottom = (pSizel->cy*GetDeviceCaps(hDC, LOGPIXELSY)/2540L)+posRect.top; 
     361                    DeleteDC(hDC); 
     362                } 
     363                p_inPlaceSite->OnPosRectChange(&posRect); 
     364                p_inPlaceSite->Release(); 
     365            } 
     366        } 
     367        return S_OK; 
     368    } 
    317369    return E_NOTIMPL; 
    318370}; 
  • activex/persistpropbag.cpp

    r1591dec r1b75d79  
    117117}; 
    118118 
    119 STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDiry, BOOL fSaveAllProperties) 
     119STDMETHODIMP VLCPersistPropertyBag::Save(LPPROPERTYBAG pPropBag, BOOL fClearDirty, BOOL fSaveAllProperties) 
    120120{ 
    121121    if( NULL == pPropBag ) 
  • activex/plugin.cpp

    rb9057a6 r1b75d79  
    251251    vlcControl = new VLCControl(this); 
    252252    vlcViewObject = new VLCViewObject(this); 
     253 
     254    // set default/preferred size (320x240) pixels in HIMETRIC 
     255    HDC hDC = CreateDevDC(NULL); 
     256    _extent.cx = (320*2540L)/GetDeviceCaps(hDC, LOGPIXELSX); 
     257    _extent.cy = (240*2540L)/GetDeviceCaps(hDC, LOGPIXELSY); 
     258    DeleteDC(hDC); 
    253259}; 
    254260 
     
    384390        return NOERROR; 
    385391    } 
     392    else if( IID_IViewObject2 == riid ) 
     393    { 
     394        AddRef(); 
     395        *ppv = reinterpret_cast<LPVOID>(vlcViewObject); 
     396        return NOERROR; 
     397    } 
    386398 
    387399    *ppv = NULL; 
     
    408420 
    409421/* 
    410 ** we use an in-place child window to represent plugin viewport, 
    411 ** whose size is limited by the clipping rectangle 
    412 ** all drawing within this window must follow  
    413 ** cartesian coordinate system represented by _bounds. 
     422** we use a window to represent plugin viewport, 
     423** whose geometry is limited by the clipping rectangle 
     424** all drawing within this window must follow must 
     425** follow coordinates system described in lprPosRect 
    414426*/ 
    415427 
    416 void VLCPlugin::calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect) 
    417 
    418     _bounds.right  = lprPosRect->right-lprPosRect->left; 
    419  
    420     if( lprcClipRect->left <= lprPosRect->left ) 
     428static void getViewportCoords(LPRECT lprPosRect, LPRECT lprClipRect) 
     429
     430    RECT bounds; 
     431    bounds.right  = lprPosRect->right-lprPosRect->left; 
     432 
     433    if( lprClipRect->left <= lprPosRect->left ) 
    421434    { 
    422435        // left side is not clipped out 
    423         _bounds.left = 0; 
    424  
    425         if( lprcClipRect->right >= lprPosRect->right ) 
     436        bounds.left = 0; 
     437 
     438        if( lprClipRect->right >= lprPosRect->right ) 
    426439        { 
    427440            // right side is not clipped out, no change 
    428441        } 
    429         else if( lprcClipRect->right >= lprPosRect->left ) 
     442        else if( lprClipRect->right >= lprPosRect->left ) 
    430443        { 
    431444            // right side is clipped out 
    432             lprPosRect->right = lprcClipRect->right; 
     445            lprPosRect->right = lprClipRect->right; 
    433446        } 
    434447        else 
     
    441454    { 
    442455        // left side is clipped out 
    443         _bounds.left = lprPosRect->left-lprcClipRect->left; 
    444         _bounds.right += _bounds.left; 
    445  
    446         lprPosRect->left = lprcClipRect->left; 
    447         if( lprcClipRect->right >= lprPosRect->right ) 
     456        bounds.left = lprPosRect->left-lprClipRect->left; 
     457        bounds.right += bounds.left; 
     458 
     459        lprPosRect->left = lprClipRect->left; 
     460        if( lprClipRect->right >= lprPosRect->right ) 
    448461        { 
    449462            // right side is not clipped out 
     
    452465        { 
    453466            // right side is clipped out 
    454             lprPosRect->right = lprcClipRect->right; 
    455         } 
    456     } 
    457  
    458     _bounds.bottom = lprPosRect->bottom-lprPosRect->top; 
    459  
    460     if( lprcClipRect->top <= lprPosRect->top ) 
     467            lprPosRect->right = lprClipRect->right; 
     468        } 
     469    } 
     470 
     471    bounds.bottom = lprPosRect->bottom-lprPosRect->top; 
     472 
     473    if( lprClipRect->top <= lprPosRect->top ) 
    461474    { 
    462475        // top side is not clipped out 
    463         _bounds.top = 0; 
    464  
    465         if( lprcClipRect->bottom >= lprPosRect->bottom ) 
     476        bounds.top = 0; 
     477 
     478        if( lprClipRect->bottom >= lprPosRect->bottom ) 
    466479        { 
    467480            // bottom side is not clipped out, no change 
    468481        } 
    469         else if( lprcClipRect->bottom >= lprPosRect->top ) 
     482        else if( lprClipRect->bottom >= lprPosRect->top ) 
    470483        { 
    471484            // bottom side is clipped out 
    472             lprPosRect->bottom = lprcClipRect->bottom; 
     485            lprPosRect->bottom = lprClipRect->bottom; 
    473486        } 
    474487        else 
     
    480493    else 
    481494    { 
    482         _bounds.top = lprPosRect->top-lprcClipRect->top; 
    483         _bounds.bottom += _bounds.top; 
    484  
    485         lprPosRect->top = lprcClipRect->top; 
    486         if( lprcClipRect->bottom >= lprPosRect->bottom ) 
     495        bounds.top = lprPosRect->top-lprClipRect->top; 
     496        bounds.bottom += bounds.top; 
     497 
     498        lprPosRect->top = lprClipRect->top; 
     499        if( lprClipRect->bottom >= lprPosRect->bottom ) 
    487500        { 
    488501            // bottom side is not clipped out 
     
    491504        { 
    492505            // bottom side is clipped out 
    493             lprPosRect->bottom = lprcClipRect->bottom; 
    494         } 
    495     } 
     506            lprPosRect->bottom = lprClipRect->bottom; 
     507        } 
     508    } 
     509    *lprClipRect = *lprPosRect; 
     510    *lprPosRect  = bounds; 
    496511}; 
    497512 
     
    523538        } 
    524539 
    525 #if 0 
     540#if 1 
    526541        ppsz_argv[0] = "C:\\cygwin\\home\\Damien_Fouilleul\\dev\\videolan\\vlc-trunk\\vlc"; 
    527542#endif 
     
    611626{ 
    612627    RECT posRect = *lprcPosRect; 
    613  
    614     calcPositionChange(&posRect, lprcClipRect); 
    615  
     628    RECT clipRect = *lprcClipRect; 
     629 
     630    /* 
     631    ** record keeping of control geometry within container 
     632    */  
     633    _posRect = posRect; 
     634 
     635    /* 
     636    ** convert posRect & clipRect to match control viewport coordinates 
     637    */ 
     638    getViewportCoords(&posRect, &clipRect); 
     639 
     640    /* 
     641    ** Create a window for in place activated control. 
     642    ** the window geometry represents the control viewport 
     643    ** so that embedded video is always properly clipped. 
     644    */ 
    616645    _inplacewnd = CreateWindow(_p_class->getInPlaceWndClassName(), 
    617646            "VLC Plugin In-Place Window", 
    618647            WS_CHILD|WS_CLIPCHILDREN|WS_TABSTOP, 
    619             posRect.left, 
    620             posRect.top, 
    621             posRect.right-posRect.left, 
    622             posRect.bottom-posRect.top, 
     648            clipRect.left, 
     649            clipRect.top, 
     650            clipRect.right-clipRect.left, 
     651            clipRect.bottom-clipRect.top, 
    623652            hwndParent, 
    624653            0, 
     
    632661    SetWindowLongPtr(_inplacewnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); 
    633662 
     663    /* 
     664    ** VLC embedded video geometry automatically matches parent window. 
     665    ** hence create a child window so that video position and size 
     666    ** is always correct relative to the viewport bounds 
     667    */ 
    634668    _videownd = CreateWindow(_p_class->getVideoWndClassName(), 
    635669            "VLC Plugin Video Window", 
    636670            WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE, 
    637             _bounds.left, 
    638             _bounds.top, 
    639             _bounds.right-_bounds.left, 
    640             _bounds.bottom-_bounds.top, 
     671            posRect.left, 
     672            posRect.top, 
     673            posRect.right-posRect.left, 
     674            posRect.bottom-posRect.top, 
    641675            _inplacewnd, 
    642676            0, 
     
    764798void VLCPlugin::onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect) 
    765799{ 
    766     RECT posRect = *lprcPosRect; 
    767  
    768     calcPositionChange(&posRect, lprcClipRect); 
     800    RECT clipRect = *lprcClipRect; 
     801    RECT posRect  = *lprcPosRect; 
     802 
     803    /* 
     804    ** record keeping of control geometry within container 
     805    */  
     806    _posRect = posRect; 
     807 
     808    /* 
     809    ** convert posRect & clipRect to match control viewport coordinates 
     810    */ 
     811    getViewportCoords(&posRect, &clipRect); 
    769812 
    770813    /* 
     
    772815    */ 
    773816    MoveWindow(_inplacewnd, 
     817            clipRect.left, 
     818            clipRect.top, 
     819            clipRect.right-clipRect.left, 
     820            clipRect.bottom-clipRect.top, 
     821            FALSE); 
     822 
     823    /* 
     824    ** change video window geometry to match object bounds within clipping region 
     825    */ 
     826    MoveWindow(_videownd, 
    774827            posRect.left, 
    775828            posRect.top, 
     
    778831            FALSE); 
    779832 
    780     /* 
    781     ** change video window geometry to match object bounds within clipping region 
     833 
     834    /* 
     835    ** force a full refresh of control content 
    782836    */ 
    783     MoveWindow(_videownd, 
    784             _bounds.left, 
    785             _bounds.top, 
    786             _bounds.right-_bounds.left, 
    787             _bounds.bottom-_bounds.top, 
    788             FALSE); 
    789  
    790837    RECT updateRect; 
    791  
    792     updateRect.left = -_bounds.left; 
    793     updateRect.top = -_bounds.top; 
    794     updateRect.right = _bounds.right-_bounds.left; 
    795     updateRect.bottom = _bounds.bottom-_bounds.top; 
     838    updateRect.left = -posRect.left; 
     839    updateRect.top = -posRect.top; 
     840    updateRect.right = posRect.right-posRect.left; 
     841    updateRect.bottom = posRect.bottom-posRect.top; 
    796842 
    797843    ValidateRect(_videownd, NULL); 
  • activex/plugin.h

    rb9057a6 r1b75d79  
    117117    BOOL getVisible(void) { return _b_visible; }; 
    118118 
     119     
    119120    // container events 
    120121    void onPositionChange(LPCRECT lprcPosRect, LPCRECT lprcClipRect); 
     
    127128    void fireOnStopEvent(void); 
    128129 
     130    // control size in HIMETRIC 
     131    const SIZEL& getExtent(void) { return _extent; }; 
     132    void  setExtent(const SIZEL& extent) { _extent = extent; }; 
     133 
     134    // control geometry within container 
     135    RECT getPosRect(void) { return _posRect; };  
     136 
    129137protected: 
    130138 
     
    132140 
    133141private: 
    134  
    135     void calcPositionChange(LPRECT lprPosRect, LPCRECT lprcClipRect); 
    136142 
    137143    //implemented interfaces 
     
    153159    // video window (Drawing window) 
    154160    HWND _videownd; 
    155     RECT _bounds; 
    156161 
    157162    VLCPluginClass *_p_class; 
     
    164169    BOOL _b_visible; 
    165170    BOOL _b_sendevents; 
    166     int _i_vlc; 
     171    int  _i_vlc; 
     172 
     173    SIZEL _extent; 
     174    RECT _posRect; 
    167175}; 
    168176 
  • activex/utils.cpp

    r3d831e0 r1b75d79  
    9999}; 
    100100 
     101HDC CreateDevDC(DVTARGETDEVICE *ptd) 
     102{ 
     103    HDC hdc=NULL; 
     104    LPDEVNAMES lpDevNames; 
     105    LPDEVMODE lpDevMode; 
     106    LPTSTR lpszDriverName; 
     107    LPTSTR lpszDeviceName; 
     108    LPTSTR lpszPortName; 
    101109 
     110    if (ptd == NULL) { 
     111        hdc = CreateDC(TEXT("DISPLAY"), NULL, NULL, NULL); 
     112        goto errReturn; 
     113    } 
     114 
     115    lpDevNames = (LPDEVNAMES) ptd; // offset for size field 
     116 
     117    if (ptd->tdExtDevmodeOffset == 0) { 
     118        lpDevMode = NULL; 
     119    }else{ 
     120        lpDevMode  = (LPDEVMODE) ((LPTSTR)ptd + ptd->tdExtDevmodeOffset); 
     121    } 
     122 
     123    lpszDriverName = (LPTSTR) lpDevNames + ptd->tdDriverNameOffset; 
     124    lpszDeviceName = (LPTSTR) lpDevNames + ptd->tdDeviceNameOffset; 
     125    lpszPortName   = (LPTSTR) lpDevNames + ptd->tdPortNameOffset; 
     126 
     127    hdc = CreateDC(lpszDriverName, lpszDeviceName, lpszPortName, lpDevMode); 
     128 
     129errReturn: 
     130    return hdc; 
     131}; 
     132 
     133 
  • activex/utils.h

    r3d831e0 r1b75d79  
    3434// properties 
    3535extern HRESULT GetObjectProperty(LPUNKNOWN object, DISPID dispID, VARIANT& v); 
     36 
     37// properties 
     38extern HDC CreateDevDC(DVTARGETDEVICE *ptd); 
    3639 
    3740// enumeration 
  • activex/viewobject.cpp

    rb9057a6 r1b75d79  
    2424#include "viewobject.h" 
    2525 
    26 #include <iostream> 
     26#include "utils.h" 
    2727 
    2828using namespace std; 
     
    3232        LPCRECTL lprcWBounds, BOOL(CALLBACK *pfnContinue)(DWORD), DWORD dwContinue) 
    3333{ 
    34     switch( dwAspect
     34    if( dwAspect & DVASPECT_CONTENT
    3535    { 
    36         case DVASPECT_CONTENT: 
    37             if( _p_instance->getVisible() ) 
    38             { 
    39                 RECT bounds; 
    40                 bounds.left   = lprcBounds->left; 
    41                 bounds.top    = lprcBounds->top; 
    42                 bounds.right  = lprcBounds->right; 
    43                 bounds.bottom = lprcBounds->bottom; 
    44                 _p_instance->onPaint(hdcDraw, bounds, bounds); 
    45             } 
    46             return S_OK; 
    47         case DVASPECT_THUMBNAIL: 
    48             break; 
    49         case DVASPECT_ICON: 
    50             break; 
    51         case DVASPECT_DOCPRINT: 
    52             break; 
     36        if( _p_instance->getVisible() ) 
     37        { 
     38            RECT bounds; 
     39            bounds.left   = lprcBounds->left; 
     40            bounds.top    = lprcBounds->top; 
     41            bounds.right  = lprcBounds->right; 
     42            bounds.bottom = lprcBounds->bottom; 
     43            _p_instance->onPaint(hdcDraw, bounds, bounds); 
     44        } 
     45        return S_OK; 
    5346    } 
    5447    return E_NOTIMPL; 
     
    6154        return E_INVALIDARG; 
    6255 
    63     return OLE_E_BLANK
     56    return E_NOTIMPL
    6457}; 
    6558 
     
    6760        LPADVISESINK *ppAdviseSink) 
    6861{ 
    69     return E_NOTIMPL; 
     62    if( NULL != pdwAspect ) 
     63        *pdwAspect = 0; 
     64 
     65    if( NULL != padvf ) 
     66        *padvf = 0; 
     67 
     68    if( NULL != ppAdviseSink ) 
     69        *ppAdviseSink = NULL; 
     70 
     71    return S_OK; 
    7072}; 
    7173 
     
    7375        PVOID pvAspect, DVTARGETDEVICE *ptd, HDC hicTargetDev, LPLOGPALETTE *ppColorSet) 
    7476{ 
    75     return E_NOTIMPL
     77    return S_FALSE
    7678}; 
    7779 
     
    8789}; 
    8890 
     91STDMETHODIMP VLCViewObject::GetExtent(DWORD dwAspect, LONG lindex, 
     92        DVTARGETDEVICE *ptd, LPSIZEL lpSizel) 
     93{ 
     94    if( dwAspect & DVASPECT_CONTENT ) 
     95    { 
     96        *lpSizel = _p_instance->getExtent(); 
     97        return S_OK; 
     98    } 
     99    lpSizel->cx= 0L; 
     100    lpSizel->cy= 0L; 
     101    return E_NOTIMPL; 
     102}; 
     103 
  • activex/viewobject.h

    rb9057a6 r1b75d79  
    2626#include <oleidl.h> 
    2727 
    28 class VLCViewObject : public IViewObject 
     28class VLCViewObject : public IViewObject2 
    2929{ 
    3030 
     
    4040         && (IID_IUnknown == riid)  
    4141         && (IID_IPersist == riid)  
    42          && (IID_IViewObject == riid) ) { 
     42         && (IID_IViewObject == riid)  
     43         && (IID_IViewObject2 == riid) ) { 
    4344            AddRef(); 
    4445            *ppv = reinterpret_cast<LPVOID>(this); 
     
    5960    STDMETHODIMP Unfreeze(DWORD); 
    6061 
     62    // IViewObject2 methods 
     63    STDMETHODIMP GetExtent(DWORD,LONG,DVTARGETDEVICE *,LPSIZEL); 
     64 
    6165private: 
    6266 
  • activex/vlccontrol.cpp

    r3d831e0 r1b75d79  
    5555STDMETHODIMP VLCControl::GetTypeInfoCount(UINT* pctInfo) 
    5656{ 
     57    if( NULL == pctInfo ) 
     58        return E_INVALIDARG; 
     59 
    5760    if( SUCCEEDED(getTypeInfo()) ) 
    5861        *pctInfo = 1; 
     
    103106{ 
    104107    if( NULL == pvarValue ) 
    105         return E_INVALIDARG
     108        return E_POINTER
    106109 
    107110    V_VT(pvarValue) = VT_BOOL; 
     
    128131{ 
    129132    if( NULL == isVisible ) 
    130         return E_INVALIDARG
     133        return E_POINTER
    131134 
    132135    *isVisible = _p_instance->getVisible(); 
     
    181184{ 
    182185    if( NULL == isPlaying ) 
    183         return E_INVALIDARG
     186        return E_POINTER
    184187 
    185188    int i_vlc = _p_instance->getVLCObject(); 
     
    216219{ 
    217220    if( NULL == position ) 
    218         return E_INVALIDARG
     221        return E_POINTER
    219222 
    220223    int i_vlc = _p_instance->getVLCObject(); 
     
    242245{ 
    243246    if( NULL == seconds ) 
    244         return E_INVALIDARG
     247        return E_POINTER
    245248 
    246249    int i_vlc = _p_instance->getVLCObject(); 
     
    290293{ 
    291294    if( NULL == seconds ) 
    292         return E_INVALIDARG
     295        return E_POINTER
    293296 
    294297    int i_vlc = _p_instance->getVLCObject(); 
     
    327330{ 
    328331    if( NULL == volume ) 
    329         return E_INVALIDARG
     332        return E_POINTER
    330333 
    331334    int i_vlc = _p_instance->getVLCObject(); 
     
    558561STDMETHODIMP VLCControl::addTarget( BSTR uri, VARIANT options, enum VLCPlaylistMode mode, int position) 
    559562{ 
    560     if( NULL == uri
     563    if( 0 == SysStringLen(uri)
    561564        return E_INVALIDARG; 
    562565 
     
    589592{ 
    590593    if( NULL == index ) 
    591         return E_INVALIDARG
     594        return E_POINTER
    592595 
    593596    int i_vlc = _p_instance->getVLCObject(); 
     
    648651{ 
    649652    if( NULL == version ) 
    650         return E_INVALIDARG
     653        return E_POINTER
    651654 
    652655    const char *versionStr = VLC_Version();