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

« back to all changes in this revision

Viewing changes to src/sd/dv/ucwindow.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 "ucdiagram.h"
 
23
#include "ucviewer.h"
 
24
#include "ucgraph.h"
 
25
#include "ucwindow.h"
 
26
#include "menu.h"
 
27
#include "diagramstubs.h"
 
28
 
 
29
// X bitmap data for the tiled buttons
 
30
#include "Box.xbm"
 
31
#include "BoundaryBox.xbm"
 
32
#include "StickMan.xbm"
 
33
#include "C2Line.xbm"
 
34
#include "Comment.xbm"
 
35
#include "Ellipse.xbm"
 
36
#include "NoteBox.xbm"
 
37
#include "EmptyOpenArrow.xbm"
 
38
#include "DottedLine.xbm"
 
39
 
 
40
const char *UCWindow::UC_NODE_NAMES[] = 
 
41
        {"Actor (StickMan)",
 
42
         "Actor (ClassBox)", 
 
43
         "Use Case", 
 
44
         "System",
 
45
         "Note",
 
46
         "Comment"};
 
47
const Bitmap UCWindow::UC_NODE_ICONS[] = 
 
48
        {{StickMan_width, StickMan_height, StickMan_bits},
 
49
         {Box_width, Box_height, Box_bits},
 
50
         {Ellipse_width, Ellipse_height, Ellipse_bits},
 
51
         {BoundaryBox_width, BoundaryBox_height, BoundaryBox_bits},
 
52
         {NoteBox_width, NoteBox_height, NoteBox_bits},
 
53
         {Comment_width, Comment_height, Comment_bits}};
 
54
 
 
55
const char* UCWindow::UC_EDGE_NAMES[] = 
 
56
        {"Binary association",
 
57
         "Generalization",
 
58
         "Note connector"};
 
59
 
 
60
const Bitmap UCWindow::UC_EDGE_ICONS [] =
 
61
        {{C2Line_width, C2Line_height, C2Line_bits},
 
62
         {EmptyOpenArrow_width, EmptyOpenArrow_height, EmptyOpenArrow_bits},
 
63
         {DottedLine_width, DottedLine_height, DottedLine_bits}};
 
64
 
 
65
UCWindow::UCWindow(const char *n) : ERWindow(n) {
 
66
        diagramUCBoxItems = 0;
 
67
}
 
68
 
 
69
UCWindow::~UCWindow() {
 
70
        if (diagramUCBoxItems) {
 
71
                delete diagramUCBoxItems;
 
72
        }
 
73
}
 
74
 
 
75
DiagramViewer *UCWindow::CreateViewer(Config *cfg) {
 
76
        return new UCViewer(cfg, this);
 
77
}
 
78
 
 
79
Graph *UCWindow::CreateGraph() {
 
80
        return new UCGraph();
 
81
}
 
82
 
 
83
Diagram *UCWindow::CreateDiagram(Config *c, DiagramViewer *v, Graph *g) {
 
84
         return new UCDiagram(c, this, (UCViewer *)v, (UCGraph *)g);
 
85
}
 
86
 
 
87
void UCWindow::DetermineIcons() {
 
88
         nodeNames = UC_NODE_NAMES;
 
89
         nodeIcons = UC_NODE_ICONS;
 
90
         edgeNames = UC_EDGE_NAMES;
 
91
         edgeIcons = UC_EDGE_ICONS;
 
92
         nrNodes = XtNumber(UC_NODE_NAMES);
 
93
         nrEdges = XtNumber(UC_EDGE_NAMES);
 
94
}
 
95
 
 
96
void UCWindow::InitMenuItems() {
 
97
        ERWindow::InitMenuItems();
 
98
        int i = 0;
 
99
        diagramUCBoxItems = new MenuItem[10]; i=0;
 
100
        diagramUCBoxItems[i] = MenuItem(
 
101
                "to Actor Class Boxes", MenuItem::PUSHBUTTON, 'C', 0, 0, 
 
102
                DiagramStubs::UpdateNodeShapeTypeCB, 
 
103
                (XtPointer)GetDiagramViewer(), 
 
104
                (XtPointer)Code::UCD_SINGLE_CLASS_BOX, 0, 1); i++;
 
105
        diagramUCBoxItems[i] = MenuItem(
 
106
                "to StickMen", MenuItem::PUSHBUTTON, 'S', 0, 0, 
 
107
                DiagramStubs::UpdateNodeShapeTypeCB, 
 
108
                (XtPointer)GetDiagramViewer(), 
 
109
                (XtPointer)Code::STICKMAN, 0, 1); i++;
 
110
        diagramUCBoxItems[i] = MenuItem::NUL;
 
111
 
 
112
        // delete last menu item: hide value types.
 
113
        int n = 0;
 
114
        while (viewItems[n++].label != 0)
 
115
                ;
 
116
        viewItems[n-2] = MenuItem::NUL;
 
117
 
 
118
        int j = 0;
 
119
        while (editItems[j++].label != 0)
 
120
                ;
 
121
        editItems[--j] = MenuItem("", MenuItem::SEPARATOR); j++;
 
122
        editItems[j] = MenuItem(
 
123
                "Change Actor Type", MenuItem::SUBMENU, 'C', 0, 0, 
 
124
                0, 0, 0, diagramUCBoxItems, 1); j++;
 
125
        editItems[j] = MenuItem("", MenuItem::SEPARATOR); j++;
 
126
        editItems[j] = MenuItem(
 
127
                "Change Read Direction", MenuItem::SUBMENU, 'R', 0, 0,
 
128
                0, 0, 0, ERReadDirectionItems, 1); j++;
 
129
        editItems[j] = MenuItem::NUL;
 
130
 
 
131
        int k = 0;
 
132
        while (popupEditItems[k++].label != 0)
 
133
                ;
 
134
        popupEditItems[--k] = MenuItem("", MenuItem::SEPARATOR); k++;
 
135
        popupEditItems[k] = MenuItem(
 
136
                "Change Actor Type", MenuItem::SUBMENU, '\0', 0, 0, 
 
137
                0, 0, 0, diagramUCBoxItems, 1); k++;
 
138
        popupEditItems[k] = MenuItem("", MenuItem::SEPARATOR); k++;
 
139
        popupEditItems[j] = MenuItem(
 
140
                "Change Read Direction", MenuItem::SUBMENU, '\0', 0, 0,
 
141
                0, 0, 0, ERReadDirectionItems, 1); k++;
 
142
        popupEditItems[k] = MenuItem::NUL;
 
143
 
 
144
}