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

« back to all changes in this revision

Viewing changes to src/ed/drawwindow.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 1995, 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 "drawwindow.h"
 
23
#include "drawingarea.h"
 
24
#include "mstring.h"
 
25
#include "menu.h"
 
26
#include "config.h"
 
27
#include "editstubs.h"
 
28
#include "helper.h"
 
29
#include "document.h"
 
30
#include "viewer.h"
 
31
#include "system.h"
 
32
#include "liteclue.h"
 
33
#include <stdlib.h>
 
34
#include <Xm/XmAll.h>
 
35
 
 
36
const int DrawWindow::MIN_DRAWING_SIZE = 200;
 
37
 
 
38
DrawWindow::DrawWindow(const char *n): EditWindow(n) {
 
39
        drawingArea = 0;
 
40
        scrolledWindow = 0;
 
41
        verticalScrollBar = 0;
 
42
        horizontalScrollBar = 0;
 
43
        scaleValue = 0;
 
44
        documentItems = 0;
 
45
        documentInfoItems = 0;
 
46
}
 
47
 
 
48
DrawWindow::~DrawWindow() {
 
49
        if (documentItems)
 
50
                delete documentItems;
 
51
        if (documentInfoItems)
 
52
                delete documentInfoItems;
 
53
        if (scaleItems)
 
54
                delete scaleItems;
 
55
}
 
56
 
 
57
void DrawWindow::ParseUserOptions(int argc, char **argv) {
 
58
        int n;
 
59
        SetArgsLeft(argc-1);
 
60
        EditWindow::ParseUserOptions(argc, argv);
 
61
        DetermineScrollSize(GetScreenType());
 
62
        initDrawingWidth = GetConfig()->GetDrawingWidth();
 
63
        initDrawingHeight = GetConfig()->GetDrawingHeight();
 
64
        maxDrawingWidth = GetConfig()->GetDrawingMaxWidth();
 
65
        maxDrawingHeight = GetConfig()->GetDrawingMaxHeight();
 
66
        // look for -drawing option to set initial drawing area size.
 
67
        if (System::FindArg(argv, argc, "-drawing", n)) {
 
68
                if (n < argc-1 && 
 
69
                    System::NxnParse(argv[n+1], initDrawingWidth, 
 
70
                            initDrawingHeight))
 
71
                        SetArgsLeft(GetArgsLeft() - 2);
 
72
                else {
 
73
                        WriteUsage(argv[0]);
 
74
                        exit(1);
 
75
                }
 
76
        }
 
77
        // look for -maxdrawing option to set maximal drawing area size.
 
78
        if (System::FindArg(argv, argc, "-maxdrawing", n)) {
 
79
                if (n < argc-1 && 
 
80
                    System::NxnParse(argv[n+1], maxDrawingWidth, 
 
81
                                maxDrawingHeight))
 
82
                        SetArgsLeft(GetArgsLeft() - 2);
 
83
                else {
 
84
                        WriteUsage(argv[0]);
 
85
                        exit(1);
 
86
                }
 
87
        }
 
88
        initDrawingWidth = max(initDrawingWidth, MIN_DRAWING_SIZE);
 
89
        initDrawingHeight = max(initDrawingHeight, MIN_DRAWING_SIZE);
 
90
        maxDrawingWidth = max(initDrawingWidth, maxDrawingWidth);
 
91
        maxDrawingHeight = max(initDrawingHeight, maxDrawingHeight);
 
92
}
 
93
 
 
94
void DrawWindow::WriteUsage(const char *prog) {
 
95
        EditWindow::WriteUsage(prog);
 
96
}
 
97
 
 
98
void DrawWindow::FitDocument() {
 
99
        if (drawingArea)
 
100
                drawingArea->FitDocument();
 
101
}
 
102
 
 
103
void DrawWindow::FitDocument(int wd, int ht) {
 
104
        if (drawingArea)
 
105
                drawingArea->FitDocument(wd, ht);
 
106
}
 
107
 
 
108
Widget DrawWindow::CreateScrolledWindow(Widget parent) {
 
109
        // create an automatic scrolling window of N by N cm.
 
110
        // (the clipped drawing area is M by M cm.). The window
 
111
        // is so attached that when the main window is resized the
 
112
        // scrolled window is also resized
 
113
        if (!check(parent))
 
114
                return 0;
 
115
        Widget sw = XtVaCreateManagedWidget("ScrolledWindow",
 
116
                xmScrolledWindowWidgetClass, parent,
 
117
                XmNheight, scrollHeight,
 
118
                XmNwidth, scrollWidth,
 
119
                XmNscrollingPolicy, XmAUTOMATIC,
 
120
                XmNscrollBarDisplayPolicy, XmAS_NEEDED,
 
121
                XmNrightAttachment, XmATTACH_FORM, 0);
 
122
        if (GetDocumentArea())
 
123
                XtVaSetValues(sw, 
 
124
                        XmNtopAttachment, XmATTACH_WIDGET,
 
125
                        XmNtopWidget, GetDocumentArea(), 0);
 
126
        if (GetLogo())
 
127
                XtVaSetValues(sw, 
 
128
                        XmNtopAttachment, XmATTACH_WIDGET,
 
129
                        XmNtopWidget, GetLogo(), 0);
 
130
        if (GetStatusArea())
 
131
                XtVaSetValues(GetStatusArea(),
 
132
                        XmNtopAttachment, XmATTACH_WIDGET,
 
133
                        XmNtopWidget, sw, 0);
 
134
        else if (GetControlArea())
 
135
                XtVaSetValues(sw, 
 
136
                        XmNbottomAttachment, XmATTACH_WIDGET,
 
137
                        XmNbottomWidget, GetControlArea(), 0);
 
138
        else
 
139
                XtVaSetValues(sw, 
 
140
                        XmNbottomAttachment, XmATTACH_FORM, 0);
 
141
        XtVaGetValues(sw, XmNverticalScrollBar, &verticalScrollBar, 0);
 
142
        XtVaGetValues(sw, XmNhorizontalScrollBar, &horizontalScrollBar, 0);
 
143
        return sw;
 
144
}
 
