~ubuntu-branches/ubuntu/utopic/tcm/utopic

« back to all changes in this revision

Viewing changes to src/ed/editwindow.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 1997, 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 "mstring.h"
 
23
#include "document.h"
 
24
#include "editstubs.h"
 
25
#include "printer.h"
 
26
#include "helper.h"
 
27
#include "bitmap.h"
 
28
#include "menu.h"
 
29
#include "system.h"
 
30
#include "version.h"
 
31
#include "liteclue.h"
 
32
#include "config.h"
 
33
#include <stdlib.h>
 
34
#include <Xm/XmAll.h>
 
35
#include "messagedialog.h"
 
36
#include "Teapot2a.xbm"
 
37
 
 
38
EditWindow::EditWindow(const char *n): MainWindow(n) {
 
39
        helper = 0;
 
40
        document = 0;
 
41
        printer = 0;
 
42
        logo = 0;
 
43
        menubar = 0;
 
44
        popupEditItems = 0;
 
45
        fileItems = 0;
 
46
        editItems = 0;
 
47
        printItems = 0;
 
48
        printerOptionsItems = 0;
 
49
        propertiesItems = 0;
 
50
        pageOrientationItems = 0;
 
51
        pageSizeItems = 0;
 
52
        bannerPageItems = 0;
 
53
        pageItems = 0;
 
54
        helpItems = 0;
 
55
        searchItems = 0;
 
56
        viewItems = 0;
 
57
        documentArea = 0;
 
58
        statusArea = 0;
 
59
        statusText = 0;
 
60
        dirName = 0;
 
61
        documentName = 0;
 
62
        documentLevel = 0;
 
63
        documentType = 0;
 
64
        modifiedToggle = 0;
 
65
        editMenu = 0;
 
66
        screenType = SUN17;
 
67
        doLoad = False;
 
68
        projDir = "";
 
69
        loadFile = "";
 
70
        generatePS = False;
 
71
        generateEPS = False;
 
72
        generateFig = False;
 
73
        generatePNG = False;
 
74
        generateLatexFonts = False;
 
75
        doMap = True;
 
76
}
 
77
 
 
78
EditWindow::~EditWindow() {
 
79
        if (helper)
 
80
                delete helper;
 
81
        if (printer)
 
82
                delete printer;
 
83
        if (document)
 
84
                delete document;
 
85
        if (popupEditItems)
 
86
                delete popupEditItems;
 
87
        if (fileItems)
 
88
                delete fileItems;
 
89
        if (editItems)
 
90
                delete editItems;
 
91
        if (printItems)
 
92
                delete printItems;
 
93
        if (printerOptionsItems)
 
94
                delete printerOptionsItems;
 
95
        if (bannerPageItems)
 
96
                delete bannerPageItems;
 
97
        if (helpItems)
 
98
                delete helpItems;
 
99
        if (viewItems)
 
100
                delete viewItems;
 
101
        if (searchItems)
 
102
                delete searchItems;
 
103
        if (propertiesItems)
 
104
                delete propertiesItems;
 
105
        if (pageOrientationItems)
 
106
                delete pageOrientationItems;
 
107
        if (pageSizeItems)
 
108
                delete pageSizeItems;
 
109
        if (pageItems)
 
110
                delete pageItems;
 
111
}
 
112
 
 
113
void EditWindow::Manage() {
 
114
        if (doMap)
 
115
                MainWindow::Manage();
 
116
        else
 
117
                MainWindow::ManageUnmapped();
 
118
}
 
