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

« back to all changes in this revision

Viewing changes to src/ed/viewer.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 "grafport.h"
 
23
#include "viewer.h"
 
24
#include "command.h"
 
25
#include "printer.h"
 
26
#include "inlineeditor.h"
 
27
#include "config.h"
 
28
#include "scaledialog.h"
 
29
#include "ntogglelistdialog.h"
 
30
#include "linestyledialog.h"
 
31
#include "linewidthdialog.h"
 
32
#include "textalignmentdialog.h"
 
33
#include "fontchooserdialog.h"
 
34
#include "colorchooserdialog.h"
 
35
#include "editstubs.h"
 
36
#include "key.h"
 
37
#include <ctype.h>
 
38
 
 
39
const int Viewer::MIN_LINE_WIDTH=1;
 
40
const int Viewer::MAX_LINE_WIDTH=10;
 
41
 
 
42
Viewer::Viewer(Config *c, DrawWindow *d) {
 
43
 
 
44
        mainwindow = d;
 
45
        config = c;
 
46
        grafport = 0;
 
47
        scaler = new Scaler(c, this, d);
 
48
        lastCmd = -1;
 
49
        lastCmdIllegal = True;
 
50
        cmdHistSize = 0;
 
51
        edit = 0;
 
52
        printer = 0;
 
53
        editing = False;
 
54
        pasting = False;
 
55
        zigZag = False;
 
56
        // set these defaults from config.
 
57
        autoResizing = config->GetAutoResizing();
 
58
        inlineEditor = config->GetInlineEditor();
 
59
        defaultLineWidth=max(MIN_LINE_WIDTH, 
 
60
                             min(config->GetLineWidth(), MAX_LINE_WIDTH));
 
61
        defaultLineStyle=config->GetLineStyle();
 
62
        defaultLineColor=*config->GetLineColor();
 
63
        defaultTextColor=*config->GetTextColor();
 
64
        defaultFillColor=*config->GetFillColor();
 
65
        defaultFillStyle = FillStyle::UNFILLED;
 
66
        defaultTextAlignment = config->GetTextAlignment();
 
67
        defaultFont = new XFont(config->GetFontFoundry(), 
 
68
                config->GetFontFamily(), config->GetFontStyle(), 
 
69
                config->GetPointSize(), config->GetScalableFonts());
 
70
        defaultFont->SetUnderlined(config->GetUnderlined());
 
71
        fontList = new List<XFont *>;
 
72
        fontList->add(defaultFont);
 
73
        // font chooser stuff
 
74
        fontChooserDialog = new FontChooserDialog(d->GetWidget(),
 
75
                                                                                                config->GetAddPointSizes());
 
76
        fontChooserDialog->Initialize();
 
77
        // color chooser stuff
 
78
        colorChooserDialog = new ColorChooserDialog(d->GetWidget());
 
79
        colorChooserDialog->Initialize();
 
80
        // line width stuff
 
81
        lineWidthDialog = new LineWidthDialog(d->GetWidget());
 
82
        lineWidthDialog->Initialize();
 
83
        // line style stuff
 
84
        lineStyleDialog = new LineStyleDialog(d->GetWidget());
 
85
        lineStyleDialog->Initialize();
 
86
        // text align stuff
 
87
        textAlignmentDialog = new TextAlignmentDialog(d->GetWidget());
 
88
        textAlignmentDialog->Initialize();
 
89
 
 
90
        ShowConfigLineStyle();
 
91
        ShowConfigLineWidth();
 
92
        ShowConfigTextAlignment();
 
93
        ShowConfigFont();
 
94
        ShowConfigLineColor();
 
95
}
 
96
 
 
97
Viewer::~Viewer() {
 
98
        delete scaler;
 
99
        if (edit)
 
100
                delete edit;
 
101
        fontList->clear();
 
102
        delete fontList;
 
103
        for (int i=0; i<cmdHistSize; i++)
 
104
                delete cmdHist[i];
 
105
        delete lineWidthDialog;
 
106
        delete lineStyleDialog;
 
107
        delete fontChooserDialog;
 
108
        delete colorChooserDialog;
 
109
        delete textAlignmentDialog;
 
110
}
 
111
 
 
112
void Viewer::Undo() {
 
113
        mainwindow->SetStatus("action: undo");
 
114
        if (!(pasting || zigZag))
 
115
                UndoCommand();
 
116
}
 
117
 
 
118
void Viewer::Redo() {
 
119
        mainwindow->SetStatus("action: redo");
 
120
        if (!(pasting || zigZag))
 
121
                RedoCommand();
 
122
}
 
123
 
 
124
Command *Viewer::GetLastCmd() {
 
125
        if (lastCmdIllegal || lastCmd < 0 || lastCmd >= cmdHistSize)
 
126
                return 0;
 
127
        else
 
128
                return cmdHist[lastCmd];
 
129
        
 
130
}
 
131
 
 
132
void Viewer::Refresh() {
 
133
        // can take a while ...
 
134
        mainwindow->SetCursor(MouseCursor::WATCH);
 
135
        TextModeOff();
 
136
        ClearGrafport();
 
137
        // draw itself.
 
138
        Redraw();
 
139
        mainwindow->SetCursor(MouseCursor::LEFT_PTR);
 
140
}
 
141
 
 
142
void Viewer::Redraw() {
 
143
        Draw();
 
144
        if (printer)
 
145
                printer->Draw();
 
146
}
 
147
 
 
148
FileSelectionDialog *Viewer::GetPrintFileSelectionDialog() {
 
149
        return printer->GetFileSelectionDialog();
 
150
}
 
151
 
 
152
void Viewer::ClearGrafport() {
 
153
        grafport->ClearArea(0,0,grafport->GetWidth(),grafport->GetHeight());
 
154
}
 
155
 
 
156
XFont *Viewer::GetFont(int family, int style, int size) {
 
157
        // look for font in font list.
 
158
        for (fontList->first(); !fontList->done(); fontList->next()) {
 
159
                XFont *ft = fontList->cur();
 
160
                if (ft->GetFamily() == family && ft->GetStyle() == style &&
 
161
                    ft->GetSize() == size) {
 
162
                        return ft;
 
163
                }
 
164
        }
 
165
        // if not found, load new font and add to font list.
 
166
        XFont *newFont = new XFont(config->GetFontFoundry(), 
 
167
                family, style, size, config->GetScalableFonts());
 
168
        fontList->add(newFont);
 
169
        return newFont;
 
170
}
 
171
 
 
172
XFont *Viewer::GetFont(const char *description) {
 
173
        int family = XFont::FindFamily(description);
 
174
        int style = XFont::FindStyle(description);
 
175
        int size = XFont::FindSize(description);
 
176
        return GetFont(family, style, size);
 
177
}
 
178
 
 
179
void Viewer::SetDefaultFontAttributes(int f, int s, int p) { 
 
180
        if (defaultFont->GetFamily()==f && 
 
181
            defaultFont->GetStyle()==s &&
 
182
            defaultFont->GetSize()==p)
 
183
                return;
 
184
        SetDefaultFont(GetFont(f, s, p));
 
185
        printer->SetDefaultFont(f, s, p);
 
186
}
 
187
 
 
188
void Viewer::DoubleClick() {
 
189
        error("Double click is not implemented\n");
 
190
}
 
191
 
 
192
void Viewer::DoFunctionKey(int i) {
 
193
        error("Function key %d, (not implemented)\n", i); 
 
194
}
 
195
 
 
196
void Viewer::DeleteCommands() {
 
197
        lastCmd = -1;
 
198
        lastCmdIllegal = True;
 
199
        for (int i=0; i<cmdHistSize; i++)
 
200
                delete cmdHist[i];
 
201
        cmdHistSize = 0;
 
202
        mainwindow->SetUndoName("Undo");
 
203
        mainwindow->EnableUndo(False);
 
204
        mainwindow->SetRedoName("Redo");
 
205
        mainwindow->EnableRedo(False);
 
206
        TextModeOff();
 
207
}
 