145
 
 
146
void DrawWindow::ShowPosition(int x, int y) {
 
147
        if (!check(verticalScrollBar) || !check(horizontalScrollBar))
 
148
                return;
 
149
        int vincrement=0, vmaximum=0, vminimum=0, vpage_incr=0,
 
150
            vslider_size=0, vvalue=0;
 
151
        int hincrement=0, hmaximum=0, hminimum=0, hpage_incr=0,
 
152
            hslider_size=0, hvalue=0;
 
153
        XtVaGetValues(verticalScrollBar,
 
154
                XmNincrement, &vincrement,
 
155
                XmNmaximum, &vmaximum,
 
156
                XmNminimum, &vminimum,
 
157
                XmNpageIncrement, &vpage_incr,
 
158
                XmNsliderSize, &vslider_size,
 
159
                XmNvalue, &vvalue, 0);
 
160
        XtVaGetValues(horizontalScrollBar,
 
161
                XmNincrement, &hincrement,
 
162
                XmNmaximum, &hmaximum,
 
163
                XmNminimum, &hminimum,
 
164
                XmNpageIncrement, &hpage_incr,
 
165
                XmNsliderSize, &hslider_size,
 
166
                XmNvalue, &hvalue, 0);
 
167
        hvalue = min(hmaximum-hslider_size, max(0, (x - hslider_size/2)));
 
168
        XmScrollBarSetValues(horizontalScrollBar, hvalue, hslider_size,
 
169
                        hincrement, hpage_incr, True);
 
170
        vvalue = min(vmaximum - vslider_size, max(0, (y - vslider_size/2)));
 
171
        XmScrollBarSetValues(verticalScrollBar, vvalue, vslider_size,
 
172
                        vincrement, vpage_incr, True);
 
173
}
 
174
 
 
175
//
 
176
//static void get_sb(Widget w, XtPointer cd, XtPointer) {
 
177
//      int increment=0, maximum=0, minimum=0,page_incr=0,
 
178
//          slider_size=0, value=0;
 
179
//      XtVaGetValues((Widget)cd,
 
180
//              XmNincrement, &increment,
 
181
//              XmNmaximum, &maximum,
 
182
//              XmNminimum, &minimum,
 
183
//              XmNpageIncrement, &page_incr,
 
184
//              XmNsliderSize, &slider_size,
 
185
//              XmNvalue, &value, 0);
 
186
//}
 
187
//
 
188
 
 
189
Widget DrawWindow::CreateScaleValue(Widget parent) {
 
190
        if (!check(parent))
 
191
                return 0; 
 
192
        Widget z = XtVaCreateManagedWidget("ScaleValue",
 
193
                xmLabelWidgetClass, parent,
 
194
                XmNtopAttachment, XmATTACH_WIDGET,
 
195
                XmNtopWidget, scrolledWindow,
 
196
                XmNrightAttachment, XmATTACH_FORM, 0);
 
197
        // XtAddCallback(z, XmNactivateCallback, get_sb, verticalScrollBar);
 
198
        AddLiteClue(z, 
 
199
                "Current scale percentage (Alt+L = larger, Alt+S = smaller)");
 
200
        return z;
 
201
}
 
202
 
 
203
void DrawWindow::SetScaleValue(const char *s) {
 
204
        if (scaleValue) {
 
205
                string text = "Scale: ";
 
206
                text += s;
 
207
                XmString label = CreateXmString(text.getstr());
 
208
                XtVaSetValues(scaleValue, XmNlabelString, label, 0);
 
209
                XmStringFree(label);
 
210
        }
 
211
}
 
212
 
 
213
Widget DrawWindow::CreateControlArea(Widget parent) {
 
214
        Widget rc = EditWindow::CreateControlArea(parent);
 
215
        if (!(rc))
 
216
                return 0;
 
217
        if (arrowButtons)
 
218
                XtVaSetValues(rc, XmNleftAttachment, XmATTACH_WIDGET,
 
219
                        XmNleftOffset, 20,
 
220
                        XmNleftWidget, arrowButtons, 0);
 
221
        autoResizeToggle = CreateToggle(rc, "autoresizing", 
 
222
                        GetConfig()->GetAutoResizing(), 
 
223
                        EditStubs::SetAutoResizeCB, 
 
224
                        (XtPointer)GetDocument()->GetViewer());
 
225
        AddLiteClue(autoResizeToggle, 
 
226
                "When set, shapes resize themselves after text editing");
 
227
        inlineEditToggle = CreateToggle(rc, "in-line editor", 
 
228
                GetConfig()->GetInlineEditor(), EditStubs::SetInlineEditCB, 
 
229
                (XtPointer)GetDocument()->GetViewer());
 
230
        AddLiteClue(inlineEditToggle, 
 
231
                "When set, text is edited directly in the drawing area"
 
232
                " (in a separate window otherwise)");
 
233
        if ( Toolkit::HierarchicEditor(GetTool()) ) {
 
234
                hierarchicToggle = CreateToggle(rc, "hierarchic document",
 
235
                        False,
 
236
                        EditStubs::SetHierarchicCB, (XtPointer)GetDocument());
 
237
                AddLiteClue(hierarchicToggle,
 
238
                        "When set, document may contain "
 
239
                        "hierarchically related nodes");
 
240
        } else
 
241
                hierarchicToggle = 0;
 
242
        XtVaCreateManagedWidget("   Directory: ",
 
243
                xmLabelWidgetClass, rc,
 
244
                XmNalignment, XmALIGNMENT_BEGINNING, 0);
 
245
        Widget dn = XtVaCreateManagedWidget("DirectoryName",
 
246
                xmTextFieldWidgetClass, rc,
 
247
                XmNeditable, True,
 
248
                XmNcursorPositionVisible, True, 0);
 
249
        SetDirName(dn);
 
250
        AddLiteClue(dn, "Current project directory. Can be changed "
 
251
                "(apply with <enter>)");
 
252
        if (GetScreenType() <= SVGA)
 
253
                XtVaSetValues(dn, XmNcolumns, 28, 0);
 
254
        else if (GetScreenType() == XVGA)
 
255
                XtVaSetValues(dn, XmNcolumns, 34, 0);
 
256
        else
 
257
                XtVaSetValues(dn, XmNcolumns, 40, 0);
 
258
        XtAddCallback(dn, XmNactivateCallback,
 
259
                EditStubs::ChangeDirCB, (XtPointer)GetDocument());
 
260
        XtManageChild(rc);
 
261
        return rc;
 
262
}
 