119
 
 
120
Widget EditWindow::CreateWorkArea(Widget parent, int argc, char **argv) {
 
121
        if (!check(parent))
 
122
                return 0;
 
123
        logoBitmap.xbm_width = Teapot2a_width;
 
124
        logoBitmap.xbm_height = Teapot2a_height;
 
125
        logoBitmap.xbm_bits = (unsigned char *)Teapot2a_bits;
 
126
        logoPixmap = logoBitmap.CreatePixmap(parent, GetDisplay());
 
127
        Widget form = XtVaCreateManagedWidget(GetName()->getstr(), 
 
128
                xmFormWidgetClass, parent, 0);
 
129
        // find type of document tool 
 
130
        int tool = GetTool();
 
131
        // parse command line options
 
132
        DetermineScreen(XtScreen(parent)); // determine screen sizes.
 
133
        ParseUserOptions(argc, argv);
 
134
        // Create application objects.
 
135
        CreateHelper();
 
136
        CreateDocument();
 
137
        CreatePrinter();
 
138
        CreateComponents(form); // create the UI components of the main window.
 
139
        string title = Toolkit::TOOLKIT_NAME;
 
140
        title += ": ";
 
141
        title += Toolkit::TOOL_TITLES[tool];
 
142
        title += " - ";
 
143
        title += Version::TOOLKIT_VERSION;
 
144
        SetTitle(&title);
 
145
        // set name and pixmap of the icon.
 
146
        SetIconName(Toolkit::TOOL_NAMES[tool]); 
 
147
        SetIconPixmap(logoPixmap);
 
148
        return form;
 
149
}
 
150
 
 
151
void EditWindow::ParseUserOptions(int argc, char **argv) {
 
152
        int n;
 
153
        argsLeft = argc-1;
 
154
        bool doExit = False;
 
155
        // look for help option.
 
156
        if (System::FindArg(argv, argc, "-help", n) || 
 
157
            System::FindArg(argv, argc, "-h", n)) {
 
158
                WriteUsage(argv[0]);
 
159
                doExit = True;
 
160
        }
 
161
        // look for version option.
 
162
        if (System::FindArg(argv, argc, "-version", n) ||
 
163
            System::FindArg(argv, argc, "-v", n)) {
 
164
                std::cerr << argv[0] << ": " << Version::TOOLKIT_VERSION << std::endl;
 
165
                doExit = True;
 
166
        }
 
167
        if (doExit)
 
168
                exit(0);
 
169
        // find but ignore priv_cmap option here.
 
170
        if (System::FindArg(argv, argc, "-priv_cmap", n)) {
 
171
                argsLeft -= 1;
 
172
        }
 
173
        // look for -project option to set working directory.
 
174
        if (System::FindArg(argv, argc, "-projdir", n)) {
 
175
                if (n < argc-1) {
 
176
                        projDir = argv[n+1]; 
 
177
                        argsLeft -= 2;
 
178
                }
 
179
                else {
 
180
                        WriteUsage(argv[0]);
 
181
                        exit(1);
 
182
                }
 
183
        }
 
184
        // look for -toPS option to generate PS.
 
185
        if (System::FindArg(argv, argc, "-toPS", n)) {
 
186
                argsLeft -= 1;
 
187
                psFile = "";
 
188
                generatePS = True;
 
189
                doMap = False;
 
190
                if (n < argc-1) {
 
191
                        char *c = strrchr(argv[n+1], '.');
 
192
                        if (c && equal(c, ".ps")) {
 
193
                                argsLeft -= 1;
 
194
                                psFile = argv[n+1];
 
195
                        }
 
196
                }
 
197
        }
 
198
        // look for -toEPS option to generate EPS.
 
199
        if (System::FindArg(argv, argc, "-toEPS", n)) {
 
200
                argsLeft -= 1;
 
201
                epsFile = "";
 
202
                generateEPS = True;
 
203
                doMap = False;
 
204
                if (n < argc-1) {
 
205
                        char *c = strrchr(argv[n+1], '.');
 
206
                        if (c && equal(c, ".eps")) {
 
207
                                argsLeft -= 1;
 
208
                                epsFile = argv[n+1];
 
209
                        }
 
210
                }
 
211
        }
 
212
        // look for -toPNG option to generate PNG.
 
213
        if (System::FindArg(argv, argc, "-toPNG", n)) {
 
214
                argsLeft -= 1;
 
215
                pngFile = "";
 
216
                generatePNG = True;
 
217
                doMap = False;
 
218
                if (n < argc-1) {
 
219
                        char *c = strrchr(argv[n+1], '.');
 
220
                        if (c && equal(c, ".png")) {
 
221
                                argsLeft -= 1;
 
222
                                pngFile = argv[n+1];
 
223
                        }
 
224
                }
 
225
        }
 
226
        // look for -toFig option to generate Fig.
 
227
        if (System::FindArg(argv, argc, "-toFig", n) ||
 
228
            System::FindArg(argv, argc, "-toFIG", n)) {
 
229
                argsLeft -= 1;
 
230
                figFile = "";
 
231
                generateFig = True;
 
232
                doMap = False;
 
233
                if (n < argc-1) {
 
234
                        char *c = strrchr(argv[n+1], '.');
 
235
                        if (c && equal(c, ".fig")) {
 
236
                                argsLeft -= 1;
 
237
                                figFile = argv[n+1];
 
238
                        }
 
239
                }
 
240
                if (System::FindArg(argv, argc, "-latex", n)) {
 
241
                        argsLeft -= 1;
 
242
                        generateLatexFonts = True;
 
243
                }
 
244
        }
 
245
}
 