208
 
 
209
void Viewer::NewCommand(Command *newcmd) {
 
210
        TextModeOff();
 
211
        if (!newcmd) {
 
212
                lastCmdIllegal = True;
 
213
                return;
 
214
        }
 
215
        lastCmdIllegal = False;
 
216
        // make space.
 
217
        if (lastCmd >= cmdHistSize-1 && cmdHistSize >= MAXHISTSIZE) {
 
218
                Command *delCmd = cmdHist[0];
 
219
                delete delCmd;
 
220
                for (int i=1; i<cmdHistSize; i++)
 
221
                        cmdHist[i-1] = cmdHist[i];
 
222
                cmdHistSize--;
 
223
                lastCmd = cmdHistSize-1;
 
224
        }
 
225
        for (int i=lastCmd+1; i<cmdHistSize; i++)
 
226
                delete cmdHist[i];
 
227
        lastCmd++;
 
228
        cmdHistSize = lastCmd+1;
 
229
        cmdHist[lastCmd] = newcmd;
 
230
        string s = "Undo (";
 
231
        s += newcmd->GetName();
 
232
        s += ")";
 
233
        mainwindow->SetUndoName(s.getstr());
 
234
        mainwindow->EnableUndo(True);
 
235
        mainwindow->SetRedoName("Redo");
 
236
        mainwindow->EnableRedo(False);
 
237
}
 
238
 
 
239
void Viewer::AbortCommand() {
 
240
        if (!lastCmdIllegal && lastCmd >= 0 && check(lastCmd==cmdHistSize-1)) {
 
241
                delete cmdHist[lastCmd];
 
242
                lastCmd--;
 
243
                cmdHistSize--;
 
244
                if (lastCmd >= 0) {
 
245
                        string s = "Undo (";
 
246
                        s += cmdHist[lastCmd]->GetName();
 
247
                        s += ")";
 
248
                        mainwindow->SetUndoName(s.getstr());
 
249
                        mainwindow->EnableUndo(True);
 
250
                }
 
251
                else {
 
252
                        lastCmdIllegal = True;
 
253
                        mainwindow->SetUndoName("Undo");
 
254
                        mainwindow->EnableUndo(False);
 
255
                }
 
256
                mainwindow->SetRedoName("Redo");
 
257
                mainwindow->EnableRedo(False);
 
258
        }
 
259
}
 
260
 
 
261
void Viewer::ExecuteCommand() {
 
262
        if (lastCmdIllegal)
 
263
                return;
 
264
        TextModeOff();
 
265
        if (lastCmd >= 0 && check(lastCmd < cmdHistSize))
 
266
                cmdHist[lastCmd]->Execute();
 
267
}
 
268
 
 
269
void Viewer::UndoCommand() {
 
270
        if (lastCmdIllegal)
 
271
                return;
 
272
        if (edit && editing && inlineEditor) {
 
273
                edit->Abort();
 
274
                editing = False;
 
275
        }
 
276
        TextModeOff();
 
277
        Command *cmd = cmdHist[lastCmd];
 
278
        if (cmd) {
 
279
                string s;
 
280
                if (cmd->CmdDone()) {
 
281
                        cmd->UnExecute();
 
282
                        s = "Redo (";
 
283
                        s += cmd->GetName();
 
284
                        s += ")";
 
285
                        mainwindow->SetRedoName(s.getstr());
 
286
                        mainwindow->EnableRedo(True);
 
287
                }
 
288
                lastCmd--;
 
289
                if (lastCmd >= 0) {
 
290
                        s = "Undo (";
 
291
                        s += cmdHist[lastCmd]->GetName();
 
292
                        s += ")";
 
293
                        mainwindow->SetUndoName(s.getstr());
 
294
                        mainwindow->EnableUndo(True);
 
295
                        return;
 
296
                }
 
297
        }
 
298
        else
 
299
                mainwindow->SetStatus("there's nothing to undo");
 
300
        mainwindow->SetUndoName("Undo");
 
301
        mainwindow->EnableUndo(False);
 
302
}
 
