From: Jeffrey D. <ha...@us...> - 2003-09-26 08:51:09
|
Log Message: ----------- Users now have the ability to set antialiasing off for static text (good for transparent views) and specify an outlinecolor for outlined text Modified Files: -------------- /cvsroot/decaldev/source/DecalControls: Static.cpp Static.h Revision Data ------------- Index: Static.cpp =================================================================== RCS file: /cvsroot/decaldev/source/DecalControls/Static.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Static.cpp 24 Sep 2003 01:28:48 -0000 1.6 +++ Static.cpp 26 Sep 2003 08:50:37 -0000 1.7 @@ -55,89 +55,122 @@ STDMETHODIMP cStatic::SchemaLoad(IView *pView, IUnknown *pSchema) { - CComPtr< IPluginSite > pPlugin; - m_pSite->get_PluginSite( &pPlugin ); + CComPtr< IPluginSite > pPlugin; + m_pSite->get_PluginSite( &pPlugin ); - pPlugin->CreateFontSchema( 14, 0, pSchema, &m_pFont ); + pPlugin->CreateFontSchema( 14, 0, pSchema, &m_pFont ); - MSXML::IXMLDOMElementPtr pElement = pSchema; + MSXML::IXMLDOMElementPtr pElement = pSchema; - _variant_t vText = pElement->getAttribute( _T( "text" ) ), + _variant_t vText = pElement->getAttribute( _T( "text" ) ), vTextColor = pElement->getAttribute( _T( "textcolor" ) ), vWidth = pElement->getAttribute( _T( "width" ) ), vHeight = pElement->getAttribute( _T( "height" ) ), - vJustify = pElement->getAttribute( _T( "justify" ) ); + vJustify = pElement->getAttribute( _T( "justify" ) ), + vOutline = pElement->getAttribute( _T( "outlinecolor" ) ), + vAntialias = pElement->getAttribute( _T( "aa" ) ); - // This is a required element - _ASSERTE( vText.vt == VT_BSTR ); + // This is a required element + _ASSERTE( vText.vt == VT_BSTR ); - // Store the text, assume left justification - m_strText = vText.bstrVal; - m_eJustify = eFontLeft; + // Store the text, assume left justification + m_strText = vText.bstrVal; + m_eJustify = eFontLeft; - // Determine the proper justification - if (vJustify.vt != VT_NULL) - { - _bstr_t bstrJustify = vJustify.bstrVal; - if (::_wcsicmp(L"left", bstrJustify) == 0) - { - m_eJustify = eFontLeft; - } - else if (::_wcsicmp(L"right", bstrJustify) == 0) - { - m_eJustify = eFontRight; - } - else if (::_wcsicmp(L"center", bstrJustify) == 0) - { - m_eJustify = eFontCenter; - } - } + // Determine the proper justification + if (vJustify.vt != VT_NULL) + { + _bstr_t bstrJustify = vJustify.bstrVal; + if (::_wcsicmp(L"left", bstrJustify) == 0) + { + m_eJustify = eFontLeft; + } + else if (::_wcsicmp(L"right", bstrJustify) == 0) + { + m_eJustify = eFontRight; + } + else if (::_wcsicmp(L"center", bstrJustify) == 0) + { + m_eJustify = eFontCenter; + } + } - // Determine the color - if( vTextColor.vt != VT_NULL ) - { - try - { - m_nTextColor = static_cast< long >( vTextColor ); - } - catch( ... ) - { - // Type conversion error - _ASSERTE( FALSE ); - } - } + // Determine the color + if( vTextColor.vt != VT_NULL ) + { + try + { + m_nTextColor = static_cast< long >( vTextColor ); + } + catch( ... ) + { + // Type conversion error + _ASSERTE( FALSE ); + } + } - /* - // Set the width of the static (not same as text width) - if( vWidth.vt != VT_NULL ) - { - try - { - m_nWidth = static_cast< long >( vWidth ); - } - catch( ... ) - { - // Type conversion error - _ASSERTE( FALSE ); - } - } + m_nOutlineColor = 0; + m_bOutline = false; + if( vOutline.vt != VT_NULL ) + { + try + { + m_bOutline = true; + m_nOutlineColor = static_cast< long >( vOutline ); + } + catch( ... ) + { + // Type conversion error + _ASSERTE( FALSE ); + } + } - // Set the height of the static (not same as text height or fontsize) - if( vHeight.vt != VT_NULL ) - { - try - { - m_nHeight = static_cast< long >( vHeight ); - } - catch( ... ) - { - // Type conversion error - _ASSERTE( FALSE ); - } - } - */ + m_bAA = true; + if( vAntialias.vt != VT_NULL ) + { + try + { + m_bAA = static_cast< bool >( vAntialias ); + } + catch( ... ) + { + // Type conversion error + _ASSERTE( FALSE ); + } + } - return S_OK; + + /* + // Set the width of the static (not same as text width) + if( vWidth.vt != VT_NULL ) + { + try + { + m_nWidth = static_cast< long >( vWidth ); + } + catch( ... ) + { + // Type conversion error + _ASSERTE( FALSE ); + } + } + + // Set the height of the static (not same as text height or fontsize) + if( vHeight.vt != VT_NULL ) + { + try + { + m_nHeight = static_cast< long >( vHeight ); + } + catch( ... ) + { + // Type conversion error + _ASSERTE( FALSE ); + } + } + */ + + return S_OK; } STDMETHODIMP cStatic::Render( ICanvas *pCanvas ) @@ -327,5 +360,13 @@ break; } - m_pFont->DrawText( &pt, szText, m_nTextColor, pCanvas ); + long lFlags = 0; + + if( m_bAA ) + lFlags |= eAA; + + if( m_bOutline ) + lFlags |= eOutlined; + + m_pFont->DrawTextEx( &pt, szText, m_nTextColor, m_nOutlineColor, lFlags, pCanvas ); } Index: Static.h =================================================================== RCS file: /cvsroot/decaldev/source/DecalControls/Static.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Static.h 22 Sep 2003 02:56:51 -0000 1.4 +++ Static.h 26 Sep 2003 08:50:37 -0000 1.5 @@ -23,7 +23,7 @@ { public: cStatic() - : m_nTextColor( RGB( 0, 0, 0 ) ) + : m_nTextColor( RGB( 0, 0, 0 ) ) { } @@ -32,6 +32,9 @@ CComPtr< IFontCache > m_pFont; _bstr_t m_strText; long m_nTextColor; + long m_nOutlineColor; + bool m_bAA; + bool m_bOutline; //long m_nWidth; //long m_nHeight; eFontJustify m_eJustify; |