246
 
 
247
void EditWindow::WriteUsage(const char *prog) {
 
248
        const char *OPTIONS = 
 
249
        "-drawing <w>x<h>\tCreate drawing area of <w>x<h> pixels\n"
 
250
        "-h[elp]\t\t\tShow this message and quit\n"
 
251
        "-maxdrawing <w>x<h>\tSet maximum drawing area size to <w>x<h> pixels\n"
 
252
        "-projdir <dir>\t\tSet the project directory to <dir>\n"
 
253
        "-priv_cmap\t\tStart the editor with a private colormap\n"
 
254
        "-toPS [<file>.ps]\tGenerate PostScript (to <file>.ps or else stdout) "             
 
255
                "and quit\n"
 
256
        "-toEPS [<file>.eps]\tGenerate EPS (to <file>.eps or else stdout) "
 
257
               "and quit\n"
 
258
        "-toFig [<file>.fig] [-latex]\tGenerate Fig format (to <file>.fig "
 
259
                "or else\n\t\t\tstdout) and quit. "
 
260
                "When the -latex option is given\n\t\t\tLaTeX fonts are "
 
261
                "generated, otherwise normal PostScript\n\t\t\t fonts"
 
262
                "are generated\n"
 
263
        "-toPNG <file>.png\tGenerate PNG format to <file>.png and quit\n"
 
264
        "-v[ersion]\t\tShow the TCM version and quit\n"
 
265
        "remark: the -toXXX options require an existing TCM document file\n";
 
266
        std::cerr << "Usage: " << prog << " [options] [document]\nOptions:\n"
 
267
             << OPTIONS << std::endl;
 
268
}
 
269
 
 
270
 
 
271
Widget EditWindow::CreateLogo(Widget parent) {
 
272
        // draws a little picture in the top right corner of parent. 
 
273
        if (!check(parent))
 
274
                return 0;
 
275
        Pixel fg, bg;
 
276
        // get the foreground and background colors of the parent
 
277
        // to make the pixmaps appear using a consistent color
 
278
        XtVaGetValues(parent, XmNforeground, &fg, XmNbackground, &bg, 0);
 
279
        // the pixmap is loaded from a X11 bitmap, called DEFAULT_ICON.
 
280
        Pixmap px = logoBitmap.CreatePixmap(parent, GetDisplay()); 
 
281
        Widget button = XtVaCreateManagedWidget(
 
282
                        "logo", xmPushButtonWidgetClass, parent,
 
283
                        XmNlabelPixmap, px,
 
284
                        XmNlabelType, XmPIXMAP,
 
285
                        XmNtopAttachment, XmATTACH_FORM,
 
286
                        XmNrightAttachment, XmATTACH_FORM, 0);
 
287
        XtAddCallback(button, XmNactivateCallback, AboutCB, (XtPointer)this);
 
288
        AddLiteClue(button, "TCM logo");
 
289
        return button;
 
290
}
 
