~ubuntu-branches/ubuntu/utopic/tcm/utopic

« back to all changes in this revision

Viewing changes to src/sd/dv/ssdtripleclassbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------------
 
2
//
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1999, Vrije Universiteit Amsterdam and University of Twente.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
// Author: Henk van de Zandschulp (henkz@cs.utwente.nl).
 
7
//
 
8
// TCM is free software; you can redistribute it and/or modify
 
9
// it under the terms of the GNU General Public License as published by
 
10
// the Free Software Foundation; either version 2 of the License, or
 
11
// (at your option) any later version.
 
12
//
 
13
// TCM is distributed in the hope that it will be useful,
 
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
// GNU General Public License for more details.
 
17
//
 
18
// You should have received a copy of the GNU General Public License
 
19
// along with TCM; if not, write to the Free Software Foundation, Inc.,
 
20
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#include "lstring.h"
 
23
#include "grafport.h"
 
24
#include "ssdsingleclassbox.h"
 
25
#include "ssdtripleclassbox.h"
 
26
#include "ssddoubleclassbox.h"
 
27
#include "ssdclassnode.h"
 
28
#include "diagramviewer.h"
 
29
#include "inputfile.h"
 
30
#include "outputfile.h"
 
31
 
 
32
SSDTripleClassBox::SSDTripleClassBox(ShapeView *v, Grafport *g, int x, int y, 
 
33
                int w, int h): TripleClassBox(v, g, x, y, w, h) {
 
34
        stereotypeLabel = new TextShape(v, g, this);
 
35
        stereotypeLabel->SetOneLine(True);
 
36
        stereotypeLabel->SetDescription("Stereotype");
 
37
        string my_stereo = "<<SSDTripleClassBox>>";
 
38
        stereotypeLabel->SetString(&my_stereo);
 
39
        propertiesLabel = new TextShape(v, g, this);
 
40
        propertiesLabel->SetOneLine(False);
 
41
        propertiesLabel->SetDescription("Properties");
 
42
        string my_props = "{ SSDTripleClassBox }";
 
43
        propertiesLabel->SetString(&my_props);
 
44
        showStereotype = False;
 
45
        showProperties = False;
 
46
        SetSize(w, RequiredHeight());
 
47
}
 
48
 
 
49
SSDTripleClassBox::~SSDTripleClassBox() {
 
50
        delete stereotypeLabel;
 
51
        delete propertiesLabel;
 
52
}
 
53
 
 
54
SSDTripleClassBox::SSDTripleClassBox(const SSDTripleClassBox &s): 
 
55
                                                TripleClassBox(s) {
 
56
        showStereotype = s.showStereotype;
 
57
        showProperties = s.showProperties;
 
58
        stereotypeLabel = new TextShape(*(s.stereotypeLabel));
 
59
        propertiesLabel = new TextShape(*(s.propertiesLabel));
 
60
        stereotypeLabel->SetParent(this);
 
61
        propertiesLabel->SetParent(this);
 
62
        SetSize(s.GetWidth(), s.GetHeight());
 
63
}
 
64
 
 
65
SSDTripleClassBox::SSDTripleClassBox(const SSDDoubleClassBox &s): 
 
66
                                                TripleClassBox(s) {
 
67
        showStereotype = s.IsShowStereotype();
 
68
        showProperties = s.IsShowProperties();
 
69
        stereotypeLabel = new TextShape(*s.GetStereotypeLabel());
 
70
        propertiesLabel = new TextShape(*s.GetPropertiesLabel());
 
71
        stereotypeLabel->SetParent(this);
 
72
        propertiesLabel->SetParent(this);
 
73
        SetTextShape();
 
74
        AdjustSizes(GetName()->GetString());
 
75
}
 
76
 
 
77
SSDTripleClassBox::SSDTripleClassBox(const SSDSingleClassBox &s): 
 
78
                                                TripleClassBox(s) {
 
79
        showStereotype = s.IsShowStereotype();
 
80
        showProperties = s.IsShowProperties();
 
81
        stereotypeLabel = new TextShape(*s.GetStereotypeLabel());
 
82
        propertiesLabel = new TextShape(*s.GetPropertiesLabel());
 
83
        stereotypeLabel->SetParent(this);
 
84
        propertiesLabel->SetParent(this);
 
85
        SetTextShape();
 
86
        AdjustSizes(GetName()->GetString());
 
87
}
 
