From: Todd D. P. <ci...@us...> - 2003-09-22 02:56:53
|
Log Message: ----------- Fixes resizing issues with IStatic. Originally control was caching width and height and ignoring new values, so resizing wouldn't make text appear like it should if clipped. All better now :) 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.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Static.cpp 24 Jul 2002 03:56:34 -0000 1.4 +++ Static.cpp 22 Sep 2003 02:56:51 -0000 1.5 @@ -107,6 +107,7 @@ } } + /* // Set the width of the static (not same as text width) if( vWidth.vt != VT_NULL ) { @@ -134,6 +135,7 @@ _ASSERTE( FALSE ); } } + */ return S_OK; } @@ -161,17 +163,22 @@ m_pFont->MeasureText(strText, &Size); int height = Size.cy; - if(Size.cx > m_nWidth) + RECT rcPos; + m_pSite->get_Position(&rcPos); + int nWidth = rcPos.right - rcPos.left; + int nHeight = rcPos.bottom - rcPos.top; + + if(Size.cx > nWidth) { for( token = ::strtok( (char*)strText, " " ); token !=NULL; token = ::strtok( NULL, " " ) ) { m_pFont->MeasureText(temp + _bstr_t(token), &Size); - if(Size.cx > m_nWidth) + if(Size.cx > nWidth) { DrawText( &ptText, temp, pCanvas ); ptText.y+=height;//14; - if(ptText.y+height>m_nHeight) + if(ptText.y+height>nHeight) return S_OK; temp = _bstr_t(token) + _bstr_t(" "); } @@ -213,6 +220,11 @@ { POINT pt = *ppt; + RECT rcPos; + m_pSite->get_Position(&rcPos); + int nWidth = rcPos.right - rcPos.left; + int nHeight = rcPos.bottom - rcPos.top; + // Act based on justification style switch (m_eJustify) { @@ -220,7 +232,7 @@ { SIZE Size; m_pFont->MeasureText(szText, &Size); - pt.x = m_nWidth - Size.cx; + pt.x = nWidth - Size.cx; } break; @@ -228,7 +240,7 @@ { SIZE Size; m_pFont->MeasureText(szText, &Size); - pt.x = (m_nWidth / 2) - (Size.cx / 2); + pt.x = (nWidth / 2) - (Size.cx / 2); } break; Index: Static.h =================================================================== RCS file: /cvsroot/decaldev/source/DecalControls/Static.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Static.h 16 Mar 2002 23:45:19 -0000 1.3 +++ Static.h 22 Sep 2003 02:56:51 -0000 1.4 @@ -32,8 +32,8 @@ CComPtr< IFontCache > m_pFont; _bstr_t m_strText; long m_nTextColor; - long m_nWidth; - long m_nHeight; + //long m_nWidth; + //long m_nHeight; eFontJustify m_eJustify; DECLARE_REGISTRY_RESOURCEID(IDR_STATIC) |