⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 umllinesegment.cpp

📁 uml编辑器很牛
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		CString label;
		CDC* dc = CWnd::GetDesktopWindow()->GetDC();
		CFont font;
		font.CreateFont( -12, 0,0,0,FW_NORMAL,0,0,0,0,0,0,0,0, GetFont() );
		CFont* oldfont = dc->SelectObject( &font );
		CString str = GetTitle();
		int cut = GetMarkerSize().cx / 2;
		if( str.GetLength() )
		{
			CRect rectTemp = GetRect();
			rectTemp.NormalizeRect();
			CRect r( rect.right - cut, rect.top, rect.right - ( rectTemp.Width() + cut ), rect.bottom );
			if( IsHorizontal() )
			{
				CRect r( rect.left, rect.top - ( 14 + cut ), rect.right, rect.bottom );
				r.NormalizeRect();
				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:center;'>%s</div>" ), 
					r.left, r.top, r.Width(), r.Height(), GetFont(), str );
				result += label;
			}
			else
			{
				CRect r( rect.right - ( dc->GetTextExtent( str ).cx + cut * 2 ), rect.top, rect.right - cut, rect.bottom );
				r.NormalizeRect();
				r.top += r.Height() / 2 - 7;
				r.bottom = r.top + 14;
				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
					r.left, r.top, r.Width(), r.Height(), GetFont(), str );
				result += label;
			}

		}

		str = GetStartLabel();
		if( str.GetLength() )
		{
			CRect rectTemp = GetRect();
			if( IsHorizontal() )
			{
				rectTemp.bottom = rectTemp.top - cut;
				rectTemp.top -= 14 + cut;

				if( rectTemp.left < rectTemp.right )
				{
					rectTemp.left += cut;
					rectTemp.right -= cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}
				else
				{
					int temp = rectTemp.left;
					rectTemp.left = rectTemp.right + cut;
					rectTemp.right = temp - cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:left;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}

			}
			else
			{
				rectTemp.left -= dc->GetTextExtent( str ).cx + 2 * cut;
				rectTemp.right -= cut;
				if( rectTemp.top < rectTemp.bottom )
					rectTemp.bottom = rectTemp.top + 14;
				else
				{
					rectTemp.top -= 14;
					rectTemp.bottom = rectTemp.top + 14;
				}

				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
					rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
				result += label;
			}

		}

		str = GetSecondaryStartLabel();
		if( str.GetLength() )
		{
			CRect rectTemp = GetRect();
			if( IsHorizontal() )
			{
				rectTemp.bottom += 14 + cut;
				rectTemp.top += cut;

				if( rectTemp.left < rectTemp.right )
				{
					rectTemp.left += cut;
					rectTemp.right -= cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}
				else
				{
					int temp = rectTemp.left;
					rectTemp.left = rectTemp.right + cut;
					rectTemp.right = temp - cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:left;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}

			}
			else
			{
				rectTemp.right += dc->GetTextExtent( str ).cx + 2 * cut;
				rectTemp.left += cut;

				if( rectTemp.top < rectTemp.bottom )
					rectTemp.bottom = rectTemp.top + 14;
				else
				{
					rectTemp.top -= 14;
					rectTemp.bottom = rectTemp.top + 14;
				}

				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
					rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
				result += label;
			}

		}

		str = GetEndLabel();
		if( str.GetLength() )
		{
			CRect rectTemp = GetRect();
			if( IsHorizontal() )
			{
				rectTemp.bottom = rectTemp.top - cut;
				rectTemp.top -= 14 + cut;

				if( rectTemp.left < rectTemp.right )
				{
					rectTemp.left += cut;
					rectTemp.right -= cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:left;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}
				else
				{
					int temp = rectTemp.left;
					rectTemp.left = rectTemp.right + cut;
					rectTemp.right = temp - cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}

			}
			else
			{
				rectTemp.left -= dc->GetTextExtent( str ).cx + 2 * cut;
				rectTemp.right -= cut;
				if( rectTemp.top < rectTemp.bottom )
					rectTemp.top = rectTemp.bottom - 14;
				else
				{
					rectTemp.top = rectTemp.bottom;
					rectTemp.bottom = rectTemp.top + 14;
				}
				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
					rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
				result += label;
			}
		}

		str = GetSecondaryEndLabel();
		if( str.GetLength() )
		{
			CRect rectTemp = GetRect();
			if( IsHorizontal() )
			{
				rectTemp.bottom += 14 + cut;
				rectTemp.top += cut;

				if( rectTemp.left < rectTemp.right )
				{
					rectTemp.left += cut;
					rectTemp.right -= cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:left;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}
				else
				{
					int temp = rectTemp.left;
					rectTemp.left = rectTemp.right + cut;
					rectTemp.right = temp - cut;
					label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
						rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
					result += label;
				}

			}
			else
			{
				rectTemp.right += dc->GetTextExtent( str ).cx + 2 * cut;
				rectTemp.left += cut;
				if( rectTemp.top < rectTemp.bottom )
					rectTemp.top = rectTemp.bottom - 14;
				else
				{
					rectTemp.top = rectTemp.bottom;
					rectTemp.bottom = rectTemp.top + 14;
				}
				label.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;font-family:%s;font-size:12;background-color:transparent;text-align:right;'>%s</div>" ), 
					rectTemp.left, rectTemp.top, rectTemp.Width(), rectTemp.Height(), GetFont(), str );
				result += label;
			}
		}

		dc->SelectObject( oldfont );
		CWnd::GetDesktopWindow()->ReleaseDC( dc );
	}

	return result;

}