88
 
 
89
void SSDTripleClassBox::SetGrafport(Grafport *g) {
 
90
        TripleClassBox::SetGrafport(g);
 
91
        stereotypeLabel->SetGrafport(g);
 
92
        propertiesLabel->SetGrafport(g);
 
93
}
 
94
 
 
95
void SSDTripleClassBox::SetView(ShapeView *v) {
 
96
        TripleClassBox::SetView(v);
 
97
        stereotypeLabel->SetView(v);
 
98
        propertiesLabel->SetView(v);
 
99
}
 
100
 
 
101
bool SSDTripleClassBox::HasTextShape(TextShape *t) const {
 
102
        if (TripleClassBox::HasTextShape(t))
 
103
                return True;
 
104
        if (GetStereotypeLabel() == t)
 
105
                return True;
 
106
        if (GetPropertiesLabel() == t)
 
107
                return True;
 
108
        return False;
 
109
}
 
110
 
 
111
bool SSDTripleClassBox::HasString(const string *s, bool sens, bool sub) const {
 
112
        if (TripleClassBox::HasString(s, sens, sub))
 
113
                return True;
 
114
        if (showStereotype && stereotypeLabel->HasString(s, sens, sub))
 
115
                return True;
 
116
        if (showProperties && propertiesLabel->HasString(s, sens, sub))
 
117
                return True;
 
118
        return False;
 
119
}
 
120
 
 
121
bool SSDTripleClassBox::HasString(const string *s, bool sens, bool sub,
 
122
                        List<TextShape *> *list) {
 
123
        bool b = TripleClassBox::HasString(s, sens, sub, list);
 
124
        if (showStereotype && stereotypeLabel->HasString(s, sens, sub, list))
 
125
                b = True;
 
126
        if (showProperties && propertiesLabel->HasString(s, sens, sub, list))
 
127
                b = True;
 
128
        return b;
 
129
}
 
130
 
 
131
void SSDTripleClassBox::SetTextShape() {
 
132
        TripleClassBox::SetTextShape();
 
133
 
 
134
        if (!check(GetSubject() &&
 
135
             GetSubject()->GetClassType()==Code::SSD_CLASS_NODE))
 
136
                return;
 
137
        GetStereotypeLabel()->SetString(
 
138
                        ((SSDClassNode *)GetSubject())->GetStereotype());
 
139
        GetStereotypeLabel()->SetParent(this);
 
140
        GetPropertiesLabel()->SetString(
 
141
                        ((SSDClassNode *)GetSubject())->GetProperties());
 
142
        GetPropertiesLabel()->SetParent(this);
 
143
//      CalcPositionLabels();
 
144
}
 
145
 
 
146
void SSDTripleClassBox::SetFont(XFont *ft) {
 
147
        TripleClassBox::SetFont(ft);
 
148
        stereotypeLabel->SetFont(ft);
 
149
        propertiesLabel->SetFont(ft);
 
150
//      CalcPositionLabels();
 
151
}
 
152
 
 
153
void SSDTripleClassBox::SetTextColor(const string *c) {
 
154
        TripleClassBox::SetTextColor(c);
 
155
        stereotypeLabel->SetColor(c);
 
156
        propertiesLabel->SetColor(c);
 
157
}
 
158
 
 
159
void SSDTripleClassBox::UpdateShowStereotype(bool b) {
 
160
        if (b == showStereotype)
 
161
                return;
 
162
        if (IsVisible())
 
163
                Undraw();
 
164
        showStereotype = b;
 
165
//      CalcPositionLabels();
 
166
        if (IsVisible())
 
167
                Draw();
 
168
}
 
169
 
 
170
void SSDTripleClassBox::UpdateShowProperties(bool b) {
 
171
        if (b == showProperties)
 
172
                return;
 
173
        if (IsVisible())
 
174
                Undraw();
 
175
        showProperties = b;
 
176
//      CalcPositionLabels();
 
177
        if (IsVisible())
 
178
                Draw();
 
179
}
 
