📄 ssddoubleclassbox.c
字号:
GetViewer()->ShapePositionUpdate(this); }// else// CalcPositionLabels();}void SSDDoubleClassBox::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 SSDDoubleClassBox::CalcPositionLabels() { DoubleClassBox::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 pt.y = GetTopMost() + nameHeight/2; GetName()->SetPosition(&pt); pt.y = GetTopMost() + snpHeight; pt.y += (3*textHeight)/4; for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) { TextShape *t = GetLabels()->cur(); // position and left adjust textshape int w = t->GetStringWidth(); pt.x = GetLeftMost() + w/2 + TEXTMARGIN; t->SetPosition(&pt); pt.y += textHeight; } // set index label position. pt.x = GetName()->GetPosition()->x + GetWidth()*5/12; pt.y = GetName()->GetPosition()->y - nameHeight/4; GetIndexLabel()->SetPosition(&pt); if (showStereotype) CalcPositionStereotypeLabel(); if (showProperties) CalcPositionPropertiesLabel();}void SSDDoubleClassBox::CalcPositionStereotypeLabel() { int textHeight = GetName()->GetFontHeight(); Point pt; pt.x = GetPosition()->x; pt.y = GetTopMost() + textHeight/2; stereotypeLabel->SetPosition(&pt);}void SSDDoubleClassBox::CalcPositionPropertiesLabel() { // 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 snHeight = (addLines+labelLines) * textHeight; int propHeight = (showProperties ? GetPropertiesLabelString()->lines()*textHeight : 0); Point pt; pt.x = GetPosition()->x; pt.y = GetTopMost() + snHeight + propHeight/2; propertiesLabel->SetPosition(&pt);}int SSDDoubleClassBox::RequiredHeight() { 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 ht = (snpHeight + textHeight + GetLabels()->count()*textHeight);// return max(ht, GetInitialHeight()); return ht;}int SSDDoubleClassBox::RequiredWidth() { int twidth = GetName()->GetWidth(); if (showStereotype) twidth = max(twidth, GetStereotypeLabel()->GetWidth()); if (showProperties) twidth = max(twidth, GetPropertiesLabel()->GetWidth()); // Labels for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) { int wd = GetLabels()->cur()->GetStringWidth(); twidth = max(twidth, wd); } return twidth;}TextShape *SSDDoubleClassBox::ChooseTextShape(int x, int y) { // in first part (of the class name) ? // calculate #labelnameLines 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 snHeight = (addLines+labelLines) * textHeight; // calculate first_compartmentHeight if (showProperties) addLines += GetPropertiesLabelString()->lines(); int snpHeight = (addLines+labelLines) * textHeight; int pos_y = GetTopMost() + snpHeight; if (y <= pos_y) { if (showStereotype) { if (y <= GetTopMost() + textHeight) return GetStereotypeLabel(); } if (GetViewer()->IsShowIndexes() && !IsFixedIndexLabel()) { if (y <= GetName()->GetPosition()->y && x >= GetName()->GetPosition()->x + GetWidth()/3) return GetIndexLabel(); } if (y > GetTopMost() + snHeight) return GetPropertiesLabel(); if (!IsFixedName()) return GetName(); } // in labels part ?? pos_y += textHeight/2; for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) { pos_y += textHeight; if (pos_y >= GetTopMost() + GetHeight()) return 0; else if (y <= pos_y) return GetLabels()->cur(); } if (GetViewer()->IsEditing()) return 0; // somewhere down the list; create a new label. TextShape *t = new TextShape(GetView(), GetGrafport(), this); t->SetAlignment(TextAlign::LEFT); t->SetSequence(GetLabels()->count()); t->SetDescription(&labelDescription); t->SetFont(GetName()->GetFont()); t->SetColor(GetName()->GetColor()); Undraw(); GetLabels()->add(t);// CalcPositionLabels(); // move text shape to a better position. Point pt = *t->GetPosition(); pt.x += GetWidth()/2 - TEXTMARGIN; t->SetPosition(&pt); Draw(); return t;}void SSDDoubleClassBox::UpdateStereotypeLabelString(const string *s) { if (IsVisible()) Undraw(); SetStereotypeLabelString(s); if (IsVisible()) Draw();} void SSDDoubleClassBox::UpdatePropertiesLabelString(const string *s) { if (IsVisible()) Undraw(); SetPropertiesLabelString(s); if (IsVisible()) Draw();}bool SSDDoubleClassBox::ReadMembers(InputFile *ifile, double format) { if (!DoubleClassBox::ReadMembers(ifile, format)) return False; if (format >= 1.28) { string val; if (!ifile->ReadAttribute("ShowStereotype", &val)) return False; showStereotype = (val == "True"); if (!ifile->ReadAttribute("ShowProperties", &val)) return False; showProperties = (val == "True"); } else { showStereotype = False; showProperties = False; } return True;} void SSDDoubleClassBox::WriteMembers(OutputFile *ofile) { DoubleClassBox::WriteMembers(ofile); (*ofile) << "\t{ ShowStereotype " << (showStereotype?"True":"False") << " }\n"; (*ofile) << "\t{ ShowProperties " << (showProperties?"True":"False") << " }\n";}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -