~ubuntu-branches/ubuntu/intrepid/tcm/intrepid

« back to all changes in this revision

Viewing changes to src/sd/dv/tripleclassbox.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 1998, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version.
 
11
//
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
////////////////////////////////////////////////////////////////////////////////
 
22
#include "tripleclassbox.h"
 
23
#include "stringlistnode2.h"
 
24
 
 
25
const int TripleClassBox::TRIPLECLASSBOX_WIDTH = 76;
 
26
const int TripleClassBox::TRIPLECLASSBOX_HEIGHT = 66;
 
27
 
 
28
TripleClassBox::TripleClassBox(ShapeView *v, Grafport *g, 
 
29
        int x, int y, int w, int h): TripleBox(v, g, x, y, w, h) {
 
30
        SetSeparatorLineStyle(LineStyle::SOLID);
 
31
        SetSeparator2LineStyle(LineStyle::SOLID);
 
32
        labelDescription = "Attribute";
 
33
        label2Description = "Operation";
 
34
}
 
35
 
 
36
TripleClassBox::TripleClassBox(const Box &s): TripleBox(s) {
 
37
        labelDescription = "Attribute";
 
38
        label2Description = "Operation";
 
39
        SetSeparatorLineStyle(LineStyle::SOLID);
 
40
        SetSeparator2LineStyle(LineStyle::SOLID);
 
41
        SetTextShape();
 
42
        AdjustSizes(GetName()->GetString());
 
43
}
 
44
 
 
45
TripleClassBox::TripleClassBox(const TripleBox &s): TripleBox(s) {
 
46
        labelDescription = "Attribute";
 
47
        label2Description = "Operation";
 
48
        SetTextShape();
 
49
        AdjustSizes(GetName()->GetString());
 
50
}
 
51
 
 
52
bool TripleClassBox::SetAssocSubject(AssocList *al) {
 
53
        if (!TripleBox::SetAssocSubject(al))
 
54
                return False;
 
55
        if (check(GetSubject() &&
 
56
            (GetSubject()->GetClassType()==Code::CLASS_NODE ||
 
57
             GetSubject()->GetClassType()==Code::SSD_CLASS_NODE)))
 
58
                return True;
 
59
        SetSubject(0);
 
60
        return False;
 
61
}
 
62
 
 
63
void TripleClassBox::SetTextShape() {
 
64
        TripleBox::SetTextShape();
 
65
        GetLabels()->clear();
 
66
        GetLabels2()->clear();
 
67
        if (!check(GetSubject()) || 
 
68
            (GetSubject()->GetClassType() != Code::CLASS_NODE &&
 
69
             GetSubject()->GetClassType() != Code::SSD_CLASS_NODE))
 
70
                return;
 
71
        StringListNode2 *node = (StringListNode2 *)GetSubject();
 
72
        unsigned numItems = node->NrStrings();
 
73
        for (unsigned i=0; i<numItems; i++) {
 
74
                TextShape *et = new TextShape(GetView(), GetGrafport(), this);
 
75
                et->SetSequence(i);
 
76
                et->SetAlignment(TextAlign::LEFT);
 
77
                et->SetDescription(&labelDescription);
 
78
                et->SetString(node->GetString(i));
 
79
                et->SetParent(this);
 
80
                et->SetFont(GetName()->GetFont());
 
81
                et->SetColor(GetName()->GetColor());
 
82
                GetLabels()->add(et);
 
83
        }
 
84
        numItems = node->NrStrings2();
 
85
        for (unsigned j=0; j<numItems; j++) {
 
86
                TextShape *et = new TextShape(GetView(), GetGrafport(), this);
 
87
                et->SetSequence(j);
 
88
                et->SetAlignment(TextAlign::LEFT);
 
89
                et->SetDescription(&label2Description);
 
90
                et->SetString(node->GetString2(j));
 
91
                et->SetParent(this);
 
92
                et->SetFont(GetName()->GetFont());
 
93
                et->SetColor(GetName()->GetColor());
 
94
                GetLabels2()->add(et);
 
95
        }
 
96
//      CalcPositionLabels();
 
97
}