291
 
 
292
Widget EditWindow::CreateDocumentArea(Widget parent) {
 
293
        // draws a label and a text-field which is intended to contain the
 
294
        // name and type of document that is being edited
 
295
        if (!check(parent))
 
296
                return 0;
 
297
        Widget rc = XtVaCreateWidget("DocumentArea", 
 
298
                xmRowColumnWidgetClass, parent, 
 
299
                XmNadjustLast, True,
 
300
                XmNorientation, XmHORIZONTAL,
 
301
                XmNleftAttachment, XmATTACH_FORM, 0);
 
302
        if (menubar)
 
303
                XtVaSetValues(rc, XmNtopAttachment, XmATTACH_WIDGET,
 
304
                        XmNtopWidget, menubar, 0);
 
305
        if (logo)
 
306
                XtVaSetValues(rc, XmNrightAttachment, XmATTACH_WIDGET,
 
307
                        XmNrightWidget, logo, 0);
 
308
        XtVaCreateManagedWidget("Document Type: ",
 
309
                xmLabelWidgetClass, rc,
 
310
                XmNalignment, XmALIGNMENT_BEGINNING, 0);
 
311
        documentType = XtVaCreateManagedWidget("DocumentType",
 
312
                xmTextFieldWidgetClass, rc, 
 
313
                XmNcolumns, 15,
 
314
                XmNeditable, False,
 
315
                XmNcursorPositionVisible, False, 0);
 
316
        AddLiteClue(documentType, 
 
317
                "The type of document that is edited by this editor (fixed)");
 
318
        XtVaCreateManagedWidget("Name: ",
 
319
                xmLabelWidgetClass, rc, 
 
320
                XmNalignment, XmALIGNMENT_BEGINNING, 0);
 
321
        documentName = XtVaCreateManagedWidget("DocumentName",
 
322
                xmTextFieldWidgetClass, rc, 
 
323
                XmNeditable, True,
 
324
                XmNcolumns, 10,
 
325
                XmNcursorPositionVisible, True, 0);
 
326
        AddLiteClue(documentName, 
 
327
                "The document name. Can be changed (apply with <enter>)");
 
328
        if (check(document))
 
329
                XtAddCallback(documentName, XmNactivateCallback, 
 
330
                        EditStubs::ChangeNameCB, (XtPointer)document);
 
331
        if (Toolkit::HierarchicEditor(GetTool())) {
 
332
//              XtVaCreateManagedWidget("Level: ",
 
333
//                      xmLabelWidgetClass, rc,
 
334
//                      XmNalignment, XmALIGNMENT_BEGINNING, 0);
 
335
//              documentLevel = XtVaCreateManagedWidget("DocumentLevel",
 
336
//                      xmTextFieldWidgetClass, rc,
 
337
//                      XmNeditable, False,
 
338
//                      XmNcursorPositionVisible, False, 0);
 
339
//              AddLiteClue(documentLevel,
 
340
//                      "The current level in the document (fixed)");
 
341
        }
 
342
        modifiedToggle = CreateToggle(rc, "modified", False, 
 
343
                        EditStubs::SetModifiedCB, (XtPointer)document);
 
344
        AddLiteClue(modifiedToggle, "Indicates document modification");
 
345
        XtUninstallTranslations(modifiedToggle); 
 
346
        XtManageChild(rc);
 
347
        return rc;
 
348
}
 