180
 
 
181
void SSDTripleClassBox::DrawTextShapes() {
 
182
        string oldBackground;
 
183
        Grafport *g = GetGrafport();
 
184
        if (GetFillStyle() != FillStyle::UNFILLED) {
 
185
                oldBackground = *g->GetBackgroundColor();
 
186
                g->SetBackgroundColor(GetFillColor()->getstr());
 
187
        }
 
188
        NodeShape::DrawTextShapes();
 
189
        int textHeight = GetName()->GetFontHeight();
 
190
        int addLines = (showStereotype ? 1 : 0);
 
191
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
192
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
193
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
194
        // calculate first_compartmentHeight
 
195
        if (showProperties)
 
196
                addLines += GetPropertiesLabelString()->lines();
 
197
        int snpHeight = (addLines+labelLines) * textHeight;
 
198
        int dboxHeight = DoubleBoxHeight();
 
199
        if (snpHeight < GetHeight()) {
 
200
                g->DrawLine(GetLeftMost()+1, GetTopMost()+snpHeight+1,
 
201
                        GetRightMost()-1,
 
202
                        GetTopMost()+snpHeight+1);
 
203
                g->SetLineStyle(GetLineStyle());
 
204
        }
 
205
        int i = snpHeight;
 
206
        for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {
 
207
                i += textHeight;
 
208
                if (i < GetHeight())
 
209
                        GetLabels()->cur()->Draw();
 
210
        }
 
211
        if (dboxHeight < GetHeight()) {
 
212
                g->SetLineStyle(GetSeparatorLineStyle());
 
213
                g->DrawLine(GetLeftMost()+1, GetTopMost()+dboxHeight,
 
214
                        GetRightMost()-1,
 
215
                        GetTopMost()+dboxHeight);
 
216
                g->SetLineStyle(GetLineStyle());
 
217
        }
 
218
        i = dboxHeight;
 
219
        for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {
 
220
                i += textHeight;
 
221
                if (i < GetHeight())
 
222
                        GetLabels2()->cur()->Draw();
 
223
        }
 
224
        if (GetFillStyle() != FillStyle::UNFILLED)
 
225
                g->SetBackgroundColor(oldBackground.getstr());
 
226
        if (showStereotype)
 
227
                stereotypeLabel->Draw();
 
228
        if (showProperties)
 
229
                propertiesLabel->Draw();
 
230
}
 
231
 
 
232
void SSDTripleClassBox::AdjustSize() {
 
233
        int twd = RequiredWidth();
 
234
        int ht = RequiredHeight();
 
235
        if (twd > GetWidth() || ht != GetHeight()) {
 
236
                int wd = max((twd+2*TEXTMARGIN), GetWidth());
 
237
                UpdateSize(wd, ht);
 
238
                GetViewer()->ShapePositionUpdate(this);
 
239
        }
 
240
//      else
 
241
//              CalcPositionLabels();
 
242
}
 
243
 
 
244
void SSDTripleClassBox::AdjustSizes(const string *) {
 
245
        if (!GetViewer()->IsAutoResize()) {
 
246
//              CalcPositionLabels();
 
247
                return;
 
248
        }
 
249
        int twd = RequiredWidth();
 
250
        int ht = RequiredHeight();
 
251
        if (twd > GetWidth() || GetHeight() != ht) {
 
252
                int wd = max((twd+2*TEXTMARGIN), GetWidth());
 
253
                SetSize(wd, ht);
 
254
                GetViewer()->ShapePositionUpdate(this);
 
255
        }
 
256
//      else
 
257
//              CalcPositionLabels();
 
258
}
 