263
 
 
264
Widget DrawWindow::CreateArrowButtonSquare(Widget parent) {
 
265
        Widget frame = XtVaCreateManagedWidget("ArrowsFrame",
 
266
                xmFrameWidgetClass, parent, 
 
267
                XmNbottomAttachment, XmATTACH_FORM,
 
268
                XmNleftAttachment, XmATTACH_FORM, 0);
 
269
        Widget form = XtVaCreateManagedWidget("ArrowsForm", 
 
270
                xmFormWidgetClass, frame, 
 
271
                XmNfractionBase, 3, 0);
 
272
        Widget a1 = XtVaCreateManagedWidget(
 
273
                "arrow1", xmArrowButtonWidgetClass, form,
 
274
                XmNtopPosition, 0,
 
275
                XmNbottomPosition, 1,
 
276
                XmNleftPosition, 1,
 
277
                XmNrightPosition, 2,
 
278
                XmNtopAttachment, XmATTACH_POSITION,
 
279
                XmNbottomAttachment, XmATTACH_POSITION,
 
280
                XmNrightAttachment, XmATTACH_POSITION,
 
281
                XmNleftAttachment, XmATTACH_POSITION,
 
282
                XmNarrowDirection, XmARROW_UP,
 
283
                XmNuserData, Document::UP, 0);
 
284
        Widget a2 = XtVaCreateManagedWidget(
 
285
                "arrow2", xmArrowButtonWidgetClass, form,
 
286
                XmNtopPosition, 1,
 
287
                XmNbottomPosition, 2,
 
288
                XmNleftPosition, 0,
 
289
                XmNrightPosition, 1,
 
290
                XmNtopAttachment, XmATTACH_POSITION,
 
291
                XmNbottomAttachment, XmATTACH_POSITION,
 
292
                XmNrightAttachment, XmATTACH_POSITION,
 
293
                XmNleftAttachment, XmATTACH_POSITION,
 
294
                XmNarrowDirection, XmARROW_LEFT,
 
295
                XmNuserData, (XtPointer)Document::LEFT, 0);
 
296
        Widget a3 = XtVaCreateManagedWidget(
 
297
                "arrow3", xmArrowButtonWidgetClass, form,
 
298
                XmNtopPosition, 1,
 
299
                XmNbottomPosition, 2,
 
300
                XmNleftPosition, 2,
 
301
                XmNrightPosition, 3,
 
302
                XmNtopAttachment, XmATTACH_POSITION,
 
303
                XmNbottomAttachment, XmATTACH_POSITION,
 
304
                XmNrightAttachment, XmATTACH_POSITION,
 
305
                XmNleftAttachment, XmATTACH_POSITION,
 
306
                XmNarrowDirection, XmARROW_RIGHT,
 
307
                XmNuserData, (XtPointer)Document::RIGHT, 0);
 
308
        Widget a4 = XtVaCreateManagedWidget(
 
309
                "arrow4", xmArrowButtonWidgetClass, form,
 
310
                XmNtopPosition, 2,
 
311
                XmNbottomPosition, 3,
 
312
                XmNleftPosition, 1,
 
313
                XmNrightPosition, 2,
 
314
                XmNtopAttachment, XmATTACH_POSITION,
 
315
                XmNbottomAttachment, XmATTACH_POSITION,
 
316
                XmNrightAttachment, XmATTACH_POSITION,
 
317
                XmNleftAttachment, XmATTACH_POSITION,
 
318
                XmNarrowDirection, XmARROW_DOWN,
 
319
                XmNuserData, (XtPointer)Document::DOWN, 0);
 
320
        XmString c = CreateXmString("C");
 
321
        Widget a5 = XtVaCreateManagedWidget(
 
322
                "arrow5", xmPushButtonWidgetClass, form,
 
323
                XmNlabelString, c,
 
324
                XmNtopPosition, 1,
 
325
                XmNbottomPosition, 2,
 
326
                XmNleftPosition, 1,
 
327
                XmNrightPosition, 2,
 
328
                XmNtopAttachment, XmATTACH_POSITION,
 
329
                XmNbottomAttachment, XmATTACH_POSITION,
 
330
                XmNrightAttachment, XmATTACH_POSITION,
 
331
                XmNleftAttachment, XmATTACH_POSITION,
 
332
                XmNuserData, (XtPointer)Document::CENTER, 0);
 
333
        XmStringFree(c);
 
334
        AddLiteClue(a1, "Move the document one step up");
 
335
        AddLiteClue(a2, "Move the document one step left");
 
336
        AddLiteClue(a3, "Move the document one step right");
 
337
        AddLiteClue(a4, "Move the document one step down");
 
338
        AddLiteClue(a5, "Center the document on the page");
 
339
        if (check(GetDocument())) {
 
340
                XtAddCallback(a1, XmNactivateCallback, 
 
341
                        EditStubs::MoveCB, (XtPointer)GetDocument());
 
342
                XtAddCallback(a2, XmNactivateCallback, 
 
343
                        EditStubs::MoveCB, (XtPointer)GetDocument());
 
344
                XtAddCallback(a3, XmNactivateCallback, 
 
345
                        EditStubs::MoveCB, (XtPointer)GetDocument());
 
346
                XtAddCallback(a4, XmNactivateCallback, 
 
347
                        EditStubs::MoveCB, (XtPointer)GetDocument());
 
348
                XtAddCallback(a5, XmNactivateCallback, 
 
349
                        EditStubs::MoveCB, (XtPointer)GetDocument());
 
350
        }
 
351
        return frame;
 
352
}
 
