[GME-commit] GMESRC/GME/MgaDecorators StereotypeDecorators.cpp,1.11,1.12

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Sat Jul 17 04:45:33 CDT 2004


Update of /var/lib/gme/GMESRC/GME/MgaDecorators
In directory braindrain:/tmp/cvs-serv24756

Modified Files:
	StereotypeDecorators.cpp 
Log Message:
Fixed calculations of text extent in the default decorator (JIRA GME-20)
.

CVS User: volgy

Index: StereotypeDecorators.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaDecorators/StereotypeDecorators.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** StereotypeDecorators.cpp	14 Nov 2003 08:28:01 -0000	1.11
--- StereotypeDecorators.cpp	17 Jul 2004 08:45:30 -0000	1.12
***************
*** 381,397 ****
  CRect DecoratorBase::getLabelLocation() const
  {
! 	LOGFONT logFont;
! 	getFacilities().getFont( m_iFontKey )->pFont->GetLogFont( &logFont );
  	CPoint pt = getLabelPosition();
  	ECoordRefPoint eAlign = getAlignment();
  
! 	int iX = 0;
! 	for ( int i = 0 ; i < m_vecName.size() ; i++ )
! 		iX = max( m_vecName[ i ].GetLength(), iX );
! 	CSize cSize( logFont.lfWidth * iX, logFont.lfHeight );
  	if ( eAlign == CRP_CENTER )
  		pt.x -= cSize.cx / 2;
  	else if ( eAlign == CRP_END )
  		pt.x -= cSize.cx;
  
  	return CRect( pt.x, pt.y, pt.x + cSize.cx, pt.y + cSize.cy );
--- 381,403 ----
  CRect DecoratorBase::getLabelLocation() const
  {
! 
  	CPoint pt = getLabelPosition();
  	ECoordRefPoint eAlign = getAlignment();
  
! 	CDC dc;
! 	dc.CreateCompatibleDC(NULL);
! 	dc.SelectObject(getFacilities().getFont( m_iFontKey )->pFont);
! 	CSize cSize(0,0);
! 	for ( int i = 0 ; i < m_vecName.size() ; i++ ) {
! 		CSize tmpSize = dc.GetTextExtent(m_vecName[ i ]);
! 		cSize.cy += tmpSize.cy;
! 		cSize.cx = max (cSize.cx, tmpSize.cx);
! 	}
! 
  	if ( eAlign == CRP_CENTER )
  		pt.x -= cSize.cx / 2;
  	else if ( eAlign == CRP_END )
  		pt.x -= cSize.cx;
+ 
  
  	return CRect( pt.x, pt.y, pt.x + cSize.cx, pt.y + cSize.cy );



More information about the GME-commit mailing list