303
 
 
304
void Viewer::RedoCommand() {
 
305
        if (lastCmdIllegal)
 
306
                return;
 
307
        TextModeOff();
 
308
        if (edit && editing && inlineEditor) {
 
309
                edit->Abort();
 
310
                editing = False;
 
311
        }
 
312
        if (lastCmd < -1 || lastCmd > cmdHistSize-1)
 
313
                return;
 
314
        lastCmd++;
 
315
        Command *cmd = cmdHist[lastCmd];
 
316
        if (cmd) {
 
317
                string s;
 
318
                if (!cmd->CmdDone()) {
 
319
                        cmd->ReExecute();
 
320
                        s = "Undo (";
 
321
                        s += cmd->GetName();
 
322
                        s += ")";
 
323
                        mainwindow->SetUndoName(s.getstr());
 
324
                        mainwindow->EnableUndo(True);
 
325
                }
 
326
                if (lastCmd >= 0 && lastCmd < cmdHistSize-1) {
 
327
                        s = "Redo (";
 
328
                        s += cmdHist[lastCmd+1]->GetName();
 
329
                        s += ")";
 
330
                        mainwindow->SetRedoName(s.getstr());
 
331
                        mainwindow->EnableRedo(True);
 
332
                        return;
 
333
                }
 
334
        }
 
335
        else
 
336
                mainwindow->SetStatus("there's nothing to redo");
 
337
        mainwindow->SetRedoName("Redo");
 
338
        mainwindow->EnableRedo(False);
 
339
}
 
340
 
 
341
void Viewer::EditText(int key) {
 
342
        if (!check(edit))
 
343
                return;
 
344
        if (key == Key::BACKSPACE) {
 
345
                edit->BackSpace();
 
346
                mainwindow->SetStatus("delete previous char");
 
347
        }
 
348
        else if (key == Key::DELETE) {
 
349
                edit->Delete();
 
350
                mainwindow->SetStatus("delete next char");
 
351
        }
 
352
        else if (key == Key::VERTICAL_TAB || key == Key::ESCAPE) {
 
353
                edit->Clear();
 
354
                mainwindow->SetStatus("delete all chars");
 
355
        }
 
356
        else if (key == Key::HOME || key == Key::RS) {
 
357
                edit->Home();
 
358
                mainwindow->SetStatus("move cursor to first char");
 
359
        }
 
360
        else if (key == Key::END || key == Key::FS) {
 
361
                edit->End();
 
362
                mainwindow->SetStatus("move cursor to last char");
 
363
        }
 
364
        else if (key == Key::LEFT) {
 
365
                edit->CharLeft();
 
366
                mainwindow->SetStatus("move cursor 1 char left");
 
367
        }
 
368
        else if (key == Key::DOWN) {
 
369
                edit->CharDown();
 
370
                mainwindow->SetStatus("move cursor 1 line down");
 
371
        }
 
372
        else if (key == Key::UP) {
 
373
                edit->CharUp();
 
374
                mainwindow->SetStatus("move cursor 1 line up");
 
375
        }
 
376
        else if (key == Key::RIGHT) {
 
377
                edit->CharRight();
 
378
                mainwindow->SetStatus("move cursor 1 char right");
 
379
        }
 
380
        else {
 
381
                unsigned char c = (unsigned char)key;
 
382
                if (key == '\r')
 
383
                        key = '\n';
 
384
                if (!iscntrl(c) || key == '\n')
 
385
                        edit->AddChar(key);
 
386
                else
 
387
                        mainwindow->SetStatus("ignoring char");
 
388
        }
 
389
}
 
390
 
 
391
void Viewer::GetPageSize(double &w, double &h) {
 
392
        if (printer)
 
393
                printer->GetPageSize(w, h);
 
394
}
 
395
 
 
396
void Viewer::SetAutoResize(bool s) {
 
397
        string buf = "Autoresize is ";
 
398
        if (s)
 
399
                buf += "True";
 
400
        else
 
401
                buf += "False";
 
402
        mainwindow->SetStatus(&buf);
 
403
        autoResizing = s;
 
404
}
 
405
 
 
406
void Viewer::SetInlineEdit(bool s) {
 
407
        string buf = "In-line edit is ";
 
408
        if (s)
 
409
                buf += "True";
 
410
        else
 
411
                buf += "False";
 
412
        mainwindow->SetStatus(&buf);
 
413
        TextModeOff();
 
414
        inlineEditor = s;
 
415
}
 
416
 
 
417
void Viewer::DefaultLineWidth() {
 
418
        mainwindow->SetStatus("action: default line width");
 
419
        lineWidthDialog->SetTitle("default line width");
 
420
        lineWidthDialog->SetHelpCallback(
 
421
                EditStubs::DefaultLineWidthDefaultCB, this);
 
422
        lineWidthDialog->SetOKCallback(
 
423
                EditStubs::DefaultLineWidthOKCB, this);
 
424
        ShowDefaultLineWidth();
 
425
        lineWidthDialog->Popup();
 
426
}
 