353
 
 
354
void DrawWindow::EnableUndo(bool flag) {
 
355
        EditWindow::EnableUndo(flag);
 
356
        if (drawingArea)
 
357
                drawingArea->EnableUndo(flag);
 
358
}
 
359
 
 
360
void DrawWindow::EnableRedo(bool flag) {
 
361
        EditWindow::EnableRedo(flag);
 
362
        if (drawingArea)
 
363
                drawingArea->EnableRedo(flag);
 
364
}
 
365
 
 
366
void DrawWindow::SetUndoName(const char *uname) {
 
367
        EditWindow::SetUndoName(uname);
 
368
        if (drawingArea)
 
369
                drawingArea->SetUndoName(uname);
 
370
}
 
371
 
 
372
void DrawWindow::SetRedoName(const char *uname) {
 
373
        EditWindow::SetRedoName(uname);
 
374
        if (drawingArea)
 
375
                drawingArea->SetRedoName(uname);
 
376
}
 
377
 
 
378
void DrawWindow::DetermineScrollSize(ScreenType s) {
 
379
        if (s == HP19) {
 
380
                scrollWidth = 816;
 
381
                scrollHeight = 680;
 
382
        }
 
383
        else if (s == NCD16) {
 
384
                scrollWidth = 724;
 
385
                scrollHeight = 680;
 
386
        }
 
387
        else if (s == SUN17) {
 
388
                scrollWidth = 724;
 
389
                scrollHeight = 660;
 
390
        }
 
391
        else if (s == NCD19B) {
 
392
                scrollWidth = 624;
 
393
                scrollHeight = 580;
 
394
        }
 
395
        else if (s == XVGA) {
 
396
                scrollWidth = 624;
 
397
                scrollHeight = 550;
 
398
        }
 
399
        else if (s == SVGA) {
 
400
                scrollWidth = 510;
 
401
                scrollHeight = 403;
 
402
        }
 
403
        else if (s == VGA) {
 
404
                scrollWidth = 418;
 
405
                scrollHeight = 306;
 
406
        }
 
407
        else if (s == EGA) {
 
408
                scrollWidth = 300;
 
409
                scrollHeight = 200;
 
410
        }
 
411
#ifdef DEBUG
 
412
        error("scroll wxh = %dx%d\n", scrollWidth, scrollHeight);
 
413
#endif
 
414
}
 
415
 
 
416
void DrawWindow::SetAutoResize(bool set) {
 
417
        if (autoResizeToggle)
 
418
                XtVaSetValues(autoResizeToggle, XmNset, set, 0);
 
419
}
 
420
 
 
421
void DrawWindow::SetInlineEdit(bool set) {
 
422
        if (inlineEditToggle)
 
423
                XtVaSetValues(inlineEditToggle, XmNset, set, 0); 
 
424
}
 
425
 
 
426
 
 
427
/* virtual */ void DrawWindow::SetHierarchic(bool set) {
 
428
        if ( hierarchicToggle )
 
429
                XtVaSetValues(hierarchicToggle, XmNset, set, 0);
 
430
}
 
431
 
 
432
 
 
433
void DrawWindow::CreateDrawingArea() {
 
434
        drawingArea = new DrawingArea(
 
435
                        GetConfig(), scrolledWindow, "DrawingArea", this);
 
436
}
 
437
 
 
438
void DrawWindow::Finalize() {
 
439
        EditWindow::Finalize();
 
440
        SetScaleValue("100%");
 
441
}
 