349
 
 
350
Widget EditWindow::CreateControlArea(Widget parent) {
 
351
        if (!check(parent))
 
352
                return 0;
 
353
        Widget rc = XtVaCreateWidget("ControlArea", 
 
354
                xmRowColumnWidgetClass, parent, 
 
355
                XmNorientation, XmHORIZONTAL, 0);
 
356
        if (statusArea) 
 
357
                XtVaSetValues(rc, XmNtopWidget, statusArea, 
 
358
                        XmNtopAttachment, XmATTACH_WIDGET, 0);
 
359
        XtVaSetValues(rc, XmNbottomAttachment, XmATTACH_FORM, 0);
 
360
        XtManageChild(rc);
 
361
        return rc;
 
362
}
 
363
 
 
364
Widget EditWindow::CreateStatusArea(Widget parent) {
 
365
        // create a single line uneditable text field. This is the area 
 
366
        // intended for (status) text output of the application.
 
367
        if (!check(parent))
 
368
                return 0;
 
369
        Widget rc = XtVaCreateWidget("StatusArea", 
 
370
                xmRowColumnWidgetClass, parent, 
 
371
                XmNorientation, XmHORIZONTAL, 0);
 
372
        if (controlArea) 
 
373
                XtVaSetValues(rc, XmNbottomWidget, controlArea, 
 
374
                        XmNbottomAttachment, XmATTACH_WIDGET, 0);
 
375
        statusText = XtVaCreateManagedWidget("StatusText",
 
376
                xmTextFieldWidgetClass, rc, 
 
377
                XmNeditable, False,
 
378
                XmNcursorPositionVisible, False,
 
379
                XmNshadowThickness, 0,
 
380
                XmNvalue, "...", 0);
 
381
        if (screenType <= SVGA)
 
382
                XtVaSetValues(statusText, XmNcolumns, 40, 0);
 
383
        else
 
384
                XtVaSetValues(statusText, XmNcolumns, 50, 0);
 
385
        XtManageChild(rc);
 
386
        return rc;
 
387
}
 
388
 
 
389
Widget EditWindow::CreateToggle(Widget parent, const char *label, bool Init, 
 
390
                        XtCallbackProc fun, XtPointer clientData) {
 
391
        if (!check(parent))
 
392
                return 0;
 
393
        XmString text = CreateXmString(label);
 
394
        Widget toggle = XtVaCreateManagedWidget(label, 
 
395
                xmToggleButtonWidgetClass, parent,
 
396
                XmNlabelString, text,
 
397
                XmNset, Init, 0);
 
398
        XtAddCallback(toggle, XmNvalueChangedCallback, fun, clientData);
 
399
        XmStringFree(text);
 
400
        return toggle;
 
401
}
 
402
 
 
403
void EditWindow::EnableUndo(bool flag) {
 
404
        // change edit pulldown menu undo sensitiveness.
 
405
        if (!editMenu)
 
406
                return;
 
407
        Widget undoMenuItem = editMenu->GetMenuItem("Undo");
 
408
        if (undoMenuItem) {
 
409
                XtVaSetValues(undoMenuItem, XmNsensitive, flag, 0);
 
410
        }
 
411
}
 
412
 
 
413
void EditWindow::EnableRedo(bool flag) {
 
414
        // change edit pulldown menu redo sensitiveness.
 
415
        if (!editMenu)
 
416
                return;
 
417
        Widget redoMenuItem = editMenu->GetMenuItem("Redo");
 
418
        if (redoMenuItem)
 
419
                XtVaSetValues(redoMenuItem, XmNsensitive, flag, 0);
 
420
}
 
421
 
 
422
void EditWindow::SetUndoName(const char *uname) {
 
423
        // change edit pulldown menu undo label.
 
424
        if (!editMenu)
 
425
                return;
 
426
        XmString s = CreateXmString(uname);
 
427
        Widget undoMenuItem = editMenu->GetMenuItem("Undo");
 
428
        if (undoMenuItem)
 
429
                XtVaSetValues(undoMenuItem, XmNlabelString, s, 0);
 
430
        XmStringFree(s);
 
431
}
 