259
 
 
260
void SSDTripleClassBox::CalcPositionLabels() {
 
261
        TripleClassBox::CalcPositionLabels();
 
262
 
 
263
        Point pt = *GetPosition();
 
264
        // calculate labelnameHeight first
 
265
        int textHeight = GetName()->GetFontHeight();
 
266
        int addLines = (showStereotype ? 1 : 0);
 
267
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
268
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
269
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
270
        int nameHeight = labelLines * textHeight;
 
271
        // calculate first_compartmentHeight
 
272
        if (showProperties)
 
273
                addLines += GetPropertiesLabelString()->lines();
 
274
        int snpHeight = (addLines+labelLines) * textHeight;
 
275
 
 
276
        if (showStereotype)
 
277
                pt.y = GetTopMost() + textHeight + nameHeight/2;
 
278
        else
 
279
                pt.y = GetTopMost() + nameHeight/2;
 
280
        GetName()->SetPosition(&pt);
 
281
 
 
282
        pt.y = GetTopMost() + snpHeight;
 
283
        pt.y += (3*textHeight)/4;
 
284
        for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {
 
285
                TextShape *t = GetLabels()->cur();
 
286
                // position and left adjust textshape
 
287
                int w = t->GetStringWidth();
 
288
                pt.x = GetLeftMost() + w/2 + TEXTMARGIN;
 
289
                t->SetPosition(&pt);
 
290
                pt.y += textHeight;
 
291
        }
 
292
 
 
293
        //  Operation part
 
294
        CalcPositionLabels2();
 
295
 
 
296
        // set index label position.
 
297
        pt.x = GetName()->GetPosition()->x + GetWidth()*5/12;
 
298
        pt.y = GetName()->GetPosition()->y - nameHeight/4;
 
299
        GetIndexLabel()->SetPosition(&pt);
 
300
 
 
301
        if (showStereotype)
 
302
                CalcPositionStereotypeLabel();
 
303
        if (showProperties)
 
304
                CalcPositionPropertiesLabel();
 
305
}
 
306
 
 
307
void SSDTripleClassBox::CalcPositionLabels2() {
 
308
        Point pt = *GetPosition();
 
309
        pt.y = GetTopMost() + DoubleBoxHeight();
 
310
        int textHeight = GetName()->GetFontHeight();
 
311
        pt.y += (3*textHeight)/4;
 
312
        for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {
 
313
                TextShape *t = GetLabels2()->cur();
 
314
                // position and left adjust textshape
 
315
                int w = t->GetStringWidth();
 
316
                // int h = t->GetHeight();
 
317
                pt.x = GetLeftMost() + w/2 + TEXTMARGIN;
 
318
                t->SetPosition(&pt);
 
319
                pt.y += textHeight;
 
320
        }
 
321
}
 
322
 
 
323
void SSDTripleClassBox::CalcPositionStereotypeLabel() {
 
324
        int textHeight = GetName()->GetFontHeight();
 
325
        Point pt;
 
326
        pt.x = GetPosition()->x;
 
327
        pt.y = GetTopMost() + textHeight/2;
 
328
        stereotypeLabel->SetPosition(&pt);
 
329
}
 
330
 
 
331
void SSDTripleClassBox::CalcPositionPropertiesLabel() {
 
332
        int textHeight = GetName()->GetFontHeight();
 
333
        int addLines = (showStereotype ? 1 : 0);
 
334
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
335
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
336
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
337
        int snHeight = (addLines+labelLines) * textHeight;
 
338
 
 
339
        int propHeight = (showProperties ?
 
340
                        GetPropertiesLabelString()->lines()*textHeight : 0);
 
341
        Point pt;
 
342
        pt.x = GetPosition()->x;
 
343
        pt.y = GetTopMost() + snHeight + propHeight/2;
 
344
        propertiesLabel->SetPosition(&pt);
 
345
}
 
346
 
 
347
int SSDTripleClassBox::RequiredHeight() {
 
348
        // int textHeight = GetName()->GetFontHeight();
 
349
        int addLines = (showStereotype ? 1 : 0);
 
350
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
351
        // int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
352
        // int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
353
        // calculate first_compartmentHeight
 
354
        if (showProperties)
 
355
                addLines += GetPropertiesLabelString()->lines();
 
356
        // int snpHeight = (addLines+labelLines) * textHeight;
 
357
        // int propHeight = GetPropertiesLabelString()->lines() * textHeight;
 
358
 
 
359
        // int ht = (snpHeight + textHeight + GetLabels()->count()*textHeight);
 
360
        // int ht2 = (snpHeight + int(1.5*textHeight) + GetLabels()->count()*textHeight +
 
361
        //              textHeight + GetLabels2()->count()*textHeight);
 
362
        // int dboxHeight = DoubleBoxHeight();
 
363
        int tboxHeight = TripleBoxHeight();
 
364
        return max(tboxHeight, GetInitialHeight());
 
365
}
 