427
 
 
428
void Viewer::UpdateLineWidth() {
 
429
        mainwindow->SetStatus("action: update line width");
 
430
        lineWidthDialog->SetTitle("update line width");
 
431
        lineWidthDialog->SetHelpCallback(
 
432
                EditStubs::UpdateLineWidthDefaultCB, this);
 
433
        lineWidthDialog->SetOKCallback(
 
434
                EditStubs::UpdateLineWidthOKCB, this);
 
435
        lineWidthDialog->Popup();
 
436
}
 
437
 
 
438
void Viewer::SetDefaultLineWidth(unsigned d) {
 
439
        defaultLineWidth=max(MIN_LINE_WIDTH, min(d, MAX_LINE_WIDTH));
 
440
        // otherwise some problems with pixel droppings.
 
441
        Refresh();
 
442
}
 
443
 
 
444
void Viewer::DefaultLineColor() {
 
445
        mainwindow->SetStatus("action: default line color");
 
446
        colorChooserDialog->SetTitle("default line color");
 
447
        colorChooserDialog->SetHelpCallback(
 
448
                EditStubs::DefaultLineColorDefaultCB, this);
 
449
        colorChooserDialog->SetOKCallback(
 
450
                EditStubs::DefaultLineColorOKCB, this);
 
451
        colorChooserDialog->ManageFillToggle(False);
 
452
        ShowDefaultLineColor();
 
453
        colorChooserDialog->Popup();
 
454
}
 
455
 
 
456
void Viewer::UpdateLineColor() {
 
457
        mainwindow->SetStatus("action: update line color");
 
458
        colorChooserDialog->SetTitle("update line color");
 
459
        colorChooserDialog->SetHelpCallback(
 
460
                EditStubs::UpdateLineColorDefaultCB, this);
 
461
        colorChooserDialog->SetOKCallback(
 
462
                EditStubs::UpdateLineColorOKCB, this);
 
463
        colorChooserDialog->ManageFillToggle(False);
 
464
        colorChooserDialog->Popup();
 
465
}
 
466
 
 
467
void Viewer::ShowConfigLineColor() {
 
468
        colorChooserDialog->SetTextString(config->GetLineColor());
 
469
        colorChooserDialog->SelectItem(config->GetLineColor());
 
470
}
 
471
 
 
472
void Viewer::ShowDefaultLineColor() {
 
473
        colorChooserDialog->SetTextString(&defaultLineColor);
 
474
        colorChooserDialog->SelectItem(&defaultLineColor);
 
475
}
 
476
 
 
477
void Viewer::DefaultTextColor() {
 
478
        mainwindow->SetStatus("action: default text color");
 
479
        colorChooserDialog->SetTitle("default text color");
 
480
        colorChooserDialog->SetHelpCallback(
 
481
                EditStubs::DefaultTextColorDefaultCB, this);
 
482
        colorChooserDialog->SetOKCallback(
 
483
                EditStubs::DefaultTextColorOKCB, this);
 
484
        colorChooserDialog->ManageFillToggle(False);
 
485
        ShowDefaultTextColor();
 
486
        colorChooserDialog->Popup();
 
487
}
 
488
 
 
489
void Viewer::UpdateTextColor() {
 
490
        mainwindow->SetStatus("action: update text color");
 
491
        colorChooserDialog->SetTitle("update text color");
 
492
        colorChooserDialog->SetHelpCallback(
 
493
                EditStubs::UpdateTextColorDefaultCB, this);
 
494
        colorChooserDialog->SetOKCallback(
 
495
                EditStubs::UpdateTextColorOKCB, this);
 
496
        colorChooserDialog->ManageFillToggle(False);
 
497
        colorChooserDialog->Popup();
 
498
}
 
499
 
 
500
void Viewer::ShowConfigTextColor() {
 
501
        colorChooserDialog->SetTextString(config->GetTextColor());
 
502
        colorChooserDialog->SelectItem(config->GetTextColor());
 
503
}
 
