1
////////////////////////////////////////////////////////////////////////////////
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).
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
////////////////////////////////////////////////////////////////////////////////
22
#include "drawwindow.h"
23
#include "drawingarea.h"
27
#include "editstubs.h"
36
const int DrawWindow::MIN_DRAWING_SIZE = 200;
38
DrawWindow::DrawWindow(const char *n): EditWindow(n) {
41
verticalScrollBar = 0;
42
horizontalScrollBar = 0;
45
documentInfoItems = 0;
48
DrawWindow::~DrawWindow() {
51
if (documentInfoItems)
52
delete documentInfoItems;
57
void DrawWindow::ParseUserOptions(int argc, char **argv) {
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)) {
69
System::NxnParse(argv[n+1], initDrawingWidth,
71
SetArgsLeft(GetArgsLeft() - 2);
77
// look for -maxdrawing option to set maximal drawing area size.
78
if (System::FindArg(argv, argc, "-maxdrawing", n)) {
80
System::NxnParse(argv[n+1], maxDrawingWidth,
82
SetArgsLeft(GetArgsLeft() - 2);
88
initDrawingWidth = max(initDrawingWidth, MIN_DRAWING_SIZE);
89
initDrawingHeight = max(initDrawingHeight, MIN_DRAWING_SIZE);
90
maxDrawingWidth = max(initDrawingWidth, maxDrawingWidth);
91
maxDrawingHeight = max(initDrawingHeight, maxDrawingHeight);
94
void DrawWindow::WriteUsage(const char *prog) {
95
EditWindow::WriteUsage(prog);
98
void DrawWindow::FitDocument() {
100
drawingArea->FitDocument();
103
void DrawWindow::FitDocument(int wd, int ht) {
105
drawingArea->FitDocument(wd, ht);
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
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())
124
XmNtopAttachment, XmATTACH_WIDGET,
125
XmNtopWidget, GetDocumentArea(), 0);
128
XmNtopAttachment, XmATTACH_WIDGET,
129
XmNtopWidget, GetLogo(), 0);
131
XtVaSetValues(GetStatusArea(),
132
XmNtopAttachment, XmATTACH_WIDGET,
133
XmNtopWidget, sw, 0);
134
else if (GetControlArea())
136
XmNbottomAttachment, XmATTACH_WIDGET,
137
XmNbottomWidget, GetControlArea(), 0);
140
XmNbottomAttachment, XmATTACH_FORM, 0);
141
XtVaGetValues(sw, XmNverticalScrollBar, &verticalScrollBar, 0);
142
XtVaGetValues(sw, XmNhorizontalScrollBar, &horizontalScrollBar, 0);
146
void DrawWindow::ShowPosition(int x, int y) {
147
if (!check(verticalScrollBar) || !check(horizontalScrollBar))
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);
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);
189
Widget DrawWindow::CreateScaleValue(Widget parent) {
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);
199
"Current scale percentage (Alt+L = larger, Alt+S = smaller)");
203
void DrawWindow::SetScaleValue(const char *s) {
205
string text = "Scale: ";
207
XmString label = CreateXmString(text.getstr());
208
XtVaSetValues(scaleValue, XmNlabelString, label, 0);
213
Widget DrawWindow::CreateControlArea(Widget parent) {
214
Widget rc = EditWindow::CreateControlArea(parent);
218
XtVaSetValues(rc, XmNleftAttachment, XmATTACH_WIDGET,
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",
236
EditStubs::SetHierarchicCB, (XtPointer)GetDocument());
237
AddLiteClue(hierarchicToggle,
238
"When set, document may contain "
239
"hierarchically related nodes");
241
hierarchicToggle = 0;
242
XtVaCreateManagedWidget(" Directory: ",
243
xmLabelWidgetClass, rc,
244
XmNalignment, XmALIGNMENT_BEGINNING, 0);
245
Widget dn = XtVaCreateManagedWidget("DirectoryName",
246
xmTextFieldWidgetClass, rc,
248
XmNcursorPositionVisible, True, 0);
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);
257
XtVaSetValues(dn, XmNcolumns, 40, 0);
258
XtAddCallback(dn, XmNactivateCallback,
259
EditStubs::ChangeDirCB, (XtPointer)GetDocument());
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,
275
XmNbottomPosition, 1,
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,
287
XmNbottomPosition, 2,
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,
299
XmNbottomPosition, 2,
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,
311
XmNbottomPosition, 3,
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,
325
XmNbottomPosition, 2,
328
XmNtopAttachment, XmATTACH_POSITION,
329
XmNbottomAttachment, XmATTACH_POSITION,
330
XmNrightAttachment, XmATTACH_POSITION,
331
XmNleftAttachment, XmATTACH_POSITION,
332
XmNuserData, (XtPointer)Document::CENTER, 0);
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());
354
void DrawWindow::EnableUndo(bool flag) {
355
EditWindow::EnableUndo(flag);
357
drawingArea->EnableUndo(flag);
360
void DrawWindow::EnableRedo(bool flag) {
361
EditWindow::EnableRedo(flag);
363
drawingArea->EnableRedo(flag);
366
void DrawWindow::SetUndoName(const char *uname) {
367
EditWindow::SetUndoName(uname);
369
drawingArea->SetUndoName(uname);
372
void DrawWindow::SetRedoName(const char *uname) {
373
EditWindow::SetRedoName(uname);
375
drawingArea->SetRedoName(uname);
378
void DrawWindow::DetermineScrollSize(ScreenType s) {
383
else if (s == NCD16) {
387
else if (s == SUN17) {
391
else if (s == NCD19B) {
395
else if (s == XVGA) {
399
else if (s == SVGA) {
412
error("scroll wxh = %dx%d\n", scrollWidth, scrollHeight);
416
void DrawWindow::SetAutoResize(bool set) {
417
if (autoResizeToggle)
418
XtVaSetValues(autoResizeToggle, XmNset, set, 0);
421
void DrawWindow::SetInlineEdit(bool set) {
422
if (inlineEditToggle)
423
XtVaSetValues(inlineEditToggle, XmNset, set, 0);
427
/* virtual */ void DrawWindow::SetHierarchic(bool set) {
428
if ( hierarchicToggle )
429
XtVaSetValues(hierarchicToggle, XmNset, set, 0);
433
void DrawWindow::CreateDrawingArea() {
434
drawingArea = new DrawingArea(
435
GetConfig(), scrolledWindow, "DrawingArea", this);
438
void DrawWindow::Finalize() {
439
EditWindow::Finalize();
440
SetScaleValue("100%");
443
void DrawWindow::InitMenuItems() {
444
// All menu-items of the application and their stub functions
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(),
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;
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;
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)),
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)),
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)),
513
bannerPageItems[i] = MenuItem::NUL;
515
printerOptionsItems = new MenuItem[25]; i=0;
516
printerOptionsItems[i] = MenuItem(
517
"Printer Name...", MenuItem::PUSHBUTTON, 'N', 0, 0,
518
EditStubs::PrinterNameCB, (XtPointer)GetPrinter(),
520
printerOptionsItems[i] = MenuItem(
521
"Number of Copies...", MenuItem::PUSHBUTTON, 'o', 0, 0,
522
EditStubs::PrinterCopiesCB, (XtPointer)GetPrinter(),
524
printerOptionsItems[i] = MenuItem("", MenuItem::SEPARATOR); i++;
525
printerOptionsItems[i] = MenuItem(
526
"Print Command...", MenuItem::PUSHBUTTON, 'P', 0, 0,
527
EditStubs::PrintCommandCB, (XtPointer)GetPrinter(),
529
printerOptionsItems[i] = MenuItem(
530
"Printer Queue Command...", MenuItem::PUSHBUTTON, 'Q', 0, 0,
531
EditStubs::PrinterQueueCommandCB, (XtPointer)GetPrinter(),
533
printerOptionsItems[i] = MenuItem(
534
"Printer Remove Command...", MenuItem::PUSHBUTTON, 'R', 0, 0,
535
EditStubs::PrinterRemoveCommandCB, (XtPointer)GetPrinter(),
538
printerOptionsItems[i] = MenuItem(
539
"Preview Command...", MenuItem::PUSHBUTTON, 'v', 0, 0,
540
EditStubs::PreviewCommandCB, (XtPointer)GetPrinter(),
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;
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(),
571
printItems[i] = MenuItem(
572
"Printer Queue...", MenuItem::PUSHBUTTON, 'Q', 0, 0,
573
EditStubs::ShowPrinterQueueCB, (XtPointer)GetPrinter(),
575
printItems[i] = MenuItem(
576
"Printer Properties", MenuItem::SUBMENU, 'O', 0, 0,
577
0, 0, 0, printerOptionsItems, 1); i++;
578
printItems[i] = MenuItem::NUL;
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;
589
toolIntroMenuLabel = "Introduction to ";
590
toolIntroMenuLabel += Toolkit::TOOL_NAMES[GetTool()];
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;
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;
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()),
665
documentInfoItems[i] = MenuItem(
666
"As Footer", MenuItem::RADIOBUTTON, 'F', 0, 0,
667
EditStubs::ShowDocumentInfoCB, (XtPointer)GetPrinter(),
668
(XtPointer)(2*i + GetConfig()->GetShowDocumentInfoAsFooter()),
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;
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;
698
documentItems = new MenuItem[25]; i=0;
699
documentItems[i] = MenuItem(
700
"Document Info...", MenuItem::PUSHBUTTON, 'I', 0, 0,
701
EditStubs::DocumentInfoCB, (XtPointer)GetDocument(),
703
documentItems[i] = MenuItem(
704
"Document Source...", MenuItem::PUSHBUTTON, 'S', 0, 0,
705
EditStubs::DocumentSourceCB, (XtPointer)GetDocument(),
707
documentItems[i] = MenuItem(
708
"Document Annotation ...", MenuItem::PUSHBUTTON, 'A', 0, 0,
709
EditStubs::AnnotateDocumentCB, (XtPointer)GetDocument(),
711
if (!Toolkit::GenericEditor(GetTool())) {
712
documentItems[i] = MenuItem(
713
"Check Document Syntax...", MenuItem::PUSHBUTTON, 'C', 0, 0,
714
EditStubs::CheckDocumentCB, (XtPointer)GetDocument(),
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(
725
MenuItem::PUSHBUTTON, 'C', 0, 0,
726
EditStubs::ClearTraceCB,
727
(XtPointer)GetDocument(), 0, 0, 1); i++;
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++;
737
documentItems[i] = MenuItem::NUL;
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(),
745
scaleItems[i] = MenuItem(
746
"Make Smaller", MenuItem::PUSHBUTTON, 'S', "Alt<Key>S", "Alt+S",
747
EditStubs::MakeSmallerCB,
748
(XtPointer)GetDocument()->GetViewer()->GetScaler(),
750
scaleItems[i] = MenuItem(
751
"Normal Scale", MenuItem::PUSHBUTTON, 'N', "Alt<Key>N", "Alt+N",
752
EditStubs::NormalScaleCB,
753
(XtPointer)GetDocument()->GetViewer()->GetScaler(),
755
scaleItems[i] = MenuItem(
756
"Whole Drawing", MenuItem::PUSHBUTTON, 'W',
757
"Alt<Key>W", "Alt+W", EditStubs::WholeDrawingCB,
758
(XtPointer)GetDocument()->GetViewer()->GetScaler(),
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(),
766
scaleItems[i] = MenuItem::NUL;
769
void DrawWindow::EnableDocumentSource(bool flag) {
772
Widget docMenuItem = documentMenu->GetMenuItem("Document Source...");
774
XtVaSetValues(docMenuItem, XmNsensitive, flag, 0);