366
 
 
367
int SSDTripleClassBox::RequiredWidth() {
 
368
        int twidth = GetName()->GetWidth();
 
369
        if (showStereotype)
 
370
                twidth = max(twidth, GetStereotypeLabel()->GetWidth());
 
371
        if (showProperties)
 
372
                twidth = max(twidth, GetPropertiesLabel()->GetWidth());
 
373
        // Labels
 
374
        for (GetLabels()->first(); !GetLabels()->done(); GetLabels()->next()) {
 
375
                int wd = GetLabels()->cur()->GetStringWidth();
 
376
                twidth = max(twidth, wd);
 
377
        }
 
378
        for (GetLabels2()->first(); !GetLabels2()->done(); GetLabels2()->next()) {
 
379
                int wd = GetLabels2()->cur()->GetStringWidth();
 
380
                twidth = max(twidth, wd);
 
381
        }
 
382
        return twidth;
 
383
}
 
384
 
 
385
int SSDTripleClassBox::DoubleBoxHeight() {
 
386
        int textHeight = GetName()->GetFontHeight();
 
387
        int addLines = (showStereotype ? 1 : 0);
 
388
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
389
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
390
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
391
        // calculate first_compartmentHeight
 
392
        if (showProperties)
 
393
                addLines += GetPropertiesLabelString()->lines();
 
394
        int snpHeight = (addLines+labelLines) * textHeight;
 
395
        if (NrLabels() == 0)
 
396
                return int(snpHeight + 1.5*textHeight);
 
397
        else
 
398
                return int(snpHeight + (1 + NrLabels())*textHeight);
 
399
}
 
400
 
 
401
int SSDTripleClassBox::TripleBoxHeight() {
 
402
        int rval1, rval2;
 
403
        int textHeight = GetName()->GetFontHeight();
 
404
        int addLines = (showStereotype ? 1 : 0);
 
405
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
406
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
407
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
408
        // calculate first_compartmentHeight
 
409
        if (showProperties)
 
410
                addLines += GetPropertiesLabelString()->lines();
 
411
        int snpHeight = (addLines+labelLines) * textHeight;
 
412
        if (NrLabels() == 0)
 
413
                rval1 = int(snpHeight + 1.5*textHeight);
 
414
        else
 
415
                rval1 = int(snpHeight + (1 + NrLabels())*textHeight);
 
416
        if (NrLabels2() == 0)
 
417
                rval2 = int(1.0*textHeight);
 
418
        else
 
419
                rval2 = int((1 + NrLabels2())*textHeight);
 
420
        return (rval1+rval2);
 
421
}
 