504
 
 
505
void Viewer::ShowDefaultTextColor() {
 
506
        colorChooserDialog->SetTextString(&defaultTextColor);
 
507
        colorChooserDialog->SelectItem(&defaultTextColor);
 
508
}
 
509
 
 
510
void Viewer::DefaultFillColor() {
 
511
        mainwindow->SetStatus("action: default fill color");
 
512
        colorChooserDialog->SetTitle("default fill color");
 
513
        colorChooserDialog->SetHelpCallback(
 
514
                EditStubs::DefaultFillColorDefaultCB, this);
 
515
        colorChooserDialog->SetOKCallback(
 
516
                EditStubs::DefaultFillColorOKCB, this);
 
517
        colorChooserDialog->SetFillToggle(defaultFillStyle==FillStyle::FILLED);
 
518
        colorChooserDialog->ManageFillToggle(True);
 
519
        colorChooserDialog->SetFillToggleLabel("fill shapes by default");
 
520
        ShowDefaultFillColor();
 
521
        colorChooserDialog->Popup();
 
522
}
 
523
 
 
524
void Viewer::UpdateFillColor() {
 
525
        mainwindow->SetStatus("action: update fill color");
 
526
        colorChooserDialog->SetTitle("update fill color");
 
527
        colorChooserDialog->SetHelpCallback(
 
528
                EditStubs::UpdateFillColorDefaultCB, this);
 
529
        colorChooserDialog->SetOKCallback(
 
530
                EditStubs::UpdateFillColorOKCB, this);
 
531
        colorChooserDialog->ManageFillToggle(True);
 
532
        colorChooserDialog->SetFillToggleLabel("fill selected shapes");
 
533
        colorChooserDialog->Popup();
 
534
}
 
535
 
 
536
void Viewer::ShowConfigFillColor() {
 
537
        colorChooserDialog->SetTextString(config->GetFillColor());
 
538
        colorChooserDialog->SelectItem(config->GetFillColor());
 
539
}
 
540
 
 
541
void Viewer::ShowDefaultFillColor() {
 
542
        colorChooserDialog->SetTextString(&defaultTextColor);
 
543
        colorChooserDialog->SelectItem(&defaultTextColor);
 
544
}
 
545
 
 
546
void Viewer::DefaultLineStyle() {
 
547
        mainwindow->SetStatus("action: default line style");
 
548
        lineStyleDialog->SetTitle("default line style");
 
549
        lineStyleDialog->SetHelpCallback(
 
550
                EditStubs::DefaultLineStyleDefaultCB, this);
 
551
        lineStyleDialog->SetOKCallback(
 
552
                EditStubs::DefaultLineStyleOKCB, this);
 
553
        ShowDefaultLineStyle();
 
554
        lineStyleDialog->Popup();
 
555
}
 
556
 
 
557
void Viewer::UpdateLineStyle() {
 
558
        mainwindow->SetStatus("action: update line style");
 
559
        lineStyleDialog->SetTitle("update line style");
 
560
        lineStyleDialog->SetHelpCallback(
 
561
                EditStubs::UpdateLineStyleDefaultCB, this);
 
562
        lineStyleDialog->SetOKCallback(
 
563
                EditStubs::UpdateLineStyleOKCB, this);
 
564
        lineStyleDialog->Popup();
 
565
}
 
566
 
 
567
void Viewer::ShowDefaultLineWidth() {
 
568
        string text = defaultLineWidth;
 
569
        lineWidthDialog->SetValueOfText(0, &text);
 
570
}
 
571
 
 
572
void Viewer::ShowConfigLineWidth() {
 
573
        string text = config->GetLineWidth();
 
574
        lineWidthDialog->SetValueOfText(0, &text);
 
575
}
 
576
 
 
577
void Viewer::ShowDefaultLineStyle() {
 
578
        string text;
 
579
        LineStyle::Type2String(defaultLineStyle, &text);
 
580
        lineStyleDialog->SetValueOfText(0, &text);
 
581
}
 
582
 
 
583
void Viewer::ShowConfigLineStyle() {
 
584
        string text;
 
585
        LineStyle::Type2String(config->GetLineStyle(), &text);
 
586
        lineStyleDialog->SetValueOfText(0, &text);
 
587
}
 