CString CUMLLineSegment::GetArrowHeadHTML() const
/* ============================================================
	Function :		CUMLLineSegment::GetArrowHeadHTML
	Description :	Gets a string representing the inheritance
					arrow picture for HTML-exports.
	Access :		Private
					
	Return :		CString	-	The string in HTML-format.
	Parameters :	none

	Usage :			Called as a part of the export mechanism.

   ============================================================*/
{

	BOOL invert = TRUE;
	if( !( GetLinkType( LINK_END ) & LINK_ALL ) && 
		( GetLinkType( LINK_START ) & LINK_ALL ) )
		invert = FALSE;

	CString img;
	CRect marker = GetRect();

	int width = 0;
	int height = 0;

	CSize size( 17, 9 );
	if( IsHorizontal() )
	{
		width = size.cx;
		height = size.cy;
		if( !invert )
		{
			if( marker.right > marker.left )
				img = _T( "images/larrow.gif" );
			else
				img = _T( "images/rarrow.gif" );
		}
		else
		{
			if( marker.right < marker.left )
				img = _T( "images/larrow.gif" );
			else
				img = _T( "images/rarrow.gif" );
		}
	}
	else
	{
		width = size.cy;
		height = size.cx;
		if( !invert )
		{
			if( marker.bottom > marker.top )
				img = _T( "images/uarrow.gif" );
			else
				img = _T( "images/darrow.gif" );
		}
		else
		{
			if( marker.bottom < marker.top )
				img = _T( "images/uarrow.gif" );
			else
				img = _T( "images/darrow.gif" );
		}
	}

	CPoint pos = GetStyleMarkerRect( LINK_END, size );

	CString arrow;
	arrow.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;background-image:url(\"%s\");background-repeat:no-repeat;'>&nbsp;</div>" ),
		pos.x, pos.y, width, height, img );

	return arrow;

}