422
 
 
423
TextShape *SSDTripleClassBox::ChooseTextShape(int x, int y) {
 
424
        // in first part (of the class name) ?
 
425
        int textHeight = GetName()->GetFontHeight();
 
426
        int addLines = (showStereotype ? 1 : 0);
 
427
        // min_firstboxlines : 2 when no <<stereotype>> / {props} shown
 
428
        int min_firstboxlines = ((showStereotype || showProperties) ? 1 : 2);
 
429
        int labelLines = max(GetName()->GetString()->lines(),min_firstboxlines);
 
430
        int snHeight = (addLines+labelLines) * textHeight;
 
431
        // calculate first_compartmentHeight
 
432
        if (showProperties)
 
433
                addLines += GetPropertiesLabelString()->lines();
 
434
        int snpHeight = (addLines+labelLines) * textHeight;
 
435
        int dboxHeight = DoubleBoxHeight();
 
436
        int pos_y = GetTopMost() + snpHeight;
 
437
        int attr_y = GetTopMost() + dboxHeight;
 
438
        if (y <= pos_y) {
 
439
                if (showStereotype) {
 
440
                        if (y <= GetTopMost() + textHeight)
 
441
                                return GetStereotypeLabel();
 
442
                }
 
443
                if (GetViewer()->IsShowIndexes() && !IsFixedIndexLabel()) {
 
444
                        if (y <= GetName()->GetPosition()->y &&
 
445
                            x >= GetName()->GetPosition()->x + GetWidth()/3)
 
446
                                return GetIndexLabel();
 
447
                }
 
448
                if (y > GetTopMost() + snHeight)
 
449
                        return GetPropertiesLabel();
 
450
                if (!IsFixedName())
 
451
                        return GetName();
 
452
        }
 
453
        else if (y <= attr_y) {         // in attribute part
 
454
                pos_y += textHeight/2;
 
455
                for (GetLabels()->first(); !GetLabels()->done();
 
456
                     GetLabels()->next()) {
 
457
                        pos_y += textHeight;
 
458
                        if (pos_y >= GetBottomMost())
 
459
                                return 0;
 
460
                        else if (y <= pos_y)
 
461
                                return GetLabels()->cur();
 
462
                }
 
463
                if (GetViewer()->IsEditing())
 
464
                        return 0;
 
465
                // somewhere down the list; create a new label.
 
466
                TextShape *t = new TextShape(GetView(), GetGrafport(), this);
 
467
                t->SetAlignment(TextAlign::LEFT);
 
468
                t->SetSequence(GetLabels()->count());
 
469
                t->SetDescription(&labelDescription);
 
470
                t->SetFont(GetName()->GetFont());
 
471
                t->SetColor(GetName()->GetColor());
 
472
                Undraw();
 
473
                GetLabels()->add(t);
 
474
//              CalcPositionLabels();
 
475
                // move text shape to a better position.
 
476
                Point pt = *t->GetPosition();
 
477
                pt.x += GetWidth()/2 - TEXTMARGIN;
 
478
                t->SetPosition(&pt);
 
479
                Draw();
 
480
                return t;
 
481
        }
 
482
        else {  // in operation part
 
483
                pos_y = GetTopMost() + dboxHeight;
 
484
                pos_y += textHeight/2;
 
485
                for (GetLabels2()->first(); !GetLabels2()->done();
 
486
                     GetLabels2()->next()) {
 
487
                        pos_y += textHeight;
 
488
                        if (pos_y >= GetBottomMost())
 
489
                                return 0;
 
490
                        else if (y <= pos_y)
 
491
                                return GetLabels2()->cur();
 
492
                }
 
493
                if (GetViewer()->IsEditing())
 
494
                        return 0;
 
495
                // somewhere down the list; create a new label.
 
496
                TextShape *t = new TextShape(GetView(), GetGrafport(), this);
 
497
                t->SetAlignment(TextAlign::LEFT);
 
498
                t->SetSequence(GetLabels2()->count());
 
499
                t->SetDescription(&label2Description);
 
500
                t->SetFont(GetName()->GetFont());
 
501
                t->SetColor(GetName()->GetColor());
 
502
                Undraw();
 
503
                GetLabels2()->add(t);
 
504
                CalcPositionLabels2();
 
505
                // move text shape to a better position.
 
506
                Point pt = *t->GetPosition();
 
507
                pt.x += GetWidth()/2 - TEXTMARGIN;
 
508
                t->SetPosition(&pt);
 
509
                Draw();
 
510
                return t;
 
511
        }
 
512
        return 0;       // dummy statement shuts up compiler
 
513
}
 
514
 
 
515
void SSDTripleClassBox::UpdateStereotypeLabelString(const string *s) {
 
516
        if (IsVisible())
 
517
                Undraw();
 
518
        SetStereotypeLabelString(s);
 
519
        if (IsVisible())
 
520
                Draw();
 
521
}
 
522
 
 
523
void SSDTripleClassBox::UpdatePropertiesLabelString(const string *s) {
 
524
        if (IsVisible())
 
525
                Undraw();
 
526
        SetPropertiesLabelString(s);
 
527
        if (IsVisible())
 
528
                Draw();
 
529
}
 
530
 
 
531
bool SSDTripleClassBox::ReadMembers(InputFile *ifile, double format) {
 
532
        if (!TripleClassBox::ReadMembers(ifile, format))
 
533
                return False;
 
534
        if (format >= 1.28) {
 
535
                string val;
 
536
                if (!ifile->ReadAttribute("ShowStereotype", &val))
 
537
                        return False;
 
538
                showStereotype = (val == "True");
 
539
                if (!ifile->ReadAttribute("ShowProperties", &val))
 
540
                        return False;
 
541
                showProperties = (val == "True");
 
542
        }
 
543
        else {
 
544
                showStereotype = False;
 
545
                showProperties = False;
 
546
        }
 
547
        return True;
 
548
}
 
549
 
 
550
void SSDTripleClassBox::WriteMembers(OutputFile *ofile) {
 
551
        TripleClassBox::WriteMembers(ofile);
 
552
        (*ofile) << "\t{ ShowStereotype " << (showStereotype?"True":"False") << " }\n";
 
553
        (*ofile) << "\t{ ShowProperties " << (showProperties?"True":"False") << " }\n";
 
554
}