588
 
 
589
void Viewer::DefaultFont() {
 
590
        mainwindow->SetStatus("action: default font");
 
591
        fontChooserDialog->SetTitle("default text font");
 
592
        fontChooserDialog->SetOKCallback(
 
593
                EditStubs::DefaultFontOKCB, this);
 
594
        fontChooserDialog->SetHelpCallback(
 
595
                EditStubs::DefaultFontDefaultCB, this);
 
596
        fontChooserDialog->SetOptionsVisible(False);
 
597
        ShowDefaultFont();
 
598
        fontChooserDialog->Popup();
 
599
}
 
600
 
 
601
void Viewer::UpdateFont() {
 
602
        mainwindow->SetStatus("action: update font");
 
603
        fontChooserDialog->SetTitle("update text font");
 
604
        fontChooserDialog->SetOKCallback(
 
605
                EditStubs::UpdateFontOKCB, this);
 
606
        fontChooserDialog->SetHelpCallback(
 
607
                EditStubs::UpdateFontDefaultCB, this);
 
608
        fontChooserDialog->SetOptionsVisible(True);
 
609
        fontChooserDialog->ShowExample();
 
610
        fontChooserDialog->Popup();
 
611
}
 
612
 
 
613
void Viewer::ShowDefaultFont() {
 
614
        mainwindow->SetStatus("show default font");
 
615
        fontChooserDialog->SetFamily(defaultFont->GetFamily());
 
616
        fontChooserDialog->SetStyle(defaultFont->GetStyle());
 
617
        fontChooserDialog->SetSize(defaultFont->GetSize());
 
618
        fontChooserDialog->ShowExample();
 
619
}
 
620
 
 
621
void Viewer::ShowConfigFont() {
 
622
        mainwindow->SetStatus("show config font");
 
623
        fontChooserDialog->SetFamily(config->GetFontFamily());
 
624
        fontChooserDialog->SetStyle(config->GetFontStyle());
 
625
        fontChooserDialog->SetSize(config->GetPointSize());
 
626
        fontChooserDialog->ShowExample();
 
627
}
 
628
 
 
629
void Viewer::DefaultTextAlignment() {
 
630
        mainwindow->SetStatus("action: default text alignment");
 
631
        textAlignmentDialog->SetTitle("default text alignment");
 
632
        textAlignmentDialog->SetHelpCallback(
 
633
                EditStubs::DefaultTextAlignmentDefaultCB, this);
 
634
        textAlignmentDialog->SetOKCallback(
 
635
                EditStubs::DefaultTextAlignmentOKCB, this);
 
636
        ShowDefaultTextAlignment();
 
637
        textAlignmentDialog->Popup();
 
638
}
 
639
 
 
640
void Viewer::UpdateTextAlignment() {
 
641
        mainwindow->SetStatus("action: update text alignment");
 
642
        textAlignmentDialog->SetTitle("update text alignment");
 
643
        textAlignmentDialog->SetHelpCallback(
 
644
                EditStubs::UpdateTextAlignmentDefaultCB, this);
 
645
        textAlignmentDialog->SetOKCallback(
 
646
                EditStubs::UpdateTextAlignmentOKCB, this);
 
647
        textAlignmentDialog->Popup();
 
648
}
 
649
 
 
650
void Viewer::ShowDefaultTextAlignment() {
 
651
        string text;
 
652
        TextAlign::Type2String(defaultTextAlignment, &text);
 
653
        textAlignmentDialog->SetValueOfText(0, &text);
 
654
}
 
655
 
 
656
void Viewer::ShowConfigTextAlignment() {
 
657
        string text;
 
658
        TextAlign::Type2String(config->GetTextAlignment(), &text);
 
659
        textAlignmentDialog->SetValueOfText(0, &text);
 
660
}
 
661
 
 
662
void Viewer::Save(OutputFile *f) {
 
663
        printer->Save(f);
 
664
        scaler->Save(f);
 
665
}
 
666
 
 
667
bool Viewer::Load(InputFile *f, double format) {
 
668
        return (printer->Load(f, format) &&
 
669
                scaler->Load(f, format));
 
670
}
 
671
 
 
672
bool Viewer::Check(InputFile *f, double format) {
 
673
        return (printer->Check(f, format) &&
 
674
                scaler->Check(f, format));
 
675
}