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

📄 umlentityclass.cpp

📁 uml编辑器很牛
💻 CPP
字号:
/* ==========================================================================
	Class :			CUMLEntityClass

	Author :		Johan Rosengren, Abstrakt Mekanik AB

	Date :			2004-04-29

	Purpose :		"CUMLEntityClass", derived from "CUMLEntity", 
					represents an UML class box. 	

	Description :	The class implements the necessary functions for 
					cloning and creation from text ("Clone" and 
					"CreateFromString"). It draws a rectangle using the 
					title attribute of "CDiagramEntity" as the text 
					contents. The box can link from all four sides.
					The class contains separate arrays for the properties, 
					operations and attributes of this class ("CPropertyContainer", 
					"COperationContainer" and "CAttributeContainer" 
					respectively).

	Usage :			When loading, create with "CUMLControlFactory::CreateFromString". 
					Otherwise, create instances in the application view or dialog and 
					add them to the editor with "StartDrawingObject". The 
					editor takes responsibility for the object.
   ========================================================================
	Changes:		8/7 2004	Changed base class handling in c++-export 
								from "CString" to "CStringArray" to support 
								multiple inheritance
					9/7 2004	Setting baseclass(es) to baseClass property 
								when importing class from h-file.
					12/7 2004	Checking for void return type (n0mer)
   ========================================================================*/

#include "stdafx.h"
#include "UMLEntityClass.h"
#include "UMLEntityContainer.h"
#include "StringHelpers.h"

#include "TextFile/TextFile.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

CUMLEntityClass::CUMLEntityClass()
/* ============================================================
	Function :		CUMLEntityClass::CUMLEntityClass
	Description :	Constructor
	Access :		Public
					
	Return :		void
	Parameters :	none

	Usage :			Create either through "CUMLControlFactory" or
					by calling "new" and adding the pointer to the
					editor via "StartDrawingObject"

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

	SetDefaultSize( CSize( 128, 64 ) );
	SetConstraints( GetDefaultSize(), CSize( -1, -1 ) );
	SetBkColor( RGB( 255, 255, 217 ) );
	SetType( _T( "uml_class" ) );

	CString title;
	title.LoadString( IDS_UML_CLASS );
	SetTitle( title );

	SetPropertyDialog( &m_dlg, CUMLClassPropertyDialog::IDD );

	CalcRestraints();

}

CUMLEntityClass::~CUMLEntityClass()
/* ============================================================
	Function :		CUMLEntityClass::~CUMLEntityClass
	Description :	Destructor
	Access :		Public
					
	Return :		void
	Parameters :	none

	Usage :			Note that objects will normally be deleted by
					the container.

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

	if( m_dlg.m_hWnd )
		m_dlg.DestroyWindow();

	ClearAttributes();
	ClearOperations();
	ClearProperties();

}

void CUMLEntityClass::Draw( CDC* dc, CRect rect )
/* ============================================================
	Function :		CUMLEntityClass::Draw
	Description :	Draws the object.
	Access :		Public

	Return :		void
	Parameters :	CDC* dc		-	The "CDC" to draw to. 
					CRect rect	-	The real rectangle of the 
									object.

	Usage :			The function should clean up all selected 
					objects. Note that the "CDC" is a memory "CDC", 
					so creating a memory "CDC" in this function 
					will probably not speed up the function.

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

	int cut = round( static_cast< double >( GetMarkerSize().cx ) * GetZoom() );
	CRect r( rect.left + cut, rect.top + cut / 2, rect.right - cut, rect.bottom - cut / 2 );

	////////////////////////////////////////////////////////////////////
	// The box
	//

	dc->SelectStockObject( BLACK_PEN );
	CBrush bk;
	bk.CreateSolidBrush( GetBkColor() );
	dc->SelectObject( &bk );

	int mode = dc->SetBkMode( TRANSPARENT );
	int height = round( 12.0 * GetZoom() );

	dc->Rectangle( rect );

	////////////////////////////////////////////////////////////////////
	// Set up
	//

	CFont font;
	font.CreateFont( -height, 0,0,0,FW_NORMAL,0,0,0,0,0,0,0,0, GetFont() );
	CFont fontItalic;
	fontItalic.CreateFont( -height, 0,0,0,FW_NORMAL,TRUE,0,0,0,0,0,0,0, GetFont() );
	CFont fontUnderline;
	fontUnderline.CreateFont( -height, 0,0,0,FW_NORMAL,0,TRUE,0,0,0,0,0,0, GetFont() );
	CFont fontBold;
	fontBold.CreateFont( -height, 0,0,0,FW_BOLD,0,0,0,0,0,0,0,0, GetFont() );
	CFont fontBoldItalic;
	fontBoldItalic.CreateFont( -height, 0,0,0,FW_BOLD,TRUE,0,0,0,0,0,0,0, GetFont() );
	CFont fontBoldUnderline;
	fontBoldUnderline.CreateFont( -height, 0,0,0,FW_BOLD,0,TRUE,0,0,0,0,0,0, GetFont() );
	CFont fontUnderlineItalic;
	fontUnderlineItalic.CreateFont( -height, 0,0,0,FW_NORMAL,TRUE,TRUE,0,0,0,0,0,0, GetFont() );

	height = round( 14.0 * GetZoom() );

	CFont* oldfont = NULL;
	oldfont = dc->SelectObject( &fontBold );

	////////////////////////////////////////////////////////////////////
	// Title
	//

	int lines = 1;
	CString stereotype = GetStereotype();
	if( stereotype.GetLength() )
	{
		stereotype = _T( "

⌨️ 快捷键说明

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