432
 
 
433
void EditWindow::SetRedoName(const char *uname) {
 
434
        // change edit pulldown menu redo label.
 
435
        if (!editMenu)
 
436
                return;
 
437
        XmString s = CreateXmString(uname);
 
438
        Widget redoMenuItem = editMenu->GetMenuItem("Redo");
 
439
        if (redoMenuItem)
 
440
                XtVaSetValues(redoMenuItem, XmNlabelString, s, 0);
 
441
        XmStringFree(s);
 
442
}
 
443
 
 
444
void EditWindow::DetermineScreen(Screen *s) {
 
445
        int width = WidthOfScreen(s);
 
446
        int height = HeightOfScreen(s);
 
447
#ifdef DEBUG
 
448
        error("screen wxh = %dx%d\n", width, height);
 
449
#endif
 
450
        // Find out what popular resolution the screen has.
 
451
        if (width >= 1280 && height >= 1024)
 
452
                screenType = HP19;
 
453
        else if (width >= 1024 && height >= 1024)
 
454
                screenType = NCD16;
 
455
        else if (width >= 1152 && height >= 900)
 
456
                screenType = SUN17;
 
457
        else if (width >= 1024 && height >= 800)
 
458
                screenType = NCD19B;
 
459
        else if (width >= 1024 && height >= 768)
 
460
                screenType = XVGA;
 
461
        else if (width >= 800 && height >= 600)
 
462
                screenType = SVGA;
 
463
        else if (width >= 640 && height >= 480)
 
464
                screenType = VGA;
 
465
        else
 
466
                screenType = VGA;
 
467
}
 
468
 
 
469
void EditWindow::CreatePrinter() {
 
470
        if (check(document) && check(GetConfig()))
 
471
                printer = new Printer(GetConfig(), document);
 
472
}
 
473
 
 
474
void EditWindow::CreateHelper() {
 
475
        helper = new Helper(GetConfig(), this);
 
476
}
 
477
 
 
478
void EditWindow::Finalize() {
 
479
        document->UpdateWindow();
 
480
        if (projDir != "")
 
481
                document->NewDir(&projDir);
 
482
        SetStatus("");
 
483
        // if a file is given as command line option, try to load it.
 
484
        if (doLoad) {
 
485
                loadFile.setSuffix(*document->GetSuffix());
 
486
                if (System::FileExists(loadFile.getstr()))
 
487
                        document->DoLoad(&loadFile);
 
488
                else {
 
489
                        if (doMap)
 
490
                                document->NewFile(&loadFile);
 
491
                }
 
492
        }
 
493
        // "send email on startup?"
 
494
        if (GetConfig()->GetSendEmailOnStartup()) {
 
495
                System::SendEmail(System::emailAddress, 
 
496
                    System::TOOLKIT_STAT_HEADER, Toolkit::TOOL_NAMES[GetTool()], 
 
497
                    Version::TOOLKIT_VERSION, "");
 
498
        }
 
499
        // generate PS, EPS, PNG or Fig??
 
500
        if (!doMap) {
 
501
                if (!doLoad) {
 
502
                        std::cerr << "error: no document file name given" << std::endl;
 
503
                        WriteUsage(Toolkit::EXECUTABLE_NAMES[GetTool()]);
 
504
                }
 
505
                else if (!document->IsLoaded()) {
 
506
                        std::cerr << "error: incorrect or non-existent document " 
 
507
                                "file given" << std::endl;
 
508
                        WriteUsage(Toolkit::EXECUTABLE_NAMES[GetTool()]);
 
509
                }
 
510
                else {
 
511
                        if (generatePS)
 
512
                                printer->SavePostScript(&psFile, False);
 
513
                        if (generateEPS)
 
514
                                printer->SaveEPS(&epsFile);
 
515
                        if (generatePNG)
 
516
                                printer->SavePNG(&pngFile);
 
517
                        if (generateFig)
 
518
                                printer->SaveFig(&figFile, generateLatexFonts);
 
519
                }
 
520
                Close();
 
521
        }
 
522
}
 
