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

📄 ssdtripleclassbox.c

📁 这个工具集提供以下结构化分析和UML分析中所用的图形化绘图工具:ER-diagrams, data and event flow diagrams and state-transition diagr
💻 C
📖 第 1 页 / 共 2 页
字号:
//------------------------------------------------------------------------------//// This file is part of Toolkit for Conceptual Modeling (TCM).// (c) copyright 1999, Vrije Universiteit Amsterdam and University of Twente.// Author: Frank Dehne (frank@cs.vu.nl).// Author: Henk van de Zandschulp (henkz@cs.utwente.nl).//// TCM is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by// the Free Software Foundation; either version 2 of the License, or// (at your option) any later version.//// TCM is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License// along with TCM; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.//-----------------------------------------------------------------------------#include "lstring.h"#include "grafport.h"#include "ssdsingleclassbox.h"#include "ssdtripleclassbox.h"#include "ssddoubleclassbox.h"#include "ssdclassnode.h"#include "diagramviewer.h"#include "inputfile.h"#include "outputfile.h"SSDTripleClassBox::SSDTripleClassBox(ShapeView *v, Grafport *g, int x, int y, 		int w, int h): TripleClassBox(v, g, x, y, w, h) {        stereotypeLabel = new TextShape(v, g, this);        stereotypeLabel->SetOneLine(True);        stereotypeLabel->SetDescription("Stereotype");	string my_stereo = "<<SSDTripleClassBox>>";        stereotypeLabel->SetString(&my_stereo);        propertiesLabel = new TextShape(v, g, this);        propertiesLabel->SetOneLine(False);        propertiesLabel->SetDescription("Properties");        string my_props = "{ SSDTripleClassBox }";        propertiesLabel->SetString(&my_props);	showStereotype = False;        showProperties = False;	SetSize(w, RequiredHeight());}SSDTripleClassBox::~SSDTripleClassBox() {        delete stereotypeLabel;        delete propertiesLabel;}SSDTripleClassBox::SSDTripleClassBox(const SSDTripleClassBox &s): 						TripleClassBox(s) {	showStereotype = s.showStereotype;        showProperties = s.showProperties;        stereotypeLabel = new TextShape(*(s.stereotypeLabel));        propertiesLabel = new TextShape(*(s.propertiesLabel));	stereotypeLabel->SetParent(this);	propertiesLabel->SetParent(this);        SetSize(s.GetWidth(), s.GetHeight());}SSDTripleClassBox::SSDTripleClassBox(const SSDDoubleClassBox &s): 						TripleClassBox(s) {	showStereotype = s.IsShowStereotype();        showProperties = s.IsShowProperties();        stereotypeLabel = new TextShape(*s.GetStereotypeLabel());        propertiesLabel = new TextShape(*s.GetPropertiesLabel());	stereotypeLabel->SetParent(this);	propertiesLabel->SetParent(this);        SetTextShape();        AdjustSizes(GetName()->GetString());}SSDTripleClassBox::SSDTripleClassBox(const SSDSingleClassBox &s): 						TripleClassBox(s) {	showStereotype = s.IsShowStereotype();        showProperties = s.IsShowProperties();        stereotypeLabel = new TextShape(*s.GetStereotypeLabel());        propertiesLabel = new TextShape(*s.GetPropertiesLabel());	stereotypeLabel->SetParent(this);	propertiesLabel->SetParent(this);	SetTextShape();        AdjustSizes(GetName()->GetString());}void SSDTripleClassBox::SetGrafport(Grafport *g) {        TripleClassBox::SetGrafport(g);        stereotypeLabel->SetGrafport(g);        propertiesLabel->SetGrafport(g);}void SSDTripleClassBox::SetView(ShapeView *v) {        TripleClassBox::SetView(v);        stereotypeLabel->SetView(v);        propertiesLabel->SetView(v);}bool SSDTripleClassBox::HasTextShape(TextShape *t) const {        if (TripleClassBox::HasTextShape(t))                return True;	if (GetStereotypeLabel() == t)                return True;        if (GetPropertiesLabel() == t)                return True;        return False;}bool SSDTripleClassBox::HasString(const string *s, bool sens, bool sub) const {        if (TripleClassBox::HasString(s, sens, sub))                return True;        if (showStereotype && stereotypeLabel->HasString(s, sens, sub))                return True;        if (showProperties && propertiesLabel->HasString(s, sens, sub))                return True;        return False;} bool SSDTripleClassBox::HasString(const string *s, bool sens, bool sub,                        List<TextShape *> *list) {        bool b = TripleClassBox::HasString(s, sens, sub, list);        if (showStereotype && stereotypeLabel->HasString(s, sens, sub, list))                b = True;        if (showProperties && propertiesLabel->HasString(s, sens, sub, list))                b = True;        return b;}void SSDTripleClassBox::SetTextShape() {	TripleClassBox::SetTextShape();	if (!check(GetSubject() &&             GetSubject()->GetClassType()==Code::SSD_CLASS_NODE))                return;        GetStereotypeLabel()->SetString(                        ((SSDClassNode *)GetSubject())->GetStereotype());        GetStereotypeLabel()->SetParent(this);        GetPropertiesLabel()->SetString(                        ((SSDClassNode *)GetSubject())->GetProperties());        GetPropertiesLabel()->SetParent(this);//	CalcPositionLabels();}void SSDTripleClassBox::SetFont(XFont *ft) {        TripleClassBox::SetFont(ft);        stereotypeLabel->SetFont(ft);        propertiesLabel->SetFont(ft);//	CalcPositionLabels();} void SSDTripleClassBox::SetTextColor(const string *c) {        TripleClassBox::SetTextColor(c);        stereotypeLabel->SetColor(c);        propertiesLabel->SetColor(c);}void SSDTripleClassBox::UpdateShowStereotype(bool b) {        if (b == showStereotype)                return;        if (IsVisible())                Undraw();        showStereotype = b;//	CalcPositionLabels();        if (IsVisible())                Draw();} void SSDTripleClassBox::UpdateShowProperties(bool b) {        if (b == showProperties)                return;        if (IsVisible())                Undraw();        showProperties = b;//	CalcPositionLabels();        if (IsVisible())                Draw();}void SSDTripleClassBox::DrawTextShapes() {        string oldBackground;        Grafport *g = GetGrafport();        if (GetFillStyle() != FillStyle::UNFILLED) {                oldBackground = *g->GetBackgroundColor();                g->SetBackgroundColor(GetFillColor()->getstr());        }	NodeShape::DrawTextShapes();        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        int snpHeight = (addLines+labelLines) * textHeight;        int dboxHeight = DoubleBoxHeight();	if (snpHeight < GetHeight()) {		g->DrawLine(GetLeftMost()+1, GetTopMost()+snpHeight+1,			GetRightMost()-1,			GetTopMost()+snpHeight+1);		g->SetLineStyle(GetLineStyle());	}	int i = snpHeight;	for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {		i += textHeight;		if (i < GetHeight())			GetLabels()->cur()->Draw();	}	if (dboxHeight < GetHeight()) {		g->SetLineStyle(GetSeparatorLineStyle());		g->DrawLine(GetLeftMost()+1, GetTopMost()+dboxHeight,			GetRightMost()-1,			GetTopMost()+dboxHeight);		g->SetLineStyle(GetLineStyle());	}	i = dboxHeight;	for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {		i += textHeight;		if (i < GetHeight())			GetLabels2()->cur()->Draw();	}	if (GetFillStyle() != FillStyle::UNFILLED)		g->SetBackgroundColor(oldBackground.getstr());	if (showStereotype)		stereotypeLabel->Draw();	if (showProperties)		propertiesLabel->Draw();}void SSDTripleClassBox::AdjustSize() {        int twd = RequiredWidth();        int ht = RequiredHeight();        if (twd > GetWidth() || ht != GetHeight()) {                int wd = max((twd+2*TEXTMARGIN), GetWidth());                UpdateSize(wd, ht);                GetViewer()->ShapePositionUpdate(this);	}//	else//		CalcPositionLabels();}void SSDTripleClassBox::AdjustSizes(const string *) {        if (!GetViewer()->IsAutoResize()) {//		CalcPositionLabels();                return;        }        int twd = RequiredWidth();        int ht = RequiredHeight();        if (twd > GetWidth() || GetHeight() != ht) {                int wd = max((twd+2*TEXTMARGIN), GetWidth());                SetSize(wd, ht);                GetViewer()->ShapePositionUpdate(this);        }//	else//		CalcPositionLabels();}void SSDTripleClassBox::CalcPositionLabels() {	TripleClassBox::CalcPositionLabels();	Point pt = *GetPosition();	// calculate labelnameHeight first        int textHeight = GetName()->GetFontHeight();	int addLines = (showStereotype ? 1 : 0);	// min_firstboxlines : 2 when no <<stereotype>> / {props} shown	int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);	int nameHeight = labelLines * textHeight;	// calculate first_compartmentHeight        if (showProperties)                addLines += GetPropertiesLabelString()->lines();        int snpHeight = (addLines+labelLines) * textHeight;        if (showStereotype)                pt.y = GetTopMost() + textHeight + nameHeight/2;        else

⌨️ 快捷键说明

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