442
 
 
443
void DrawWindow::InitMenuItems() {
 
444
        // All menu-items of the application and their stub functions
 
445
        int i = 0;
 
446
        fileItems = new MenuItem[25]; i = 0;
 
447
        fileItems[i] = MenuItem( 
 
448
                "New", MenuItem::PUSHBUTTON, 'N', "Ctrl<Key>N", "Ctrl+N", 
 
449
                EditStubs::NewCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
450
        fileItems[i] = MenuItem(
 
451
                "Load...", MenuItem::PUSHBUTTON, 'L', "Ctrl<Key>L", "Ctrl+L", 
 
452
                EditStubs::LoadCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
453
        fileItems[i] = MenuItem(
 
454
                "Append...", MenuItem::PUSHBUTTON, 'A', "Ctrl<Key>A", "Ctrl+A", 
 
455
                EditStubs::AppendCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
456
        fileItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
457
        fileItems[i] = MenuItem(
 
458
                "Save", MenuItem::PUSHBUTTON, 'v', 0, 0, 
 
459
                EditStubs::SaveCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
460
        fileItems[i] = MenuItem(
 
461
                "Save As...", MenuItem::PUSHBUTTON, 'S', 
 
462
                "Ctrl<Key>S", "Ctrl+S", EditStubs::SaveAsCB, 
 
463
                (XtPointer)GetDocument(), 0, 0, 1); i++;
 
464
        fileItems[i] = MenuItem(
 
465
                "Save Selection As...", MenuItem::PUSHBUTTON, 'e', 0,0,
 
466
                EditStubs::SaveSelectionAsCB, (XtPointer)GetDocument(), 
 
467
                0, 0, 1); i++;
 
468
        fileItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
469
        fileItems[i] = MenuItem(
 
470
                "Quit", MenuItem::PUSHBUTTON, 'Q', "Ctrl<Key>Q", "Ctrl+Q", 
 
471
                EditStubs::QuitCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
472
        fileItems[i] = MenuItem::NUL;
 
473
 
 
474
        pageSizeItems = new MenuItem[10]; i = 0;
 
475
        pageSizeItems[i] = MenuItem(
 
476
                "A3 (297 x 420 mm)", MenuItem::RADIOBUTTON, '3', 0, 0, 
 
477
                EditStubs::PageSizeCB, (XtPointer)GetPrinter(), 
 
478
                (XtPointer)(GetConfig()->GetPageSize()==PageSize::A3), 0, 1); i++;
 
479
        pageSizeItems[i] = MenuItem(
 
480
                "A4 (210 x 297 mm)", MenuItem::RADIOBUTTON, 'A', 0, 0, 
 
481
                EditStubs::PageSizeCB, (XtPointer)GetPrinter(), 
 
482
                (XtPointer)(GetConfig()->GetPageSize()==PageSize::A4), 0, 1); i++;
 
483
        pageSizeItems[i] = MenuItem(
 
484
                "Letter (8 1/2 x 11 in.)", MenuItem::RADIOBUTTON, 'L', 0, 0, 
 
485
                EditStubs::PageSizeCB, (XtPointer)GetPrinter(), 
 
486
                (XtPointer)(GetConfig()->GetPageSize()==PageSize::LETTER), 0, 1); i++;
 
487
        pageSizeItems[i] = MenuItem(
 
488
                "Legal (8 1/2 x 14 in.)", MenuItem::RADIOBUTTON, 'g', 0, 0, 
 
489
                EditStubs::PageSizeCB, (XtPointer)GetPrinter(), 
 
490
                (XtPointer)(GetConfig()->GetPageSize()==PageSize::LEGAL), 0, 1); i++;
 
491
        pageSizeItems[i] = MenuItem(
 
492
                "Executive (7 1/2 x 10 in.)", MenuItem::RADIOBUTTON, 'E', 0, 0, 
 
493
                EditStubs::PageSizeCB, (XtPointer)GetPrinter(),
 
494
                (XtPointer)(GetConfig()->GetPageSize()==PageSize::EXECUTIVE), 0, 1); i++;
 
495
        pageSizeItems[i] = MenuItem::NUL;
 
496
 
 
497
        bannerPageItems = new MenuItem[10]; i = 0;
 
498
        bannerPageItems[i] = MenuItem(
 
499
                "Print Default Banner Page", MenuItem::RADIOBUTTON, 'D', 0, 0, 
 
500
                EditStubs::BannerPageCB, (XtPointer)GetPrinter(), 
 
501
                (XtPointer)(2*i+(GetConfig()->GetBannerPage()==Config::DEF_BANNER)), 
 
502
                0, 1); i++;
 
503
        bannerPageItems[i] = MenuItem(
 
504
                "Print No Banner Page", MenuItem::RADIOBUTTON, 'N', 0, 0, 
 
505
                EditStubs::BannerPageCB, (XtPointer)GetPrinter(), 
 
506
                (XtPointer)(2*i+(GetConfig()->GetBannerPage()==Config::NO_BANNER)), 
 
507
                0, 1); i++;
 
508
        bannerPageItems[i] = MenuItem(
 
509
                "Print TCM Banner Page", MenuItem::RADIOBUTTON, 'T', 0, 0, 
 
510
                EditStubs::BannerPageCB, (XtPointer)GetPrinter(), 
 
511
                (XtPointer)(2*i+(GetConfig()->GetBannerPage()==Config::TCM_BANNER)), 
 
512
                0, 1); i++;
 
513
        bannerPageItems[i] = MenuItem::NUL;
 
514
 
 
515
        printerOptionsItems = new MenuItem[25]; i=0;
 
516
        printerOptionsItems[i] = MenuItem(
 
517
                "Printer Name...", MenuItem::PUSHBUTTON, 'N', 0, 0, 
 
518
                EditStubs::PrinterNameCB, (XtPointer)GetPrinter(), 
 
519
                0, 0, 1); i++;
 
520
        printerOptionsItems[i] = MenuItem(
 
521
                "Number of Copies...", MenuItem::PUSHBUTTON, 'o', 0, 0, 
 
522
                EditStubs::PrinterCopiesCB, (XtPointer)GetPrinter(), 
 
523
                0, 0, 1); i++;
 
524
        printerOptionsItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
525
        printerOptionsItems[i] = MenuItem(
 
526
                "Print Command...", MenuItem::PUSHBUTTON, 'P', 0, 0, 
 
527
                EditStubs::PrintCommandCB, (XtPointer)GetPrinter(), 
 
528
                0, 0, 1); i++;
 
529
        printerOptionsItems[i] = MenuItem(
 
530
                "Printer Queue Command...", MenuItem::PUSHBUTTON, 'Q', 0, 0, 
 
531
                EditStubs::PrinterQueueCommandCB, (XtPointer)GetPrinter(), 
 
532
                0, 0, 1); i++;
 
533
        printerOptionsItems[i] = MenuItem(
 
534
                "Printer Remove Command...", MenuItem::PUSHBUTTON, 'R', 0, 0, 
 
535
                EditStubs::PrinterRemoveCommandCB, (XtPointer)GetPrinter(), 
 
536
                0, 0, 1);
 
537
                i++;
 
538
        printerOptionsItems[i] = MenuItem(
 
539
                "Preview Command...", MenuItem::PUSHBUTTON, 'v', 0, 0, 
 
540
                EditStubs::PreviewCommandCB, (XtPointer)GetPrinter(), 
 
541
                0, 0, 1); i++;
 
542
        printerOptionsItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
543
        printerOptionsItems[i] = MenuItem(
 
544
                "Print Colors", MenuItem::CHECKBUTTON, 'C', 0, 0, 
 
545
                EditStubs::SetPrintColorsCB, (XtPointer)GetPrinter(), 
 
546
                (XtPointer)(GetConfig()->GetPrintColors()), 0, 1); i++;
 
547
        printerOptionsItems[i] = MenuItem(
 
548
                "Print Duplex Pages", MenuItem::CHECKBUTTON, 'D', 0, 0, 
 
549
                EditStubs::SetDuplexCB, (XtPointer)GetPrinter(), 
 
550
                (XtPointer)(GetConfig()->GetPrintDuplexPages()), 0, 1); i++;
 
551
        printerOptionsItems[i] = MenuItem(
 
552
                "Print Tumbled Pages", MenuItem::CHECKBUTTON, 'T', 0, 0, 
 
553
                EditStubs::SetTumbleCB, (XtPointer)GetPrinter(), 
 
554
                (XtPointer)(GetConfig()->GetPrintTumbledPages()), 0, 1); i++;
 
555
        printerOptionsItems[i] = MenuItem(
 
556
                "Print Banner Page Options", MenuItem::SUBMENU, 'B', 0, 0, 
 
557
                0, 0, 0, bannerPageItems, 1); i++;
 
558
        printerOptionsItems[i] = MenuItem::NUL;
 
559
 
 
560
        printItems = new MenuItem[25]; i=0;
 
561
        printItems[i] = MenuItem(
 
562
                "Print", MenuItem::PUSHBUTTON, 'P', "Ctrl<Key>P", "Ctrl+P", 
 
563
                EditStubs::PrintCB, (XtPointer)GetPrinter(), 0, 0, 1); i++;
 
564
        printItems[i] = MenuItem(
 
565
                "Export...", MenuItem::PUSHBUTTON, 'E', "Ctrl<Key>E", "Ctrl+E",
 
566
                EditStubs::ExportAsCB, (XtPointer)GetPrinter(), 0, 0, 1); i++;
 
567
        printItems[i] = MenuItem(
 
568
                "Show Preview...", MenuItem::PUSHBUTTON, 'S', 0, 0,
 
569
                EditStubs::ShowPrintPreviewCB, (XtPointer)GetPrinter(), 
 
570
                0, 0, 1); i++;
 
571
        printItems[i] = MenuItem(
 
572
                "Printer Queue...", MenuItem::PUSHBUTTON, 'Q', 0, 0, 
 
573
                EditStubs::ShowPrinterQueueCB, (XtPointer)GetPrinter(), 
 
574
                0, 0, 1); i++;
 
575
        printItems[i] = MenuItem(
 
576
                "Printer Properties", MenuItem::SUBMENU, 'O', 0, 0, 
 
577
                0, 0, 0, printerOptionsItems, 1); i++;
 
578
        printItems[i] = MenuItem::NUL;
 
579
 
 
580
        searchItems = new MenuItem[25]; i=0;
 
581
        searchItems[i] = MenuItem(
 
582
                "Find...", MenuItem::PUSHBUTTON, 'F', "Ctrl<Key>F", "Ctrl+F",
 
583
                EditStubs::FindCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
584
        searchItems[i] = MenuItem(
 
585
                "Replace...", MenuItem::PUSHBUTTON, 'R', "Ctrl<Key>Z", "Ctrl+Z",
 
586
                EditStubs::ReplaceCB, (XtPointer)GetDocument(), 0, 0, 1); i++;
 
587
        searchItems[i] = MenuItem::NUL;
 
588
 
 
589
        toolIntroMenuLabel = "Introduction to ";
 
590
        toolIntroMenuLabel += Toolkit::TOOL_NAMES[GetTool()];
 
591
        
 
592
        helpItems = new MenuItem[25]; i=0;
 
593
        helpItems[i] = MenuItem(
 
594
                "Getting Started", MenuItem::PUSHBUTTON, 'G', 0, 0, 
 
595
                EditStubs::HelpCB, (XtPointer)GetHelper(), 
 
596
                (XtPointer)Helper::GETTING_STARTED, 0, 1); i++;
 
597
        helpItems[i] = MenuItem(
 
598
                (char *)toolIntroMenuLabel.getstr(), MenuItem::PUSHBUTTON, 
 
599
                'T', 0, 0, EditStubs::HelpCB, (XtPointer)GetHelper(), 
 
600
                (XtPointer)Helper::TOOL_INTRO, 0, 1); i++;
 
601
        helpItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
602
        helpItems[i] = MenuItem(
 
603
                "Main Window", MenuItem::PUSHBUTTON, 'W', 0, 0, 
 
604
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
605
                (XtPointer)Helper::THE_MAIN_WINDOW, 0, 1); i++;
 
606
        helpItems[i] = MenuItem(
 
607
                "Mouse Commands", MenuItem::PUSHBUTTON, 'M', 0, 0, 
 
608
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
609
                (XtPointer)Helper::MOUSE_COMMANDS, 0, 1); i++;
 
610
        helpItems[i] = MenuItem(
 
611
                "Edit Menu Commands", MenuItem::PUSHBUTTON, 'E', 0, 0, 
 
612
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
613
                (XtPointer)Helper::EDIT_COMMANDS, 0, 1); i++;
 
614
        helpItems[i] = MenuItem(
 
615
                "File Menu Commands", MenuItem::PUSHBUTTON, 'F', 0, 0, 
 
616
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
617
                (XtPointer)Helper::FILE_COMMANDS, 0, 1); i++;
 
618
        helpItems[i] = MenuItem(
 
619
                "Print & Page Commands", MenuItem::PUSHBUTTON, 'P', 0, 0, 
 
620
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
621
                (XtPointer)Helper::PRINT_PAGE_COMMANDS, 0, 1); i++;
 
622
        helpItems[i] = MenuItem(
 
623
                "Miscellaneous Commands", MenuItem::PUSHBUTTON, 'i', 0, 0, 
 
624
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
625
                (XtPointer)Helper::MISC_COMMANDS, 0, 1); i++;
 
626
        helpItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
 
627
        helpItems[i] = MenuItem(
 
628
                "Version", MenuItem::PUSHBUTTON, 'V', 0, 0, 
 
629
                EditStubs::HelpCB, (XtPointer)GetHelper(), 
 
630
                (XtPointer)Helper::VERSION, 0, 1); i++;
 
631
        helpItems[i] = MenuItem(
 
632
                "Copying", MenuItem::PUSHBUTTON, 'C', 0, 0, 
 
633
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
634
                (XtPointer)Helper::COPYING, 0, 1); i++;
 
635
        helpItems[i] = MenuItem(
 
636
                "Change Log", MenuItem::PUSHBUTTON, 'L', 0, 0, 
 
637
                EditStubs::HelpCB, (XtPointer)GetHelper(),
 
638
                (XtPointer)Helper::CHANGELOG, 0, 1); i++;
 
639
        helpItems[i] = MenuItem::NUL;
 
640
 
 
641
        pageOrientationItems = new MenuItem[10]; i=0;
 
642
        pageOrientationItems[i] = MenuItem(
 
643
                "Portrait", MenuItem::RADIOBUTTON, 'P', 0, 0, 
 
644
                EditStubs::PageOrientationCB, (XtPointer)GetPrinter(), 
 
645
                (XtPointer)(2*i+(GetConfig()->GetPageOrientation()==
 
646
                Config::PORTRAIT)), 0, 1); i++;
 
647
        pageOrientationItems[i] = MenuItem(
 
648
                "Landscape", MenuItem::RADIOBUTTON, 'L', 0, 0, 
 
649
                EditStubs::PageOrientationCB, (XtPointer)GetPrinter(), 
 
650
                (XtPointer)(2*i+(GetConfig()->GetPageOrientation()==
 
651
                Config::LANDSCAPE)), 0, 1); i++;
 
652
        pageOrientationItems[i] = MenuItem::NUL;
 
653
 
 
654
        documentInfoItems = new MenuItem[10]; i=0;
 
655
        documentInfoItems[i] = MenuItem(
 
656
                "None", MenuItem::RADIOBUTTON, 'N', 0, 0, 
 
657
                EditStubs::ShowDocumentInfoCB, (XtPointer)GetPrinter(), 
 
658
                (XtPointer)(2*i + (!GetConfig()->GetShowDocumentInfoAsHeader() && 
 
659
                !GetConfig()->GetShowDocumentInfoAsFooter())), 0, 1); i++;
 
660
        documentInfoItems[i] = MenuItem(
 
661
                "As Header", MenuItem::RADIOBUTTON, 'H', 0, 0, 
 
662
                EditStubs::ShowDocumentInfoCB, (XtPointer)GetPrinter(), 
 
663
                (XtPointer)(2*i + GetConfig()->GetShowDocumentInfoAsHeader()), 
 
664
                0, 1); i++;
 
665
        documentInfoItems[i] = MenuItem(
 
666
                "As Footer", MenuItem::RADIOBUTTON, 'F', 0, 0, 
 
667
                EditStubs::ShowDocumentInfoCB, (XtPointer)GetPrinter(), 
 
668
                (XtPointer)(2*i + GetConfig()->GetShowDocumentInfoAsFooter()), 
 
669
                0, 1); i++;
 
670
        documentInfoItems[i] = MenuItem(
 
671
                "Both Header & Footer", MenuItem::RADIOBUTTON, 'B', 0, 0, 
 
672
                EditStubs::ShowDocumentInfoCB, (XtPointer)GetPrinter(), 
 
673
                (XtPointer)(2*i + (GetConfig()->GetShowDocumentInfoAsHeader() && 
 
674
                GetConfig()->GetShowDocumentInfoAsFooter())), 0, 1); i++;
 
675
        documentInfoItems[i] = MenuItem::NUL;
 
676
 
 
677
        pageItems = new MenuItem[10]; i=0;
 
678
        pageItems[i] = MenuItem(
 
679
                "Show Page Boundary", MenuItem::CHECKBUTTON, 'B', 0, 0, 
 
680
                EditStubs::ShowPageBoundaryCB, (XtPointer)GetPrinter(), 
 
681
                (XtPointer)(GetConfig()->GetShowPageBoundary()), 0, 1); i++;
 
682
        pageItems[i] = MenuItem(
 
683
                "Page Orientation", MenuItem::SUBMENU, 'O', 0, 0, 
 
684
                0, 0, 0, pageOrientationItems, 1); i++;
 
685
        pageItems[i] = MenuItem(
 
686
                "Page Size", MenuItem::SUBMENU, 'S', 0, 0, 
 
687
                0, 0, 0, pageSizeItems, 1); i++;
 
688
        pageItems[i] = MenuItem("", MenuItem::SEPARATOR);
 
689
        pageItems[i] = MenuItem(
 
690
                "Include Page Numbers", MenuItem::CHECKBUTTON, 'P', 0, 0, 
 
691
                EditStubs::ShowPageNumbersCB, (XtPointer)GetPrinter(), 
 
692
                (XtPointer)(GetConfig()->GetIncludePageNumbers()), 0, 1); i++;
 
693
        pageItems[i] = MenuItem(
 
694
                "Include Document Info", MenuItem::SUBMENU, 'D', 0, 0, 
 
695
                0, 0, 0, documentInfoItems, 1); i++;
 
696
        pageItems[i] = MenuItem::NUL;
 
697
 
 
698
        documentItems = new MenuItem[25]; i=0;
 
699
        documentItems[i] = MenuItem(
 
700
                "Document Info...", MenuItem::PUSHBUTTON, 'I', 0, 0, 
 
701
                EditStubs::DocumentInfoCB, (XtPointer)GetDocument(), 
 
702
                0, 0, 1); i++;
 
703
        documentItems[i] = MenuItem(
 
704
                "Document Source...", MenuItem::PUSHBUTTON, 'S', 0, 0,
 
705
                EditStubs::DocumentSourceCB, (XtPointer)GetDocument(),
 
706
                0, 0, 0); i++;
 
707
        documentItems[i] = MenuItem(
 
708
                "Document Annotation ...", MenuItem::PUSHBUTTON, 'A', 0, 0,
 
709
                EditStubs::AnnotateDocumentCB, (XtPointer)GetDocument(),
 
710
                0, 0, 1); i++;
 
711
        if (!Toolkit::GenericEditor(GetTool())) {
 
712
                documentItems[i] = MenuItem(
 
713
                "Check Document Syntax...", MenuItem::PUSHBUTTON, 'C', 0, 0, 
 
714
                EditStubs::CheckDocumentCB, (XtPointer)GetDocument(), 
 
715
                0, 0, 1); i++;
 
716
 
 
717
                if ( Toolkit::EditorWithModelChecker(GetTool()) ) {
 
718
                        documentItems[i] = MenuItem(
 
719
                        "Model Check Property...",
 
720
                        MenuItem::PUSHBUTTON, 'M', 0, 0,           
 
721
                        EditStubs::ModelCheckPropertyCB,
 
722
                        (XtPointer)GetDocument(), 0, 0, 1); i++;
 
723
                        documentItems[i] = MenuItem(
 
724
                        "Clear Trace",
 
725
                        MenuItem::PUSHBUTTON, 'C', 0, 0,
 
726
                        EditStubs::ClearTraceCB,
 
727
                        (XtPointer)GetDocument(), 0, 0, 1); i++;
 
728
 
 
729
                }
 
730
        }
 
731
        if ( Toolkit::HierarchicEditor(GetTool()) ) {
 
732
                documentItems[i] = MenuItem(
 
733
                        "Hierarchic Document", MenuItem::CHECKBUTTON, 'H', 0, 0,
 
734
                        EditStubs::SetHierarchicCB, (XtPointer)GetDocument(), 
 
735
                        (XtPointer) False, 0, 1); i++;
 
736
        }
 
737
        documentItems[i] = MenuItem::NUL;
 
738
 
 
739
        scaleItems = new MenuItem[10]; i=0;
 
740
        scaleItems[i] = MenuItem(
 
741
                "Make Larger", MenuItem::PUSHBUTTON, 'L', "Alt<Key>L", "Alt+L", 
 
742
                EditStubs::MakeLargerCB, 
 
743
                (XtPointer)GetDocument()->GetViewer()->GetScaler(), 
 
744
                0, 0, 1); i++;
 
745
        scaleItems[i] = MenuItem(
 
746
                "Make Smaller", MenuItem::PUSHBUTTON, 'S', "Alt<Key>S", "Alt+S",
 
747
                EditStubs::MakeSmallerCB, 
 
748
                (XtPointer)GetDocument()->GetViewer()->GetScaler(), 
 
749
                0, 0, 1); i++;
 
750
        scaleItems[i] = MenuItem(
 
751
                "Normal Scale", MenuItem::PUSHBUTTON, 'N', "Alt<Key>N", "Alt+N",
 
752
                EditStubs::NormalScaleCB, 
 
753
                (XtPointer)GetDocument()->GetViewer()->GetScaler(), 
 
754
                0, 0, 1); i++;
 
755
        scaleItems[i] = MenuItem(
 
756
                "Whole Drawing", MenuItem::PUSHBUTTON, 'W', 
 
757
                "Alt<Key>W", "Alt+W", EditStubs::WholeDrawingCB, 
 
758
                (XtPointer)GetDocument()->GetViewer()->GetScaler(), 
 
759
                0, 0, 1); i++;
 
760
        scaleItems[i] = MenuItem("", MenuItem::SEPARATOR);
 
761
        scaleItems[i] = MenuItem(
 
762
                "Scale Factor...", MenuItem::PUSHBUTTON, 'F', 
 
763
                "Alt<Key>F", "Alt+F", EditStubs::ScaleFactorCB, 
 
764
                (XtPointer)GetDocument()->GetViewer()->GetScaler(), 
 
765
                0, 0, 1); i++;
 
766
        scaleItems[i] = MenuItem::NUL;
 
767
}
 
768
 
 
769
void DrawWindow::EnableDocumentSource(bool flag) {
 
770
        if (!documentMenu)
 
771
                return;
 
772
        Widget docMenuItem = documentMenu->GetMenuItem("Document Source...");
 
773
        if (docMenuItem)
 
774
                XtVaSetValues(docMenuItem, XmNsensitive, flag, 0);
 
775
}