523
 
 
524
void EditWindow::SetStatus(const char *message) {
 
525
        if (statusText)
 
526
                XtVaSetValues(statusText, XmNvalue, message, 0); 
 
527
}
 
528
 
 
529
void EditWindow::SetStatus(const string *message) {
 
530
        SetStatus(message->getstr());
 
531
}
 
532
 
 
533
void EditWindow::SetDocumentName(const char *s) {
 
534
        if (documentName) {
 
535
                int columns = min(30, max(10, strlen(s)+2));
 
536
                XtVaSetValues(documentName, XmNvalue, s, 
 
537
                              XmNcolumns, columns, 0); 
 
538
                // show document name also in the icon.
 
539
                SetIconName(s); 
 
540
        }
 
541
}
 
542
 
 
543
void EditWindow::SetDocumentName(const string *s) {
 
544
        SetDocumentName(s->getstr());
 
545
}
 
546
 
 
547
void EditWindow::SetDocumentType(const char *s) {
 
548
        if (documentType) {
 
549
                int columns = min(30, max(10, strlen(s)+2));
 
550
                XtVaSetValues(documentType, XmNvalue, s,
 
551
                                    XmNcolumns, columns, 0); 
 
552
        }
 
553
}
 
554
 
 
555
void EditWindow::SetDocumentType(const string *s) {
 
556
        SetDocumentType(s->getstr());
 
557
}
 
558
 
 
559
void EditWindow::SetDirName(const char *s) {
 
560
        if (dirName) {
 
561
                int columns = min(30, max(10, strlen(s)+4));
 
562
                XtVaSetValues(dirName, XmNvalue, s,
 
563
                                XmNcolumns, columns, 0); 
 
564
        }
 
565
}
 
566
 
 
567
void EditWindow::SetDirName(const string *s) {
 
568
        SetDirName(s->getstr());
 
569
}
 
570
 
 
571
void EditWindow::SetModified(bool set) {
 
572
        if (modifiedToggle)
 
573
                XtVaSetValues(modifiedToggle, XmNset, set, 0); 
 
574
}
 
575
 
 
576
void EditWindow::AboutCB(Widget w, XtPointer, XtPointer) {
 
577
        MessageDialog *t = new MessageDialog(w, MessageDialog::MESSAGE);
 
578
        t->Show("About TCM", Version::ABOUT_TEXT);
 
579
}
 
580
 
 
581
void EditWindow::SetDocumentLevel(const char *s) {
 
582
        if (documentLevel)
 
583
                XtVaSetValues(documentLevel, XmNvalue, s,
 
584
                                            XmNcolumns, strlen(s)+1, 0);
 
585
}
 
586
 
 
587
void EditWindow::SetDocumentLevel(const string *s) {
 
588
        SetDocumentLevel(s->getstr());
 
589
}
 
590
 
 
591
void EditWindow::SetPageSubMenuItem(const char *text, int n) {
 
592
        if (!pageMenu)
 
593
                return;
 
594
        Widget item = pageMenu->GetMenuItem(text);
 
595
        if (check(item))
 
596
                Menu::SetNthChildToggleState(
 
597
                        item, Menu::PULLDOWN, n+1, True, True);
 
598
}
 
599
 
 
600
void EditWindow::SetPageMenuItem(const char *text, bool b) {
 
601
        if (!pageMenu)
 
602
                return;
 
603
        Menu::SetChildToggleState(pageMenu->GetWidget(), 
 
604
                Menu::PULLDOWN, text, b);
 
605
}