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

« back to all changes in this revision

Viewing changes to src/sd/dv/erwindow.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 1996, 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 "erwindow.h"
 
23
#include "erdiagram.h"
 
24
#include "erviewer.h"
 
25
#include "ergraph.h"
 
26
#include "erstubs.h"
 
27
#include "config.h"
 
28
#include "menu.h"
 
29
#include <Xm/XmAll.h>
 
30
 
 
31
// X bitmap data for the tiled buttons
 
32
#include "Box.xbm"
 
33
#include "C1Arrow.xbm"
 
34
#include "C2Line.xbm"
 
35
#include "Dot.xbm"
 
36
#include "Diamond.xbm"
 
37
#include "Ellipse.xbm"
 
38
#include "EmptyLine.xbm"
 
39
#include "IsaArrow.xbm"
 
40
#include "Comment.xbm"
 
41
#include "DoubleArrow.xbm"
 
42
 
 
43
const char *ERWindow::ER_NODE_NAMES[] =
 
44
        {"Entity type", "Value type","Taxonomy junction", "Relationship", 
 
45
         "Comment"};
 
46
const Bitmap ERWindow::ER_NODE_ICONS [] =
 
47
        {{Box_width, Box_height, Box_bits},
 
48
         {Ellipse_width, Ellipse_height, Ellipse_bits},
 
49
         {Dot_width, Dot_height, Dot_bits},
 
50
         {Diamond_width, Diamond_height, Diamond_bits},
 
51
         {Comment_width, Comment_height, Comment_bits}};
 
52
 
 
53
const char *ERWindow::ER_EDGE_NAMES[] = 
 
54
        {"Binary relationship", "Function","Is-a relationship", 
 
55
         "Empty edge", "One-one function"};
 
56
const Bitmap ERWindow::ER_EDGE_ICONS [] =
 
57
        {{C2Line_width, C2Line_height, C2Line_bits},
 
58
         {C1Arrow_width, C1Arrow_height, C1Arrow_bits},
 
59
         {IsaArrow_width, IsaArrow_height, IsaArrow_bits},
 
60
         {EmptyLine_width, EmptyLine_height, EmptyLine_bits},
 
61
         {DoubleArrow_width, DoubleArrow_height, DoubleArrow_bits}};
 
62
 
 
63
ERWindow::ERWindow(const char *n): DiagramWindow(n) { 
 
64
        ERReadDirectionItems = 0;
 
65
}
 
66
 
 
67
ERWindow::~ERWindow() {
 
68
        if (ERReadDirectionItems)
 
69
                delete ERReadDirectionItems;
 
70
}
 
71
 
 
72
DiagramViewer *ERWindow::CreateViewer(Config *cfg) {
 
73
        return new ERViewer(cfg, this);
 
74
}
 
75
 
 
76
Graph *ERWindow::CreateGraph() {
 
77
        return new ERGraph();
 
78
}
 
79
 
 
80
Diagram *ERWindow::CreateDiagram(Config *c, DiagramViewer *v, Graph *g) {
 
81
         return new ERDiagram(c, this, (ERViewer *)v, (ERGraph *)g);
 
82
}
 
83
 
 
84
void ERWindow::DetermineIcons() {
 
85
         nodeNames = ER_NODE_NAMES;
 
86
         nodeIcons = ER_NODE_ICONS;
 
87
         edgeNames = ER_EDGE_NAMES;
 
88
         edgeIcons = ER_EDGE_ICONS;
 
89
         nrNodes = XtNumber(ER_NODE_NAMES);
 
90
         nrEdges = XtNumber(ER_EDGE_NAMES);
 
91
}
 
92
 
 
93
void ERWindow::InitMenuItems() {
 
94
        DiagramWindow::InitMenuItems();
 
95
        int i=0;
 
96
        delete viewItems;
 
97
        viewItems = new MenuItem[25]; i=0;
 
98
        viewItems[i] = MenuItem(
 
99
                "Refresh", MenuItem::PUSHBUTTON, 'R', "Ctrl<Key>V", "Ctrl+V", 
 
100
                ERStubs::RefreshCB, (XtPointer)GetDiagramViewer(), 0, 0, 1); i++;
 
101
        viewItems[i] = MenuItem(
 
102
                "Grid", MenuItem::SUBMENU, 'G', 0, 0,
 
103
                0, 0, 0, gridItems, 1); i++;
 
104
        viewItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
105
        viewItems[i] = MenuItem(
 
106
                "Zoom In", MenuItem::PUSHBUTTON, 'I', "Ctrl<Key>I", "Ctrl+I",
 
107
                DiagramStubs::ZoomInCB, (XtPointer)GetDiagramViewer(), 0, 0, 0); i++;
 
108
        viewItems[i] = MenuItem(
 
109
                "Zoom Out", MenuItem::PUSHBUTTON, 'O', "Ctrl<Key>O", "Ctrl+O",
 
110
                DiagramStubs::ZoomOutCB, (XtPointer)GetDiagramViewer(), 0, 0, 0); i++;
 
111
        viewItems[i] = MenuItem(
 
112
                "Top Level", MenuItem::PUSHBUTTON, 'T', "Ctrl<Key>T", "Ctrl+T",
 
113
                DiagramStubs::TopLevelCB, (XtPointer)GetDiagramViewer(), 0, 0, 0); i++;
 
114
        viewItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
115
        viewItems[i] = MenuItem(
 
116
                "Autoresizing", MenuItem::CHECKBUTTON, 'A', 0, 0, 
 
117
                ERStubs::SetAutoResizeCB, (XtPointer)GetDiagramViewer(), 
 
118
                (XtPointer)(GetConfig()->GetAutoResizing()), 0, 1); i++;
 
119
        viewItems[i] = MenuItem(
 
120
                "In-line Editor", MenuItem::CHECKBUTTON, 'E', 0, 0, 
 
121
                ERStubs::SetInlineEditCB, (XtPointer)GetDiagramViewer(), 
 
122
                (XtPointer)(GetConfig()->GetInlineEditor()), 0, 1); i++;
 
123
        viewItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
124
        viewItems[i] = MenuItem(
 
125
                "Show ISA hierarchy", MenuItem::CHECKBUTTON, 'I', 0, 0, 
 
126
                ERStubs::ShowISACB, (XtPointer)GetDiagramViewer(), 
 
127
                (XtPointer)0, 0, 1); i++;
 
128
        viewItems[i] = MenuItem(
 
129
                "Hide Value types", MenuItem::CHECKBUTTON, 'V', 0, 0, 
 
130
                ERStubs::HideValueTypesCB, (XtPointer)GetDiagramViewer(), 
 
131
                (XtPointer)0, 0, 1); i++;
 
132
        viewItems[i] = MenuItem();
 
133
 
 
134
        ERReadDirectionItems = new MenuItem[10]; i=0;
 
135
        ERReadDirectionItems[i] = MenuItem(
 
136
                "ToShape", MenuItem::PUSHBUTTON, 'T', 0, 0,
 
137
                ERStubs::UpdateReadDirectionCB,
 
138
                (XtPointer)GetDiagramViewer(),
 
139
                0, 0, 1); i++;
 
140
        ERReadDirectionItems[i] = MenuItem(
 
141
                "None", MenuItem::PUSHBUTTON, 'N', 0, 0,
 
142
                ERStubs::UpdateReadDirectionCB,
 
143
                (XtPointer)GetDiagramViewer(),
 
144
                0, 0, 1); i++;
 
145
        ERReadDirectionItems[i] = MenuItem(
 
146
                "FromShape", MenuItem::PUSHBUTTON, 'F', 0, 0,
 
147
                ERStubs::UpdateReadDirectionCB,
 
148
                (XtPointer)GetDiagramViewer(),
 
149
                0, 0, 1); i++;
 
150
        ERReadDirectionItems[i] = MenuItem::NUL;
 
151
}