From: Jeffrey D. <ha...@us...> - 2003-11-19 19:19:46
|
Log Message: ----------- Drak's stuff Modified Files: -------------- /cvsroot/decaldev/source/Inject: BarLayer.cpp BarLayer.h FontCache.cpp Manager.cpp SimpleBar.cpp SimpleBar.h Revision Data ------------- Index: BarLayer.cpp =================================================================== RCS file: /cvsroot/decaldev/source/Inject/BarLayer.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- BarLayer.cpp 14 Sep 2003 00:11:09 -0000 1.15 +++ BarLayer.cpp 19 Nov 2003 19:19:14 -0000 1.16 @@ -1,4 +1,4 @@ - // BarLayer.cpp : Implementation of cBarLayer +// BarLayer.cpp : Implementation of cBarLayer #include "stdafx.h" #include "Inject.h" #include "BarLayer.h" @@ -8,176 +8,209 @@ ///////////////////////////////////////////////////////////////////////////// // cBarLayer +// Drakier: Added constants for Panel and Radar size +const long RADAR_SIZE = 110; +const long PANEL_SIZE = 308; + enum eChildID { - eBtnForwards = 1, - eBtnBackwards = 2, - ePager = 3, - eBtnMinMax = 4, - eChildBarFirst = 1000 + eBtnForwards = 1, + eBtnBackwards = 2, + ePager = 3, + eBtnMinMax = 4, + eChildBarFirst = 1000 }; -cBarLayer::cBarLayer() : m_nPosition( 0 ), m_bDragging( false ), m_TotalDelta( 0 ), m_nMinMax( eStateMax ) +cBarLayer::cBarLayer() : m_nBarStartPos( 0 ), m_nScreenWidth( 0 ), m_nScreenHeight( 0 ), m_nBarLength( 0 ), m_nPosition( 0 ), m_nDragging( 0 ), m_nMinMax( eStateMax ) { } void cBarLayer::onCreate() { - CComPtr< IPluginSite > pPlugin; - m_pSite->get_PluginSite( &pPlugin ); + CComPtr< IPluginSite > pPlugin; + m_pSite->get_PluginSite( &pPlugin ); - _ASSERTE( pPlugin.p != NULL ); + _ASSERTE( pPlugin.p != NULL ); - pPlugin->LoadBitmapPortal( 0x06001115, &m_pBackground ); + long lH; + long lW; + pPlugin->QueryMemLoc( _bstr_t( "3DAreaHeight" ), &lH ); + pPlugin->QueryMemLoc( _bstr_t( "3DAreaWidth" ), &lW ); + m_p3DH = reinterpret_cast< long * >( lH ); + m_p3DW = reinterpret_cast< long * >( lW ); - _ASSERTE( m_pBackground.p != NULL ); + pPlugin->LoadBitmapPortal( 0x06001115, &m_pBackground ); - // Ok, first create the 4 background controls - LayerParams lpChild = { eBtnMinMax, { 12, 3, 28, 19 }, eRenderClipped }; - { - CComPtr< ILayer > pUnk; - HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); + _ASSERTE( m_pBackground.p != NULL ); - _ASSERTE( SUCCEEDED( hRes ) ); + // Ok, first create the 4 background controls + LayerParams lpChild = { eBtnMinMax, { 12, 3, 28, 19 }, eRenderClipped }; + { + CComPtr< ILayer > pUnk; + HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); - m_pSite->CreateChild( &lpChild, pUnk ); - pUnk->QueryInterface( &m_pBtnMinMax ); + _ASSERTE( SUCCEEDED( hRes ) ); - _ASSERTE( m_pBtnMinMax.p != NULL ); + m_pSite->CreateChild( &lpChild, pUnk ); + pUnk->QueryInterface( &m_pBtnMinMax ); - m_pBtnMinMax->SetImages( 0, 0x0600113C, 0x0600113C ); - ICommandEventsImpl< BUTTON_MINMAX, cBarLayer >::advise( m_pBtnMinMax ); - m_pBtnMinMax->put_Matte( RGB( 0, 0, 0 ) ); - } + _ASSERTE( m_pBtnMinMax.p != NULL ); - { + m_pBtnMinMax->SetImages( 0, 0x0600113C, 0x0600113C ); + ICommandEventsImpl< BUTTON_MINMAX, cBarLayer >::advise( m_pBtnMinMax ); + m_pBtnMinMax->put_Matte( RGB( 0, 0, 0 ) ); + } + + { lpChild.ID = eBtnForwards; - CComPtr< ILayer > pUnk; - HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); + + CComPtr< ILayer > pUnk; + HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); - _ASSERTE( SUCCEEDED( hRes ) ); + _ASSERTE( SUCCEEDED( hRes ) ); - m_pSite->CreateChild( &lpChild, pUnk ); - pUnk->QueryInterface( &m_pBtnForwards ); + m_pSite->CreateChild( &lpChild, pUnk ); + pUnk->QueryInterface( &m_pBtnForwards ); - _ASSERTE( m_pBtnForwards.p != NULL ); + _ASSERTE( m_pBtnForwards.p != NULL ); - m_pBtnForwards->SetImages( 0, 0x06001298, 0x06001299 ); + m_pBtnForwards->SetImages( 0, 0x06001298, 0x06001299 ); + ICommandEventsImpl< BUTTON_FORWARD, cBarLayer >::advise( m_pBtnForwards ); + m_pBtnForwards->put_Matte( RGB( 0, 0, 0 ) ); + } - ICommandEventsImpl< BUTTON_FORWARD, cBarLayer >::advise( m_pBtnForwards ); - m_pBtnForwards->put_Matte( RGB( 0, 0, 0 ) ); - } + { + lpChild.ID = eBtnBackwards; - { - lpChild.ID = eBtnBackwards; + CComPtr< ILayer > pUnk; + HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); - CComPtr< ILayer > pUnk; - HRESULT hRes = ::CoCreateInstance( CLSID_Button, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, - reinterpret_cast< void ** >( &pUnk ) ); + _ASSERTE( SUCCEEDED( hRes ) ); - _ASSERTE( SUCCEEDED( hRes ) ); + m_pSite->CreateChild( &lpChild, pUnk ); + pUnk->QueryInterface( &m_pBtnBackwards ); - m_pSite->CreateChild( &lpChild, pUnk ); - pUnk->QueryInterface( &m_pBtnBackwards ); + _ASSERTE( m_pBtnBackwards.p != NULL ); - _ASSERTE( m_pBtnBackwards.p != NULL ); + m_pBtnBackwards->SetImages( 0, 0x06001295, 0x06001296 ); + ICommandEventsImpl< BUTTON_BACK, cBarLayer >::advise( m_pBtnBackwards ); + m_pBtnBackwards->put_Matte( RGB( 0, 0, 0 ) ); + } - m_pBtnBackwards->SetImages( 0, 0x06001295, 0x06001296 ); - ICommandEventsImpl< BUTTON_BACK, cBarLayer >::advise( m_pBtnBackwards ); - m_pBtnBackwards->put_Matte( RGB( 0, 0, 0 ) ); - } + { + lpChild.ID = ePager; - { - lpChild.ID = ePager; + CComPtr< ILayer > pUnk; + HRESULT hRes = ::CoCreateInstance( CLSID_Pager, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, reinterpret_cast< void ** >( &pUnk ) ); - CComPtr< ILayer > pUnk; - HRESULT hRes = ::CoCreateInstance( CLSID_Pager, NULL, CLSCTX_INPROC_SERVER, IID_ILayer, - reinterpret_cast< void ** >( &pUnk ) ); + _ASSERTE( SUCCEEDED( hRes ) ); - _ASSERTE( SUCCEEDED( hRes ) ); + m_pSite->CreateChild( &lpChild, pUnk ); + pUnk->QueryInterface( &m_pPager ); - m_pSite->CreateChild( &lpChild, pUnk ); - pUnk->QueryInterface( &m_pPager ); + _ASSERTE( m_pPager.p != NULL ); - _ASSERTE( m_pPager.p != NULL ); + IPagerEventsImpl< PAGER_CLIENT, cBarLayer >::advise( m_pPager ); + } - IPagerEventsImpl< PAGER_CLIENT, cBarLayer >::advise( m_pPager ); - } + m_pSite->put_Transparent( VARIANT_FALSE ); - m_pSite->put_Transparent( VARIANT_FALSE ); + RegKey key; + key.Create( HKEY_LOCAL_MACHINE, _T( "SOFTWARE\\Decal" ) ); - RegKey key; - key.Create( HKEY_LOCAL_MACHINE, _T( "SOFTWARE\\Decal" ) ); + DWORD dwAlpha = 255, dwRadarDraw = 1; + m_bRadarDraw = true; - DWORD dwAlpha = 255, dwRadarDraw = 1; - m_bRadarDraw = true; + if( key.QueryDWORDValue( "BarAlpha", dwAlpha ) == ERROR_SUCCESS ) + m_pSite->put_Alpha( dwAlpha ); - if( key.QueryDWORDValue( "BarAlpha", dwAlpha ) == ERROR_SUCCESS ) - m_pSite->put_Alpha( dwAlpha ); + if( key.QueryDWORDValue( "BarRadarDraw", dwRadarDraw ) == ERROR_SUCCESS ) + m_bRadarDraw = dwRadarDraw ? true : false; - if( key.QueryDWORDValue( "BarRadarDraw", dwRadarDraw ) == ERROR_SUCCESS ) - m_bRadarDraw = dwRadarDraw ? true : false; + if( key.QueryDWORDValue( "BarState", m_nMinMax ) != ERROR_SUCCESS ) + m_nMinMax = eStateMax; - if( key.QueryDWORDValue( "BarState", m_nMinMax ) != ERROR_SUCCESS ) - m_nMinMax = eStateMax; + // Drakier: get the bar start pos or default to left + if( key.QueryDWORDValue( "BarStart", (DWORD &)m_nBarStartPos ) != ERROR_SUCCESS ) + m_nBarStartPos = 0; - if( key.QueryDWORDValue( "BarDelta", (DWORD &)m_TotalDelta ) != ERROR_SUCCESS ) - m_TotalDelta = 0; + // Drakier: get the bar length or default to 250 px + if( key.QueryDWORDValue( "BarLength", (DWORD &)m_nBarLength ) != ERROR_SUCCESS ) + m_nBarLength = 250; - if( m_nMinMax == eStateMin ) - m_pBtnMinMax->SetImages( 0, 0x0600113C, 0x0600113C ); - else - m_pBtnMinMax->SetImages( 0, 0x0600113B, 0x0600113B ); + if( m_nMinMax == eStateMin ) + m_pBtnMinMax->SetImages( 0, 0x0600113C, 0x0600113C ); + else + m_pBtnMinMax->SetImages( 0, 0x0600113B, 0x0600113B ); } void cBarLayer::onDestroy() { - m_pBtnForwards.Release(); - m_pBtnBackwards.Release(); - m_pBackground.Release(); - - m_pPager.Release(); + m_pBtnForwards.Release(); + m_pBtnBackwards.Release(); + m_pBackground.Release(); + m_pPager.Release(); } STDMETHODIMP cBarLayer::Render(ICanvas *pCanvas) { - _ASSERTE( pCanvas != NULL ); + _ASSERTE( pCanvas != NULL ); - ClipParams p; - pCanvas->GetClipParams( &p ); + ClipParams p; + pCanvas->GetClipParams( &p ); - m_pBackground->PatBlt( pCanvas, &p.window, &p.org ); + m_pBackground->PatBlt( pCanvas, &p.window, &p.org ); - RECT dragBarRect; - dragBarRect.left = 3; - dragBarRect.top = 4; - dragBarRect.right = 4; - dragBarRect.bottom = 19; + RECT dragBarRect; + dragBarRect.left = 3; + dragBarRect.top = 4; + dragBarRect.right = 4; + dragBarRect.bottom = 19; - pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); - - dragBarRect.left += 1; - dragBarRect.right += 1; - pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); + pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); + + dragBarRect.left += 1; + dragBarRect.right += 1; + pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); - dragBarRect.left += 2; - dragBarRect.right += 2; - pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); + dragBarRect.left += 2; + dragBarRect.right += 2; + pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); - dragBarRect.left += 1; - dragBarRect.right += 1; - pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); + dragBarRect.left += 1; + dragBarRect.right += 1; + pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); - _ASSERTMEM( _CrtCheckMemory( ) ); + // Drakier: draw the right-hand grab bars + dragBarRect.left = m_nBarLength - 4; + dragBarRect.top = 4; + dragBarRect.right = m_nBarLength - 3; + dragBarRect.bottom = 19; - return S_OK; + pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); + + dragBarRect.left -= 1; + dragBarRect.right -= 1; + pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); + + dragBarRect.left -= 2; + dragBarRect.right -= 2; + pCanvas->Fill(&dragBarRect, RGB(165, 82, 57)); + + dragBarRect.left -= 1; + dragBarRect.right -= 1; + pCanvas->Fill(&dragBarRect, RGB(214, 173, 140)); + + _ASSERTMEM( _CrtCheckMemory( ) ); + + return S_OK; } -#define ENUM_REFORMAT 1 +#define ENUM_REFORMAT 1 class cBarEnumFormat { public: - long nCursor; + long nCursor; }; STDMETHODIMP cBarLayer::Reformat() @@ -190,34 +223,39 @@ CComPtr< IPluginSite > pPlugin; m_pSite->get_PluginSite( &pPlugin ); pPlugin->GetScreenSize( &sz ); + if ( sz.cx > 0 ) + m_nScreenWidth = sz.cx; + if ( sz.cy > 0) + m_nScreenHeight = sz.cy; - // Make sure the Decal bar is always at least 112 pixels wide, - if( ( cManager::_p->m_bContainer ) && ( m_TotalDelta > 190 ) ) - m_TotalDelta = 190; - else if( m_TotalDelta > 420 ) - m_TotalDelta = 420; - - // Also make sure it's never past left edge of the screen. - if( m_TotalDelta < -230 ) - m_TotalDelta = -230; + // Drakier: set up the bar position + // Drakier: make sure bar isn't off of left side of screen + // and that the bar length is at least 112 px + if (m_nBarStartPos < 0) + m_nBarStartPos = 0; + if (m_nBarLength < 112) + m_nBarLength = 250; + // Drakier: the right edge of the 3D area is (m_nScreenWidth - PANEL_SIZE) + // If you include the radar (110) it is (m_nScreenWidth - (PANEL_SIZE + RADAR_SIZE)) + // Drakier: make sure bar isn't off RIGHT side of screen + if (m_nBarLength > (m_nScreenWidth - PANEL_SIZE) ) + m_nBarLength = m_nScreenWidth - PANEL_SIZE; - // Now that we have the resolution, calculate the area we intend to cover - // 308 - Extreme Right Edge - 418 - Past Radar + // Drakier: adjust bar start position so its not offscreen + if (m_nBarStartPos > (m_nScreenWidth - PANEL_SIZE) ) + m_nBarStartPos = (m_nScreenWidth - PANEL_SIZE) - m_nBarLength; - int nVariableWidth = 418; + // Drakier: Adjust for Panel + if ((m_nBarStartPos + m_nBarLength) > (m_nScreenWidth - PANEL_SIZE) ) + m_nBarLength = (m_nScreenWidth - PANEL_SIZE) - m_nBarStartPos; - if( m_bRadarDraw ) - nVariableWidth = 308; + // Drakier: Adjust for Radar + if ( (!m_bRadarDraw) && ((m_nBarStartPos + m_nBarLength) > (m_nScreenWidth - (PANEL_SIZE + RADAR_SIZE))) ) + m_nBarLength = (m_nScreenWidth - (PANEL_SIZE + RADAR_SIZE)) - m_nBarStartPos; - int nWidth = sz.cx - ( nVariableWidth + 230 + m_TotalDelta ); - // GKusnick: *Really* make sure the Decal bar is always at least 112 pixels wide. - if (nWidth < 112) - { - nWidth = 112; - m_TotalDelta = sz.cx - (308 + 230 + nWidth); - } - RECT rc1 = { 230 + m_TotalDelta, 0, 230 + m_TotalDelta + nWidth, 23 }; + // Drakier: Draw the bar + RECT rc1 = { m_nBarStartPos, 0, m_nBarStartPos + m_nBarLength, 23 }; m_pSite->put_Position( &rc1 ); // Now do the backwards @@ -226,10 +264,10 @@ m_pSite->get_Child( eBtnBackwards, ePositionByID, &pBackwardsSite ); pBackwardsSite->put_Position( &rc ); - // Next do the forward button - rc.left = nWidth - 18; + // Drakier: this is a change because of the new LENGTH system + rc.left = m_nBarLength - 28; rc.top = 3; - rc.right = nWidth - 2; + rc.right = m_nBarLength - 12; rc.bottom = 19; CComPtr< ILayerSite > pFwdSite; @@ -240,7 +278,7 @@ CComPtr< ILayerSite > pPagerSite; m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); - RECT rc3 = { 50, 1, nWidth - 20, 22 }; + RECT rc3 = { 50, 1, m_nBarLength - 30, 22}; pPagerSite->put_Position( &rc3 ); m_offsets.clear(); @@ -294,139 +332,143 @@ VARIANT_BOOL cBarLayer::onClientGetNextPosition(long nID, long nCommand, long *pnX, long *pnY) { - switch( nCommand ) - { - case eBtnForwards: - if( m_nPosition < ( m_offsets.size() - 1 ) ) - { - ++ m_nPosition; - *pnX = m_offsets[ m_nPosition ]; - *pnY = 0; + switch( nCommand ) + { + case eBtnForwards: + if( m_nPosition < ( m_offsets.size() - 1 ) ) + { + ++ m_nPosition; + *pnX = m_offsets[ m_nPosition ]; + *pnY = 0; - return VARIANT_TRUE; - } - break; + return VARIANT_TRUE; + } + break; - case eBtnBackwards: - if( m_nPosition > 0 ) - { - -- m_nPosition; - *pnX = m_offsets[ m_nPosition ]; - *pnY = 0; + case eBtnBackwards: + if( m_nPosition > 0 ) + { + -- m_nPosition; + *pnX = m_offsets[ m_nPosition ]; + *pnY = 0; - return VARIANT_TRUE; - } - break; - - default: - // Unknown command - _ASSERT( FALSE ); - } + return VARIANT_TRUE; + } + break; + + default: + // Unknown command + _ASSERT( FALSE ); + } - // Unknown command or over/underflow - end paging - return VARIANT_FALSE; + // Unknown command or over/underflow - end paging + return VARIANT_FALSE; } STDMETHODIMP cBarLayer::AddBar(long nViewID, ViewParams *pParams) { - _ASSERTE( pParams != NULL ); - _ASSERTE( pParams->label != NULL ); + _ASSERTE( pParams != NULL ); + _ASSERTE( pParams->label != NULL ); - CComObject< cSimpleBar > *pNewBar; - CComObject< cSimpleBar >::CreateInstance( &pNewBar ); + CComObject< cSimpleBar > *pNewBar; + CComObject< cSimpleBar >::CreateInstance( &pNewBar ); - pNewBar->put_Params( pParams ); + pNewBar->put_Params( pParams ); - CComPtr< ILayerSite > pPagerSite; - m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); - - LayerParams p = { nViewID, { 0, 0, 0, 0 }, eRenderClipped }; + CComPtr< ILayerSite > pPagerSite; + m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); + + LayerParams p = { nViewID, { 0, 0, 0, 0 }, eRenderClipped }; - pPagerSite->CreateChild( &p, pNewBar ); + pPagerSite->CreateChild( &p, pNewBar ); - m_pSite->Reformat(); + m_pSite->Reformat(); return S_OK; } STDMETHODIMP cBarLayer::RemoveBar(long nViewID) { - CComPtr< ILayerSite > pPagerSite; - m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); + CComPtr< ILayerSite > pPagerSite; + m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); - CComPtr< ILayerSite > pBarSite; - HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); + CComPtr< ILayerSite > pBarSite; + HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); - if( FAILED( hRes ) ) - // Probably not found - return hRes; + if( FAILED( hRes ) ) + // Probably not found + return hRes; - m_pSite->Reformat(); + m_pSite->Reformat(); return pBarSite->Destroy(); } STDMETHODIMP cBarLayer::get_Bar(long nViewID, ViewParams *pVal) { - CComPtr< ILayerSite > pPagerSite; - m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); + CComPtr< ILayerSite > pPagerSite; + m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); - CComPtr< ILayerSite > pBarSite; - HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); + CComPtr< ILayerSite > pBarSite; + HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); - if( FAILED( hRes ) ) - // Probably not found - return hRes; + if( FAILED( hRes ) ) + // Probably not found + return hRes; - CComPtr< ISimpleBar > pSimpleBar; - pBarSite->GetSink( IID_ISimpleBar, reinterpret_cast< void ** >( &pSimpleBar ) ); + CComPtr< ISimpleBar > pSimpleBar; + pBarSite->GetSink( IID_ISimpleBar, reinterpret_cast< void ** >( &pSimpleBar ) ); - pSimpleBar->get_Params( pVal ); + pSimpleBar->get_Params( pVal ); return S_OK; } STDMETHODIMP cBarLayer::put_Bar(long nViewID, ViewParams *newVal) { - CComPtr< ILayerSite > pPagerSite; - m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); + CComPtr< ILayerSite > pPagerSite; + m_pSite->get_Child( ePager, ePositionByID, &pPagerSite ); - CComPtr< ILayerSite > pBarSite; - HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); + CComPtr< ILayerSite > pBarSite; + HRESULT hRes = pPagerSite->get_Child( nViewID, ePositionByID, &pBarSite ); - if( FAILED( hRes ) ) - // Probably not found - return hRes; + if( FAILED( hRes ) ) + // Probably not found + return hRes; - CComPtr< ISimpleBar > pSimpleBar; - pBarSite->GetSink( IID_ISimpleBar, reinterpret_cast< void ** >( &pSimpleBar ) ); + CComPtr< ISimpleBar > pSimpleBar; + pBarSite->GetSink( IID_ISimpleBar, reinterpret_cast< void ** >( &pSimpleBar ) ); - pSimpleBar->put_Params( newVal ); + pSimpleBar->put_Params( newVal ); - m_pSite->Reformat(); + m_pSite->Reformat(); return S_OK; } void __stdcall cBarLayer::onMinMaxHit(long nID) { - RegKey key; + RegKey key; - if (m_nMinMax == eStateMax) { + if (m_nMinMax == eStateMax) + { m_nMinMax = eStateMin; m_pBtnMinMax->SetImages(0, 0x0600113C, 0x0600113C); - } else { + } + else + { m_nMinMax = eStateMax; m_pBtnMinMax->SetImages(0, 0x0600113B, 0x0600113B); - } + } - key.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Decal")); - key.SetDWORDValue("BarState", m_nMinMax); + key.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Decal")); + key.SetDWORDValue("BarState", m_nMinMax); - Reformat(); + Reformat(); } STDMETHODIMP cBarLayer::MouseEvent(long nMsg, long wParam, long lParam) { - switch (nMsg) { + switch (nMsg) + { case WM_LBUTTONDOWN: RECT rSize; m_pSite->get_Position(&rSize); @@ -436,29 +478,37 @@ if( !cManager::_p->m_bContainer ) pt.y -= 28; - + + // Drakier: Grabbing the left drag bar if (pt.y >= rSize.top && pt.y <= rSize.bottom && pt.x >= rSize.left + 1 && pt.x <= rSize.left + 8) { - m_bDragging = true; - + m_nDragging = -1; m_DeltaX = pt.x; } + // Drakier: Grabbing the right drag bar + if (pt.y >= rSize.top && pt.y <= rSize.bottom && pt.x >= rSize.right - 8 && pt.x <= rSize.right - 1) + { + m_nDragging = 1; + m_DeltaX = pt.x; + } break; case WM_LBUTTONUP: - if( m_bDragging ) + if( m_nDragging == -1 || m_nDragging == 1 ) { - m_bDragging = false; + m_nDragging = 0; RegKey key; key.Create(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Decal")); - key.SetDWORDValue("BarDelta", (DWORD)m_TotalDelta); + // Drakier: For the new bar system + key.SetDWORDValue("BarStart", (DWORD)m_nBarStartPos); + key.SetDWORDValue("BarLength", (DWORD)m_nBarLength); } break; case WM_MOUSEMOVE: - if ( m_bDragging ) + if ( m_nDragging == -1 ) // Drakier: Drag Left { POINTS pt; pt = MAKEPOINTS(lParam); @@ -466,14 +516,42 @@ if( !cManager::_p->m_bContainer ) pt.y -= 28; - m_TotalDelta += pt.x - m_DeltaX; - m_DeltaX = pt.x; + if ( ((m_nBarLength - (pt.x - m_DeltaX)) > 112 ) && (((pt.x - m_DeltaX) + m_nBarStartPos) >= 0) ) + { + m_nBarStartPos += pt.x - m_DeltaX; + m_nBarLength += (-1) * (pt.x - m_DeltaX); + m_DeltaX = pt.x; + } Reformat( ); } + else if ( m_nDragging == 1 ) // Drakier: Drag Right + { + POINTS pt; + pt = MAKEPOINTS(lParam); + + if( !cManager::_p->m_bContainer ) + pt.y -= 28; + if ( !m_bRadarDraw ) // Drakier: Radar on? + { + if ( ((pt.x - m_DeltaX + m_nBarLength) >= 112) && ((m_nBarStartPos + m_nBarLength + pt.x - m_DeltaX) <= (m_nScreenWidth - (PANEL_SIZE + RADAR_SIZE))) ) + { + m_nBarLength += pt.x - m_DeltaX; + m_DeltaX = pt.x; + } + } + else // Drakier: Radar off! + { + if ( ((pt.x - m_DeltaX + m_nBarLength) >= 112) && ((m_nBarStartPos + m_nBarLength + pt.x - m_DeltaX) <= (m_nScreenWidth - PANEL_SIZE)) ) + { + m_nBarLength += pt.x - m_DeltaX; + m_DeltaX = pt.x; + } + } + Reformat( ); + } break; } - return S_OK; -} +} \ No newline at end of file Index: BarLayer.h =================================================================== RCS file: /cvsroot/decaldev/source/Inject/BarLayer.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- BarLayer.h 3 Jan 2003 00:55:21 -0000 1.6 +++ BarLayer.h 19 Nov 2003 19:19:14 -0000 1.7 @@ -3,7 +3,7 @@ #ifndef __BARLAYER_H_ #define __BARLAYER_H_ -#include "resource.h" // main symbols +#include "resource.h" // main symbols #include "SinkImpl.h" @@ -17,40 +17,47 @@ // cBarLayer class ATL_NO_VTABLE cBarLayer : public CComObjectRootEx<CComMultiThreadModel>, - public ILayerImpl< cBarLayer >, + public ILayerImpl< cBarLayer >, public ILayerRenderImpl, - public IBarManager, - public ICommandEventsImpl< BUTTON_BACK, cBarLayer >, - public ICommandEventsImpl< BUTTON_FORWARD, cBarLayer >, - public ICommandEventsImpl< BUTTON_MINMAX, cBarLayer >, - public ILayerMouseImpl, - public cNoEventsImpl, - public IPagerEventsImpl< PAGER_CLIENT, cBarLayer > + public IBarManager, + public ICommandEventsImpl< BUTTON_BACK, cBarLayer >, + public ICommandEventsImpl< BUTTON_FORWARD, cBarLayer >, + public ICommandEventsImpl< BUTTON_MINMAX, cBarLayer >, + public ILayerMouseImpl, + public cNoEventsImpl, + public IPagerEventsImpl< PAGER_CLIENT, cBarLayer > { public: cBarLayer(); - // Important child objects - CComPtr< IPager > m_pPager; - CComPtr< IButton > m_pBtnForwards, - m_pBtnBackwards, m_pBtnMinMax; + // Important child objects + CComPtr< IPager > m_pPager; + CComPtr< IButton > m_pBtnForwards, + m_pBtnBackwards, m_pBtnMinMax; - CComPtr< IImageCache > m_pBackground; + CComPtr< IImageCache > m_pBackground; - // This the the list of bars - typedef std::vector< long > cOffsetList; - cOffsetList m_offsets; - long m_nPosition; - unsigned long m_nMinMax; + // This the the list of bars + typedef std::vector< long > cOffsetList; + cOffsetList m_offsets; + long m_nPosition; + unsigned long m_nMinMax; - long m_DeltaX; - long m_TotalDelta; + long m_DeltaX; + long m_nScreenWidth; + long m_nScreenHeight; + //long m_TotalDelta; + long *m_p3DH; + long *m_p3DW; - bool m_bDragging; - bool m_bRadarDraw; + long m_nBarStartPos; + long m_nBarLength; - void onCreate(); - void onDestroy(); + int m_nDragging; + bool m_bRadarDraw; + + void onCreate(); + void onDestroy(); BEGIN_COM_MAP(cBarLayer) COM_INTERFACE_ENTRY(ILayer) @@ -60,41 +67,41 @@ END_COM_MAP() BEGIN_SINK_MAP(cBarLayer) - SINK_ENTRY_EX( BUTTON_BACK, DIID_ICommandEvents, DISPID_HIT, onCommandHit ) - SINK_ENTRY_EX( BUTTON_BACK, DIID_ICommandEvents, DISPID_UNHIT, onCommandUnhit ) - SINK_ENTRY_EX( BUTTON_FORWARD, DIID_ICommandEvents, DISPID_HIT, onCommandHit ) - SINK_ENTRY_EX( BUTTON_FORWARD, DIID_ICommandEvents, DISPID_UNHIT, onCommandUnhit ) - SINK_ENTRY_EX( BUTTON_MINMAX, DIID_ICommandEvents, DISPID_HIT, onMinMaxHit ) - SINK_ENTRY_EX( PAGER_CLIENT, DIID_IPagerEvents, DISPID_GETNEXTPOSITION, onClientGetNextPosition ) + SINK_ENTRY_EX( BUTTON_BACK, DIID_ICommandEvents, DISPID_HIT, onCommandHit ) + SINK_ENTRY_EX( BUTTON_BACK, DIID_ICommandEvents, DISPID_UNHIT, onCommandUnhit ) + SINK_ENTRY_EX( BUTTON_FORWARD, DIID_ICommandEvents, DISPID_HIT, onCommandHit ) + SINK_ENTRY_EX( BUTTON_FORWARD, DIID_ICommandEvents, DISPID_UNHIT, onCommandUnhit ) + SINK_ENTRY_EX( BUTTON_MINMAX, DIID_ICommandEvents, DISPID_HIT, onMinMaxHit ) + SINK_ENTRY_EX( PAGER_CLIENT, DIID_IPagerEvents, DISPID_GETNEXTPOSITION, onClientGetNextPosition ) END_SINK_MAP() public: - // IBarManager + // IBarManager STDMETHOD(get_Bar)(long nViewID, /*[out, retval]*/ ViewParams *pVal); STDMETHOD(put_Bar)(long nViewID, /*[in]*/ ViewParams * newVal); STDMETHOD(RemoveBar)(long nViewID); STDMETHOD(AddBar)(long nViewID, ViewParams *pParams); - // ILayerRender + // ILayerRender STDMETHOD(Render)(ICanvas *pCanvas); STDMETHOD(Reformat)(); - // Button Back and Forward event handlers - void __stdcall onCommandHit( long nID ) - { - m_pPager->put_Command( nID ); - } + // Button Back and Forward event handlers + void __stdcall onCommandHit( long nID ) + { + m_pPager->put_Command( nID ); + } - void __stdcall onCommandUnhit( long ) - { - m_pPager->FinishCommand(); - } + void __stdcall onCommandUnhit( long ) + { + m_pPager->FinishCommand(); + } - void __stdcall onMinMaxHit(long nID); + void __stdcall onMinMaxHit(long nID); - // Pager event handlers - VARIANT_BOOL __stdcall onClientGetNextPosition( long nID, long nCommand, long *pnX, long *pnY ); - STDMETHOD(MouseEvent)(long nMsg, long wParam, long lParam); + // Pager event handlers + VARIANT_BOOL __stdcall onClientGetNextPosition( long nID, long nCommand, long *pnX, long *pnY ); + STDMETHOD(MouseEvent)(long nMsg, long wParam, long lParam); }; #endif //__BARLAYER_H_ Index: FontCache.cpp =================================================================== RCS file: /cvsroot/decaldev/source/Inject/FontCache.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- FontCache.cpp 8 Oct 2003 20:56:44 -0000 1.4 +++ FontCache.cpp 19 Nov 2003 19:19:14 -0000 1.5 @@ -10,7 +10,7 @@ cFontCache::~cFontCache() { - cManager::_p->removeFont( this ); + cManager::_p->removeFont( this ); } #define BUFFER_WIDTHCHARS 32 @@ -19,66 +19,80 @@ bool cFontCache::checkBuffer() { - if( m_pBuffer.p ) - { - VARIANT_BOOL bWasLost; - m_pBuffer->get_WasLost( &bWasLost ); - if( bWasLost ) - m_pBuffer.Release(); - } + if( m_pBuffer.p ) + { + VARIANT_BOOL bWasLost; + m_pBuffer->get_WasLost( &bWasLost ); + if( bWasLost ) + m_pBuffer.Release(); + } - if( m_pBuffer.p ) - // The character buff is intact - return true; + if( m_pBuffer.p ) + // The character buff is intact + return true; - // Get a dummy DC from the primary surface - CComPtr< ICanvas > pSurf; + // Get a dummy DC from the primary surface + CComPtr< ICanvas > pSurf; if( FAILED(cManager::_p->GetPrimarySurface( &pSurf )) ) return false; - // Madar: This can happen if you set an edit-text during plugin initialization. - if (!pSurf) - { - return false; - } + // Madar: This can happen if you set an edit-text during plugin initialization. + if (!pSurf) + { + return false; + } - HDC hdc; - pSurf->GetDC( &hdc ); + HDC hdc; + pSurf->GetDC( &hdc ); - HFONT hfnt = ::CreateFontIndirect( &m_lf ), - hfntOld = reinterpret_cast< HFONT >( ::SelectObject( hdc, hfnt ) ); + // Drakier: reset error, try to create font, then check for error. + SetLastError(ERROR_SUCCESS); + HFONT hfnt = ::CreateFontIndirect( &m_lf ); + if (GetLastError() != ERROR_SUCCESS) + { + _ASSERTE(GetLastError()); + // Drakier: try arial instead + strcpy(m_lf.lfFaceName, "Arial"); + SetLastError(ERROR_SUCCESS); + HFONT hfnt = ::CreateFontIndirect( &m_lf ); + if (GetLastError() != ERROR_SUCCESS) + return false; + } - TEXTMETRIC tm; - ::GetTextMetrics( hdc, &tm ); + HFONT hfntOld = reinterpret_cast< HFONT >( ::SelectObject( hdc, hfnt ) ); - m_szCharCell.cy = tm.tmHeight; - m_szCharCell.cx = tm.tmMaxCharWidth; - // Create the buffer - SIZE szBuffer = { m_szCharCell.cx * BUFFER_WIDTHCHARS, m_szCharCell.cy * BUFFER_HEIGHTCHARS }; - cManager::_p->CreateCanvas( &szBuffer, &m_pBuffer ); + TEXTMETRIC tm; + ::GetTextMetrics( hdc, &tm ); - INT widths[ BUFFER_CHARCOUNT ]; - BOOL b = ::GetCharWidth( hdc, 0, ( BUFFER_CHARCOUNT - 1 ), widths ); - _ASSERTE( b ); - DWORD dwError = ::GetLastError(); + m_szCharCell.cy = tm.tmHeight; + m_szCharCell.cx = tm.tmMaxCharWidth; - for( short nChar = 0; nChar < BUFFER_CHARCOUNT; ++ nChar ) - { - // TODO: Render the chars - // Figure out the character cell size - m_nWidths[ nChar ].m_nWidth = widths[ nChar ]; - } + // Create the buffer + SIZE szBuffer = { m_szCharCell.cx * BUFFER_WIDTHCHARS, m_szCharCell.cy * BUFFER_HEIGHTCHARS }; + cManager::_p->CreateCanvas( &szBuffer, &m_pBuffer ); - // TODO: Render all the chars into the buffer + INT widths[ BUFFER_CHARCOUNT ]; + BOOL b = ::GetCharWidth( hdc, 0, ( BUFFER_CHARCOUNT - 1 ), widths ); + _ASSERTE( b ); + DWORD dwError = ::GetLastError(); - ::SelectObject( hdc, hfntOld ); - ::DeleteObject( hfnt ); + for( short nChar = 0; nChar < BUFFER_CHARCOUNT; ++ nChar ) + { + // TODO: Render the chars + // Figure out the character cell size + m_nWidths[ nChar ].m_nWidth = widths[ nChar ]; + } - pSurf->ReleaseDC(); + // TODO: Render all the chars into the buffer - return true; + ::SelectObject( hdc, hfntOld ); + ::DeleteObject( hfnt ); + + pSurf->ReleaseDC(); + + return true; } STDMETHODIMP cFontCache::DrawText( LPPOINT ppt, BSTR strText, long clr, ICanvas *pCanvas ) @@ -156,8 +170,21 @@ pCanvas->GetDC( &hdc ); // Draw the text - HFONT hfnt = ::CreateFontIndirect( &m_lf ), - hfntOld = reinterpret_cast< HFONT >( ::SelectObject( hdc, hfnt ) ); + // Drakier: reset error, try to create font, then check for error. + SetLastError(ERROR_SUCCESS); + HFONT hfnt = ::CreateFontIndirect( &m_lf ); + if (GetLastError() != ERROR_SUCCESS) + { + _ASSERTE(GetLastError()); + // Drakier: try arial instead + strcpy(m_lf.lfFaceName, "Arial"); + SetLastError(ERROR_SUCCESS); + HFONT hfnt = ::CreateFontIndirect( &m_lf ); + if (GetLastError() != ERROR_SUCCESS) + return E_FAIL; + } + + HFONT hfntOld = reinterpret_cast< HFONT >( ::SelectObject( hdc, hfnt ) ); ::SetBkMode( hdc, TRANSPARENT ); ::SetTextAlign( hdc, TA_TOP | TA_LEFT ); @@ -206,52 +233,52 @@ STDMETHODIMP cFontCache::MeasureText( BSTR strText, LPSIZE pszExt ) { - _ASSERTE( strText != NULL ); - _ASSERTE( pszExt != NULL ); + _ASSERTE( strText != NULL ); + _ASSERTE( pszExt != NULL ); - if( !checkBuffer() ) - return E_FAIL; + if( !checkBuffer() ) + return E_FAIL; - USES_CONVERSION; + USES_CONVERSION; - LPCSTR szText = OLE2T( strText ), - i_end_text = szText + strlen( szText ); + LPCSTR szText = OLE2T( strText ), + i_end_text = szText + strlen( szText ); - pszExt->cy = m_szCharCell.cy; - pszExt->cx = 0; + pszExt->cy = m_szCharCell.cy; + pszExt->cx = 0; - for( LPCSTR i_text = szText; i_text != i_end_text; ++ i_text ) - pszExt->cx += m_nWidths[ *i_text ].m_nWidth; + for( LPCSTR i_text = szText; i_text != i_end_text; ++ i_text ) + pszExt->cx += m_nWidths[ *i_text ].m_nWidth; - return S_OK; + return S_OK; } STDMETHODIMP cFontCache::HitTest(BSTR szText, long nPos, long *nIndex) { - _ASSERTE( szText != NULL ); - _ASSERTE( nIndex != NULL ); + _ASSERTE( szText != NULL ); + _ASSERTE( nIndex != NULL ); - if( !checkBuffer() ) - return E_FAIL; + if( !checkBuffer() ) + return E_FAIL; - USES_CONVERSION; + USES_CONVERSION; - LPCSTR szAText = OLE2T( szText ), - i_end_text = szAText + strlen( szAText ); + LPCSTR szAText = OLE2T( szText ), + i_end_text = szAText + strlen( szAText ); - for( LPCSTR i_text = szAText; i_text != i_end_text; ++ i_text ) - { - short nWidth = m_nWidths[ *i_text ].m_nWidth; - if( nPos < nWidth ) - { - *nIndex = ( i_text - szAText ); - return S_OK; - } + for( LPCSTR i_text = szAText; i_text != i_end_text; ++ i_text ) + { + short nWidth = m_nWidths[ *i_text ].m_nWidth; + if( nPos < nWidth ) + { + *nIndex = ( i_text - szAText ); + return S_OK; + } - nPos -= nWidth; - } + nPos -= nWidth; + } - *nIndex = -1; + *nIndex = -1; return S_OK; } Index: Manager.cpp =================================================================== RCS file: /cvsroot/decaldev/source/Inject/Manager.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- Manager.cpp 21 Oct 2003 19:12:15 -0000 1.80 +++ Manager.cpp 19 Nov 2003 19:19:14 -0000 1.81 @@ -138,23 +138,29 @@ { USES_CONVERSION; + // Obtain ACHooks Ref & start ACHooks events if we're not in Checksum's Container + if(!m_bContainer) { - // Prepare the root layer and bar manager before loading plugins - // We have to manually create the root site - CComObject< cLayerSite > *pRootSite; - CComObject< cLayerSite >::CreateInstance( &pRootSite ); + m_pDecal->get_Hooks( &m_pHooks ); + IACHooksEventsImpl<ChatMessageHook, cManager>::advise( m_pHooks ); + IACHooksEventsImpl<ChatTextHook, cManager>::advise( m_pHooks ); + } - m_pRootSite = pRootSite; + // Prepare the root layer and bar manager before loading plugins + // We have to manually create the root site + CComObject< cLayerSite > *pRootSite; + CComObject< cLayerSite >::CreateInstance( &pRootSite ); - // Create the paired root layer - CComObject< cRootLayer > *pRootLayer; - CComObject< cRootLayer >::CreateInstance( &pRootLayer ); - m_pRootLayer = pRootLayer; + m_pRootSite = pRootSite; - // To circular reference keeps it all intact - LayerParams lp = { 0, { 0, 0, 0, 0 }, eRenderClipped }; - m_pRootSite->create( &lp, NULL, pRootLayer ); - } + // Create the paired root layer + CComObject< cRootLayer > *pRootLayer; + CComObject< cRootLayer >::CreateInstance( &pRootLayer ); + m_pRootLayer = pRootLayer; + + // To circular reference keeps it all intact + LayerParams lp = { 0, { 0, 0, 0, 0 }, eRenderClipped }; + m_pRootSite->create( &lp, NULL, pRootLayer ); m_bInitialized = true; @@ -165,14 +171,6 @@ if(key.QueryDWORDValue(_T("AlphaBlendMode"), reinterpret_cast<unsigned long &>(m_eAlphaBlendMode))!=ERROR_SUCCESS) m_eAlphaBlendMode = eAlphaBlendSoftware; - } - - // Obtain ACHooks Ref & start ACHooks events if we're not in Checksum's Container - if(!m_bContainer) - { - m_pDecal->get_Hooks( &m_pHooks ); - IACHooksEventsImpl<ChatMessageHook, cManager>::advise( m_pHooks ); - IACHooksEventsImpl<ChatTextHook, cManager>::advise( m_pHooks ); } // Install the input filter Index: SimpleBar.cpp =================================================================== RCS file: /cvsroot/decaldev/source/Inject/SimpleBar.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- SimpleBar.cpp 24 Jul 2002 03:56:34 -0000 1.4 +++ SimpleBar.cpp 19 Nov 2003 19:19:14 -0000 1.5 @@ -8,24 +8,24 @@ void cSimpleBar::onCreate() { - CComPtr< IPluginSite > pPlugin; - m_pSite->get_PluginSite( &pPlugin ); + CComPtr< IPluginSite > pPlugin; + m_pSite->get_PluginSite( &pPlugin ); - pPlugin->LoadBitmapFile( _bstr_t( _T( "Switch-Active.bmp" ) ), &m_pSwitch ); - pPlugin->LoadBitmapFile( _bstr_t( _T( "Switch-Inactive.bmp" ) ), &m_pSwitchDisabled ); - BSTR bstrFontName; - pPlugin->get_FontName(&bstrFontName); - pPlugin->CreateFont( bstrFontName /*_bstr_t( _T( "Times New Roman" ) )*/, 14, 0, &m_pFont ); - m_nMinMax = 0; + pPlugin->LoadBitmapFile( _bstr_t( _T( "Switch-Active.bmp" ) ), &m_pSwitch ); + pPlugin->LoadBitmapFile( _bstr_t( _T( "Switch-Inactive.bmp" ) ), &m_pSwitchDisabled ); + BSTR bstrFontName; + pPlugin->get_FontName(&bstrFontName); + pPlugin->CreateFont( bstrFontName /*_bstr_t( _T( "Times New Roman" ) )*/, 14, 0, &m_pFont ); + m_nMinMax = 0; - m_pSite->put_Transparent( VARIANT_FALSE ); + m_pSite->put_Transparent( VARIANT_FALSE ); } void cSimpleBar::onDestroy() { - m_pSwitch.Release(); - m_pSwitchDisabled.Release(); - m_pFont.Release(); + m_pSwitch.Release(); + m_pSwitchDisabled.Release(); + m_pFont.Release(); } #define SWITCH_STRETCH_START 25 @@ -41,103 +41,106 @@ STDMETHODIMP cSimpleBar::Render(ICanvas *pCanvas) { - RECT rc; - m_pSite->get_Position( &rc ); + RECT rc; + m_pSite->get_Position( &rc ); - int nWidth = rc.right - rc.left; + int nWidth = rc.right - rc.left; - // First draw the background image - static POINT ptOrg = { 0, 0 }; - if( m_bSelected ) - m_pSwitch->StretchBlt( pCanvas, &ptOrg, nWidth, SWITCH_STRETCH_START, SWITCH_STRETCH_END ); - else - m_pSwitchDisabled->StretchBlt( pCanvas, &ptOrg, nWidth, SWITCH_STRETCH_START, SWITCH_STRETCH_END ); + // First draw the background image + static POINT ptOrg = { 0, 0 }; + if( m_bSelected ) + m_pSwitch->StretchBlt( pCanvas, &ptOrg, nWidth, SWITCH_STRETCH_START, SWITCH_STRETCH_END ); + else + m_pSwitchDisabled->StretchBlt( pCanvas, &ptOrg, nWidth, SWITCH_STRETCH_START, SWITCH_STRETCH_END ); - // Next the icon - CComPtr< IPluginSite > pPlugin; - m_pSite->get_PluginSite( &pPlugin ); + // Next the icon + CComPtr< IPluginSite > pPlugin; + m_pSite->get_PluginSite( &pPlugin ); - CComPtr< IIconCache > pIcons; - static SIZE szIcon = { ICON_SIZE, ICON_SIZE }; - pPlugin->GetIconCache( &szIcon, &pIcons ); + CComPtr< IIconCache > pIcons; + static SIZE szIcon = { ICON_SIZE, ICON_SIZE }; + pPlugin->GetIconCache( &szIcon, &pIcons ); - static POINT ptIcon = { 0, ICON_TOP }; - pIcons->DrawIcon( &ptIcon, m_nIconID, m_nIconModule, pCanvas ); + static POINT ptIcon = { 0, ICON_TOP }; + pIcons->DrawIcon( &ptIcon, m_nIconID, m_nIconModule, pCanvas ); - if (m_nMinMax == eStateMax) { - static POINT ptText = { ICON_SIZE + TEXT_ICON_GAP, TEXT_TOP }; - m_pFont->DrawText( &ptText, m_strLabel, ( m_bSelected ) ? RGB( 0, 0, 0 ) : RGB( 255, 255, 255 ), pCanvas ); - } + if (m_nMinMax == eStateMax) + { + static POINT ptText = { ICON_SIZE + TEXT_ICON_GAP, TEXT_TOP }; + m_pFont->DrawText( &ptText, m_strLabel, ( m_bSelected ) ? RGB( 0, 0, 0 ) : RGB( 255, 255, 255 ), pCanvas ); + } - _ASSERTMEM( _CrtCheckMemory( ) ); + _ASSERTMEM( _CrtCheckMemory( ) ); - return S_OK; + return S_OK; } STDMETHODIMP cSimpleBar::MouseEnter(MouseState *) { - m_bSelected = VARIANT_TRUE; - m_pSite->Invalidate(); + m_bSelected = VARIANT_TRUE; + m_pSite->Invalidate(); return S_OK; } STDMETHODIMP cSimpleBar::MouseExit(MouseState *) { - m_bSelected = VARIANT_FALSE; - m_pSite->Invalidate(); + m_bSelected = VARIANT_FALSE; + m_pSite->Invalidate(); return S_OK; } STDMETHODIMP cSimpleBar::MouseDown(MouseState *) { - CComPtr< IRootLayer > pRoot; + CComPtr< IRootLayer > pRoot; - m_pSite->GetParentSink( IID_IRootLayer, reinterpret_cast< void ** >( &pRoot ) ); + m_pSite->GetParentSink( IID_IRootLayer, reinterpret_cast< void ** >( &pRoot ) ); - _ASSERTE( pRoot.p != NULL ); + _ASSERTE( pRoot.p != NULL ); - long nID; - m_pSite->get_ID( &nID ); - pRoot->SelectBar( nID ); + long nID; + m_pSite->get_ID( &nID ); + pRoot->SelectBar( nID ); - return S_OK; + return S_OK; } STDMETHODIMP cSimpleBar::get_RenderWidth(long *nWidth) { - if (m_nMinMax == eStateMin) { - *nWidth = 20; - } else { + if (m_nMinMax == eStateMin) + { + *nWidth = 20; + } + else + { SIZE sz; - m_pFont->MeasureText( m_strLabel, &sz ); - - // Add in the requested size to the parent - *nWidth = sz.cx + TEXT_ICON_GAP + END_GAP + ICON_SIZE; - } + m_pFont->MeasureText( m_strLabel, &sz ); - return S_OK; + // Add in the requested size to the parent + *nWidth = sz.cx + TEXT_ICON_GAP + END_GAP + ICON_SIZE; + } + return S_OK; } STDMETHODIMP cSimpleBar::get_Params(ViewParams *pVal) { - USES_CONVERSION; + USES_CONVERSION; - pVal->icon = m_nIconID; - pVal->iconLibrary = m_nIconModule; - pVal->label = OLE2BSTR( m_strLabel ); - pVal->state = m_nMinMax; + pVal->icon = m_nIconID; + pVal->iconLibrary = m_nIconModule; + pVal->label = OLE2BSTR( m_strLabel ); + pVal->state = m_nMinMax; return S_OK; } STDMETHODIMP cSimpleBar::put_Params(ViewParams *newVal) { - m_nIconID = newVal->icon; - m_nIconModule = newVal->iconLibrary; - m_strLabel = newVal->label; - m_nMinMax = newVal->state; + m_nIconID = newVal->icon; + m_nIconModule = newVal->iconLibrary; + m_strLabel = newVal->label; + m_nMinMax = newVal->state; return S_OK; -} +} \ No newline at end of file Index: SimpleBar.h =================================================================== RCS file: /cvsroot/decaldev/source/Inject/SimpleBar.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- SimpleBar.h 24 Nov 2001 23:21:55 -0000 1.2 +++ SimpleBar.h 19 Nov 2003 19:19:14 -0000 1.3 @@ -3,7 +3,7 @@ #ifndef __SIMPLEBAR_H_ #define __SIMPLEBAR_H_ -#include "resource.h" // main symbols +#include "resource.h" // main symbols #include "SinkImpl.h" @@ -12,52 +12,52 @@ class ATL_NO_VTABLE cSimpleBar : public CComObjectRootEx<CComMultiThreadModel>, public ISimpleBar, - public cNoEventsImpl, - public ILayerImpl< cSimpleBar >, - public ILayerRenderImpl, - public ILayerMouseImpl + public cNoEventsImpl, + public ILayerImpl< cSimpleBar >, + public ILayerRenderImpl, + public ILayerMouseImpl { public: cSimpleBar() - : m_bSelected( VARIANT_FALSE ) + : m_bSelected( VARIANT_FALSE ) { } - _bstr_t m_strLabel; - long m_nIconModule; - long m_nIconID; - long m_nMinMax; + _bstr_t m_strLabel; + long m_nIconModule; + long m_nIconID; + long m_nMinMax; - VARIANT_BOOL m_bSelected; + VARIANT_BOOL m_bSelected; - CComPtr< IImageCache > m_pSwitch; - CComPtr< IImageCache > m_pSwitchDisabled; - CComPtr< IFontCache > m_pFont; + CComPtr< IImageCache > m_pSwitch; + CComPtr< IImageCache > m_pSwitchDisabled; + CComPtr< IFontCache > m_pFont; - void onCreate(); - void onDestroy(); + void onCreate(); + void onDestroy(); BEGIN_COM_MAP(cSimpleBar) - COM_INTERFACE_ENTRY(ILayerRender) - COM_INTERFACE_ENTRY(ILayerMouse) - COM_INTERFACE_ENTRY(ILayer) + COM_INTERFACE_ENTRY(ILayerRender) + COM_INTERFACE_ENTRY(ILayerMouse) + COM_INTERFACE_ENTRY(ILayer) COM_INTERFACE_ENTRY(ISimpleBar) END_COM_MAP() // ISimpleBar public: - // ISimpleBar Functions + // ISimpleBar Functions STDMETHOD(get_Params)(/*[out, retval]*/ ViewParams *pVal); STDMETHOD(put_Params)(/*[in]*/ ViewParams * newVal); STDMETHOD(get_RenderWidth)(long *nWidth); - // ILayerRender Functions + // ILayerRender Functions STDMETHOD(Render)(ICanvas *pCanvas); - // ILayerMouse Functions + // ILayerMouse Functions STDMETHOD(MouseEnter)(MouseState *); STDMETHOD(MouseExit)(MouseState *); - STDMETHOD(MouseDown)(MouseState *); + STDMETHOD(MouseDown)(MouseState *); }; #endif //__SIMPLEBAR_H_ |