CString CUMLLineSegment::GetFilledArrowHeadHTML() const
/* ============================================================
	Function :		CUMLLineSegment::GetFilledArrowHeadHTML
	Description :	Gets a string representing the single-direction  
					arrow picture for HTML-exports.
	Access :		Private
					
	Return :		CString	-	The string in HTML-format.
	Parameters :	none

	Usage :			Called as a part of the export mechanism.

   ============================================================*/
{

	BOOL invert = FALSE;
	if( !( GetLinkType( LINK_START ) & LINK_ALL ) && 
		( GetLinkType( LINK_END ) & LINK_ALL ) )
		invert = TRUE;

	CString img;
	CRect marker = GetRect();

	int width = 0;
	int height = 0;

	CSize size( 17, 9 );
	if( IsHorizontal() )
	{
		width = size.cx;
		height = size.cy;
		if( !invert )
		{
			if( marker.right < marker.left )
				img = _T( "images/rfarrow.gif" );
			else
				img = _T( "images/lfarrow.gif" );
		}
		else
		{
			if( marker.right > marker.left )
				img = _T( "images/rfarrow.gif" );
			else
				img = _T( "images/lfarrow.gif" );
		}
	}
	else
	{
		width = size.cy;
		height = size.cx;
		if( !invert )
		{
			if( marker.bottom < marker.top )
				img = _T( "images/dfarrow.gif" );
			else
				img = _T( "images/ufarrow.gif" );
		}
		else
		{
			if( marker.bottom > marker.top )
				img = _T( "images/dfarrow.gif" );
			else
				img = _T( "images/ufarrow.gif" );
		}
	}

	CPoint pos = GetStyleMarkerRect( LINK_START, size );

	CString arrow;
	arrow.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;background-image:url(\"%s\");background-repeat:no-repeat;'>&nbsp;</div>" ),
		pos.x, pos.y, width, height, img );

	return arrow;

}

CString CUMLLineSegment::GetFilledDiamondHTML() const
/* ============================================================
	Function :		CUMLLineSegment::GetFilledDiamondHTML
	Description :	Gets a string representing the containment 
					picture for HTML-exports.
	Access :		Private
					
	Return :		CString	-	The string in HTML-format.
	Parameters :	none

	Usage :			Called as a part of the export mechanism.

   ============================================================*/
{

	CString img;

	int width = 0;
	int height = 0;

	CSize size( 16, 9 );
	if( IsHorizontal() )
	{
		width = size.cx;
		height = size.cy;
		img = _T( "images/lrdiamond.gif" );
	}
	else
	{
		width = size.cy;
		height = size.cx;
		img = _T( "images/uddiamond.gif" );
	}

	CPoint pos = GetStyleMarkerRect( LINK_END, size );

	CString arrow;
	arrow.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;background-image:url(\"%s\");background-repeat:no-repeat;'>&nbsp;</div>" ),
		pos.x, pos.y, width, height, img );

	return arrow;

}

CString CUMLLineSegment::GetCircleCrossHTML() const
/* ============================================================
	Function :		CUMLLineSegment::GetCircleCrossHTML
	Description :	Gets a string representing the part-of 
					picture for HTML-exports.
	Access :		Private
					
	Return :		CString	-	The string in HTML-format.
	Parameters :	none

	Usage :			Called as a part of the export mechanism.

   ============================================================*/
{

	CString img( _T( "images/partof.gif" ) );

	CSize marker( 16, 16 );
	CPoint pos = GetStyleMarkerRect( LINK_END, marker );

	CString arrow;
	arrow.Format( _T( "<div style='position:absolute;left:%i;top:%i;width:%i;height:%i;background-image:url(\"%s\");background-repeat:no-repeat;'>&nbsp;</div>" ),
		pos.x, pos.y, marker.cx, marker.cy, img );

	return arrow;

}

CPoint CUMLLineSegment::GetStyleMarkerRect( int node, const CSize& size ) const
/* ============================================================
	Function :		CUMLLineSegment::GetStyleMarkerRect
	Description :	The function returns a the start point for 
					a rectangle with the size "size" for either 
					the start or end of a line.
	Access :		Private
					
	Return :		CPoint				-	The start point
	Parameters :	int node			-	Either "LINK_START" 
											or "LINK_END" for the 
											start or end of the 
											line.
					const CSize& size	-	The size of the 
											rectangle.
					
	Usage :			Call to get the position of a rectangle to 
					draw markers at either the start or the end 
					of a line segment.

   ============================================================*/
{

	CPoint result( 0, 0 );

	int invers = LINK_START;
	if( node == LINK_START )
		invers = LINK_END;

	// We try to find what end of the segment is 
	// really the start/end, that is the end where 
	// a non

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -