1
////////////////////////////////////////////////////////////////////////////////
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).
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.
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.
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
21
////////////////////////////////////////////////////////////////////////////////
23
#include "trdiagram.h"
31
#include "TextNode.xbm"
32
#include "TextRoot.xbm"
33
#include "Comment.xbm"
36
const char *TRWindow::TR_NODE_NAMES[] = { "Text root", "Text node", "Comment"};
38
const Bitmap TRWindow::TR_NODE_ICONS [] = {
39
{TextRoot_width, TextRoot_height, TextRoot_bits},
40
{TextNode_width, TextNode_height, TextNode_bits},
41
{Comment_width, Comment_height, Comment_bits}};
43
const char *TRWindow::TR_EDGE_NAMES[] = {"Line"};
44
const Bitmap TRWindow::TR_EDGE_ICONS [] = {
45
{Line_width, Line_height, Line_bits}};
47
TRWindow::TRWindow(const char *n): DiagramWindow(n) {}
49
DiagramViewer *TRWindow::CreateViewer(Config *cfg) {
50
return new TRViewer(cfg, this);
53
Graph *TRWindow::CreateGraph() {
57
Diagram *TRWindow::CreateDiagram(Config *c, DiagramViewer *v, Graph *g) {
58
return new TRDiagram(c, this, (TRViewer *)v, (TRGraph *)g);
61
void TRWindow::DetermineIcons() {
62
nodeNames = TR_NODE_NAMES;
63
nodeIcons = TR_NODE_ICONS;
64
edgeNames = TR_EDGE_NAMES;
65
edgeIcons = TR_EDGE_ICONS;
66
nrNodes = XtNumber(TR_NODE_NAMES);
67
nrEdges = XtNumber(TR_EDGE_NAMES);
70
Widget TRWindow::CreateMenuBar(Widget parent) {
71
Widget bar = DiagramWindow::CreateMenuBar(parent);
72
// make the duplicate item insensitive.
73
Widget w1 = editMenu->GetMenuItem("Duplicate");
75
XtVaSetValues(w1, XmNsensitive, False, 0);
79
Widget TRWindow::CreateTiles(Widget parent) {
80
Widget t = DiagramWindow::CreateTiles(parent);
81
(void)CreateLayoutTiles(t);
86
Widget TRWindow::CreateLayoutTiles(Widget parent) {
90
Widget frame = XtVaCreateManagedWidget("layout_tiles_frame1",
91
xmFrameWidgetClass, parent,
92
XmNshadowType, XmSHADOW_ETCHED_IN, 0);
94
XtVaCreateManagedWidget("Layout",
95
xmLabelWidgetClass, frame,
96
XmNchildType, XmFRAME_TITLE_CHILD, 0);
98
Widget rc = XtVaCreateWidget("rc1", xmRowColumnWidgetClass, frame,
99
XmNentryAlignment, XmALIGNMENT_CENTER, 0);
100
// create a radiobox for the tiles
101
XtSetArg(args[i], XmNradioAlwaysOne, True); i++;
102
char wname[8] = "Layout";
103
Widget rb = XmCreateRadioBox(rc, wname, args, i);
104
// create all layout tiles
106
lb1 = CreateXmString("Editable\nGraph");
107
lb2 = CreateXmString("Forked\nTree");
108
editButton = XtVaCreateManagedWidget("EditableGraph",
109
xmToggleButtonWidgetClass, rb,
111
XmNhighlightThickness, 0,
112
XmNlabelType, XmSTRING,
114
XmNuserData, (XtPointer)0,
115
XmNalignment, XmALIGNMENT_CENTER, 0);
116
XtAddCallback(editButton, XmNvalueChangedCallback,
117
TRWindow::LayoutCB, (XtPointer)this);
118
AddLiteClue(editButton, "Edit mode in which document is drawn as a graph");
119
treeButton = XtVaCreateManagedWidget("ForkedTree",
120
xmToggleButtonWidgetClass, rb,
123
XmNlabelType, XmSTRING,
124
XmNhighlightThickness, 0,
125
XmNuserData, (XtPointer)1,
126
XmNalignment, XmALIGNMENT_CENTER, 0);
127
XtAddCallback(treeButton, XmNvalueChangedCallback,
128
TRWindow::LayoutCB, (XtPointer)this);
129
AddLiteClue(treeButton, "View mode in which document has a forked tree layout");
137
void TRWindow::SetLayout(bool b) {
138
TRViewer *v = (TRViewer *)GetDiagramViewer();
139
if (!v->IsPasting() && !v->IsZigZag()) {
140
SetStatus("action: set layout");
141
v->UpdateTreeMode(b);
143
else if (b != v->IsTreeMode()) {
144
SetStatus("I'm busy with something else");
145
XmToggleButtonSetState(editButton, b, False);
146
XmToggleButtonSetState(treeButton, !b, False);
148
SetSensitive(editMenu, "Cut", !b);
149
SetSensitive(editMenu, "Copy", !b);
150
SetSensitive(editMenu, "Paste", !b);
151
SetSensitive(editMenu, "Delete", !b);
152
SetSensitive(editMenu, "Delete All", !b);
153
SetSensitive(editMenu, "Select All", !b);
154
SetSensitive(editMenu, "Same Size", !b);
155
SetSensitive(editMenu, "Align Nodes", !b);
156
GetDrawingArea()->Enable("Cut", !b);
157
GetDrawingArea()->Enable("Copy", !b);
158
GetDrawingArea()->Enable("Paste", !b);
159
GetDrawingArea()->Enable("Delete", !b);
160
GetDrawingArea()->Enable("Delete All", !b);
161
GetDrawingArea()->Enable("Select All", !b);
162
GetDrawingArea()->Enable("Same Size", !b);
163
GetDrawingArea()->Enable("Align Nodes", !b);
164
SetSensitive(fileMenu, "Append", !b);
165
SetSensitive(fileMenu, "Save Selection As", !b);
166
SetSensitive(searchMenu, "Replace", !b);
167
SetSensitive(propertiesMenu, "Node/Edge Annotation", !b);
168
SetSensitive(propertiesMenu, "Update Text Font", !b);
169
SetSensitive(propertiesMenu, "Update Line Width", !b);
170
SetSensitive(propertiesMenu, "Update Line Style", !b);
171
SetSensitive(propertiesMenu, "Update Line Ends", !b);
172
SetSensitive(propertiesMenu, "Set/Unset Text Underlining", !b);
173
SetSensitive(propertiesMenu, "Update Text Alignment", !b);
174
SetSensitive(propertiesMenu, "Update Line Color", !b);
175
SetSensitive(propertiesMenu, "Update Text Color", !b);
176
SetSensitive(propertiesMenu, "Update Fill Color", !b);
179
void TRWindow::SetSensitive(Menu *menu, const char *label, bool b) {
180
Widget w = menu->GetMenuItem(label);
182
XtVaSetValues(w, XmNsensitive, b, 0);
185
void TRWindow::LayoutCB(Widget w, XtPointer cd, XtPointer) {
186
if (XmToggleButtonGetState(w)) {
188
XtVaGetValues(w, XmNuserData, &num, 0);
189
((TRWindow *)cd)->SetLayout(num);