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
////////////////////////////////////////////////////////////////////////////////
23
#include "tablewindow.h"
24
#include "tablestubs.h"
25
#include "tableviewer.h"
26
#include "texteditdialog.h"
27
#include "togglelistdialog.h"
28
#include "textalignmentdialog.h"
29
#include "linewidthsidedialog.h"
30
#include "linestylesidedialog.h"
31
#include "scaledialog.h"
32
#include "questiondialog.h"
33
#include "fileselectiondialog.h"
37
#include "cellcolumn.h"
38
#include "appendtablecmd.h"
39
#include "addrowscmd.h"
40
#include "addcolumnscmd.h"
41
#include "deleterowscmd.h"
42
#include "deletecolumnscmd.h"
43
#include "deleteallcellscmd.h"
44
#include "purgecellscmd.h"
45
#include "cutcelltextscmd.h"
46
#include "pastecelltextscmd.h"
47
#include "sortrowscmd.h"
48
#include "sortcolumnscmd.h"
49
#include "findnextcellcmd.h"
50
#include "updatecelltextcmd.h"
51
#include "movetablecmd.h"
52
#include "replaceallcelltextscmd.h"
53
#include "replacenextcelltextcmd.h"
54
#include "updaterowalignmentcmd.h"
55
#include "updatecolumnalignmentcmd.h"
56
#include "updatelinestyletablecmd.h"
57
#include "updatelinewidthtablecmd.h"
58
#include "updatecelltextunderlinecmd.h"
59
#include "celltextbuffer.h"
61
const int Table::MIN_ROW_HEIGHT = 10;
62
const int Table::MIN_COLUMN_WIDTH = 10;
63
const int Table::MAX_ROW_HEIGHT = 200;
64
const int Table::MAX_COLUMN_WIDTH = 200;
65
const int Table::MIN_MARGIN_WIDTH = 0;
66
const int Table::MIN_MARGIN_HEIGHT = 0;
67
const int Table::MAX_MARGIN_WIDTH = 30;
68
const int Table::MAX_MARGIN_HEIGHT = 30;
69
const int Table::MIN_NUMBER_OF_ROWS = 1;
70
const int Table::MIN_NUMBER_OF_COLUMNS = 1;
71
const int Table::MAX_NUMBER_OF_ROWS = 30;
72
const int Table::MAX_NUMBER_OF_COLUMNS = 30;
74
const int Table::DEFAULT_ADD_ROWS = 1;
75
const int Table::DEFAULT_ADD_COLUMNS = 1;
77
Table::Table(Config *c, TableWindow *w, TableViewer *v): Document(c, w, v) {
83
string l = "Append table to the: ";
85
s.add(new string("Bottom"));
86
s.add(new string("Right"));
87
GetEltAnnotationDialog()->
88
SetOKCallback(TableStubs::AnnotateCellOKCB, this);
89
GetFileSelectionDialog()->CreateOptionMenu(&l, &s);
90
GetFileSelectionDialog()->SetOptionChangedCallback(
91
TableStubs::AppendToggleCB, this);
93
scaleDialog = new ScaleDialog(w->GetWidget());
94
scaleDialog->Initialize();
95
List<string *> labels;
96
labels.add(new string("this entry sucks"));
97
labels.add(new string("this entry sucks even more"));
98
promptToggleDialog = new ToggleListDialog(w->GetWidget(), True);
99
promptToggleDialog->Initialize();
100
promptToggleDialog->CreateToggles(&labels); // labels are changed later.
102
defaultNumberOfRows = tviewer->GetDefaultNumberOfRows();
103
defaultNumberOfColumns = tviewer->GetDefaultNumberOfColumns();
104
defaultRowHeight = tviewer->GetDefaultRowHeight();
105
defaultColumnWidth = tviewer->GetDefaultColumnWidth();
106
defaultMarginWidth = tviewer->GetMarginWidth();
107
defaultMarginHeight = tviewer->GetMarginHeight();
109
tableLineStyleDialog = new LineStyleSideDialog(w->GetWidget());
110
tableLineStyleDialog->Initialize();
111
tableLineStyleDialog->SetTitle("update line style");
112
tableLineStyleDialog->SetHelpCallback(
113
TableStubs::UpdateTableLineStyleDefaultCB, this);
114
tableLineStyleDialog->SetOKCallback(
115
TableStubs::UpdateTableLineStyleOKCB, this);
117
tableLineWidthDialog = new LineWidthSideDialog(w->GetWidget());
118
tableLineWidthDialog->Initialize();
119
tableLineWidthDialog->SetTitle("update line width");
120
tableLineWidthDialog->SetHelpCallback(
121
TableStubs::UpdateTableLineWidthDefaultCB, this);
122
tableLineWidthDialog->SetOKCallback(
123
TableStubs::UpdateTableLineWidthOKCB, this);
125
columnAlignmentDialog = GetViewer()->GetTextAlignmentDialog();
126
rowAlignmentDialog = new TextAlignmentDialog(w->GetWidget(), False);
127
rowAlignmentDialog->Initialize();
128
ShowConfigLineStyle();
129
ShowConfigLineWidth();
130
ShowConfigColumnAlignment();
131
ShowConfigRowAlignment();
136
delete promptToggleDialog;
137
delete tableLineStyleDialog;
138
delete tableLineWidthDialog;
139
delete rowAlignmentDialog;
143
/* virtual */ void Table::Initialize() {
144
Document::Initialize();
145
tviewer->Initialize();
149
void Table::Append() {
150
GetFileSelectionDialog()->ManageOptionMenu(True);
154
void Table::RemoveAll() {
156
tviewer->DeleteCommands();
159
void Table::LoadEntries() {
161
tviewer->NewCommand(new AppendTableCmd(this, tviewer));
162
tviewer->ExecuteCommand();
165
tviewer->TextModeOff();
166
// delete the document contents.
168
unsigned rows, columns;
169
InputFile *ipf = GetInputFile();
170
if (tviewer->ReadAttributes(ipf, IsAppending(), rows,
171
columns, GetLoadFormat())) {
172
// load: add new rows and columns
173
tviewer->InitTable(rows, columns);
174
tviewer->SetVisible(False);
175
if (GetLoadFormat() >= 1.09) {
176
if (tviewer->ReadRows(ipf, rows, 0, 0, GetLoadFormat()))
177
tviewer->ReadColumns(
178
ipf, columns, 0, 0, GetLoadFormat());
181
if (tviewer->ReadColumns(ipf, columns, 0, 0,
183
tviewer->ReadRows(ipf, rows, 0, 0,
186
tviewer->DeleteCommands();
188
tviewer->SetVisible(True);
193
void Table::FitTable() {
195
tviewer->CalcSizeElements(p1, p2);
196
double wd = tviewer->Scale(p2.x) + 300.0;
197
double ht = tviewer->Scale(p2.y) + 300.0;
198
((DrawWindow *)GetMainWindow())->FitDocument(static_cast<int>(0.5 + wd),
199
static_cast<int>(0.5 + ht));
202
void Table::SaveEntries() {
203
tviewer->TextModeOff();
204
OutputFile *opf = GetOutputFile();
205
if (IsSaveSelection()) {
206
tviewer->WriteSelection(opf);
209
tviewer->WriteAttributes(opf);
210
tviewer->WriteRows(opf);
211
tviewer->WriteColumns(opf);
215
void Table::SetAppendToggle(bool set) {
218
SetStatus("append to the bottom of the table");
220
SetStatus("append to the right of the table");
223
void Table::AddRows() {
224
SetStatus("action: add rows");
225
string d = DEFAULT_ADD_ROWS;
226
string s0("To the bottom of the table");
227
string s1("To the top of the selection");
228
promptToggleDialog->SetToggleText(0, &s0);
229
promptToggleDialog->SetToggleText(1, &s1);
230
promptToggleDialog->SetTitle("Add rows");
231
promptToggleDialog->SetSelectionLabel("Number of rows to add");
232
promptToggleDialog->SetTextString(&d);
233
promptToggleDialog->SetOKCallback(TableStubs::AddRowsOKCB, this);
234
promptToggleDialog->SetToggleChangedCallback(
235
TableStubs::AddRowsToggleCB, this);
236
promptToggleDialog->SetValue(topAdd);
237
promptToggleDialog->Popup();
240
void Table::AddColumns() {
241
SetStatus("action: add columns");
242
string d = DEFAULT_ADD_COLUMNS;
243
string s0("To the right of the table");
244
string s1("To the left of the selection");
245
promptToggleDialog->SetToggleText(0, &s0);
246
promptToggleDialog->SetToggleText(1, &s1);
247
promptToggleDialog->SetTitle("Add columns");
248
promptToggleDialog->SetSelectionLabel("Number of columns to add");
249
promptToggleDialog->SetTextString(&d);
250
promptToggleDialog->SetOKCallback(TableStubs::AddColumnsOKCB, this);
251
promptToggleDialog->SetToggleChangedCallback(
252
TableStubs::AddColumnsToggleCB, this);
253
promptToggleDialog->SetValue(leftAdd);
254
promptToggleDialog->Popup();
257
void Table::SetAddRowsToggle(bool set) {
260
SetStatus("add rows at the top of the selection");
262
SetStatus("add rows at the bottom of the table");
265
void Table::SetAddColumnsToggle(bool set) {
268
SetStatus("add columns at the left of the selection");
270
SetStatus("add columns at the right of the table");
273
void Table::AddRows(unsigned n) {
276
if ((m = tviewer->GetTopSelectionRow()) == -1)
277
m = tviewer->GetNumberOfRows();
280
m = tviewer->GetNumberOfRows();
281
tviewer->NewCommand(new AddRowsCmd(this, tviewer, n, m));
282
tviewer->ExecuteCommand();
285
void Table::AddColumns(unsigned n) {
288
if ((m = tviewer->GetLeftSelectionColumn()) == -1)
289
m = tviewer->GetNumberOfColumns();
292
m = tviewer->GetNumberOfColumns();
293
tviewer->NewCommand(new AddColumnsCmd(this, tviewer, n, m));
294
tviewer->ExecuteCommand();
297
void Table::DeleteRows() {
298
SetStatus("action: delete rows");
299
if (tviewer->NrSelected() > 0) {
300
tviewer->NewCommand(new DeleteRowsCmd(this, tviewer));
301
tviewer->ExecuteCommand();
304
EmptySelectionMessage();
307
void Table::DeleteColumns() {
308
SetStatus("action: delete columns");
309
if (tviewer->NrSelected() > 0) {
310
tviewer->NewCommand(new DeleteColumnsCmd(this, tviewer));
311
tviewer->ExecuteCommand();
314
EmptySelectionMessage();
317
void Table::DeleteAll() {
318
SetStatus("action: delete all");
319
if (tviewer->GetNumberOfRows() > 0) {
320
QuestionDialog q(GetMainWindow()->GetWidget(), False);
322
q.SetTitle("delete all");
324
"Are you sure you want to delete everything?");
325
int answer = q.GetAnswer();
326
if (answer == QuestionDialog::YES)
328
else if (answer == QuestionDialog::NO)
329
SetStatus("aborted: nothing is deleted");
332
SetStatus("aborted: table is empty");
335
void Table::DeleteAllCells() {
336
tviewer->NewCommand(new DeleteAllCellsCmd(this, tviewer));
337
tviewer->ExecuteCommand();
340
void Table::Purge() {
341
SetStatus("action: purge table");
342
if (tviewer->GetNumberOfRows() > 0) {
343
tviewer->NewCommand(new PurgeCellsCmd(this, tviewer));
344
tviewer->ExecuteCommand();
347
SetStatus("aborted: table is empty");
350
void Table::CutTexts() {
351
SetStatus("action: cut texts");
352
if (tviewer->NrSelected() > 0) {
353
tviewer->NewCommand(new CutCellTextsCmd(this, tviewer));
354
tviewer->ExecuteCommand();
357
EmptySelectionMessage();
360
void Table::CopyTexts() {
361
SetStatus("action: copy texts");
362
if (tviewer->NrSelected() > 0) {
363
tviewer->NewCommand(new CopyCellTextsCmd(this, tviewer));
364
tviewer->ExecuteCommand();
367
EmptySelectionMessage();
370
void Table::PasteTexts() {
371
SetStatus("action: paste texts");
372
if (!tviewer->GetBuffer()->IsEmpty())
373
tviewer->NewCommand(new PasteCellTextsCmd(this, tviewer));
375
(new MessageDialog(GetMainWindow()->GetWidget(),
376
MessageDialog::WARNING))->
377
Show("Warning", "There is nothing in the paste buffer");
378
SetStatus("aborted: paste buffer is empty");
382
void Table::SortRows() {
383
SetStatus("action: sort rows");
384
tviewer->NewCommand(new SortRowsCmd(this, tviewer));
385
tviewer->ExecuteCommand();
388
void Table::SortColumns() {
389
SetStatus("action: sort columns");
390
tviewer->NewCommand(new SortColumnsCmd(this, tviewer));
391
tviewer->ExecuteCommand();
394
void Table::FindAll(const string *s, bool sens, bool substr, bool) {
395
tviewer->NewCommand(new FindAllCellsCmd(
396
this, tviewer, s, sens, substr));
397
tviewer->ExecuteCommand();
400
void Table::FindNext(const string *s, bool sens, bool substr, bool) {
401
tviewer->NewCommand(new FindNextCellCmd(
402
this, tviewer, s, sens, substr));
403
tviewer->ExecuteCommand();
406
void Table::ReplaceNext(const string *s1, const string *s2,
407
bool sens, bool substr, bool) {
408
tviewer->NewCommand(new ReplaceNextCellTextCmd(
409
this, tviewer, s1, s2, sens, substr));
410
tviewer->ExecuteCommand();
413
void Table::ReplaceAll(const string *s1, const string *s2,
414
bool sens, bool substr, bool) {
415
tviewer->NewCommand(new ReplaceAllCellTextsCmd(
416
this, tviewer, s1, s2, sens, substr));
417
tviewer->ExecuteCommand();
420
void Table::SameWidth() { }
422
void Table::SameHeight() { }
424
void Table::Span() { }
426
void Table::UnSpan() { }
428
void Table::SelectAll() {
429
SetStatus("action: select all");
430
tviewer->NewCommand(new SelectAllCellsCmd(this, tviewer));
431
tviewer->ExecuteCommand();
434
void Table::Move(Document::MoveType t) {
435
tviewer->NewCommand(new MoveTableCmd(this, tviewer, t));
436
tviewer->ExecuteCommand();
439
void Table::SetDefaultNumberOfRows(unsigned n) {
440
string txt = "def. number of rows is ";
443
tviewer->SetDefaultNumberOfRows(n);
446
void Table::SetDefaultNumberOfColumns(unsigned n) {
447
string txt = "def. number of columns is ";
450
tviewer->SetDefaultNumberOfColumns(n);
453
void Table::SetDefaultRowHeight(int n) {
454
string txt = "default row height is ";
457
tviewer->TextModeOff();
458
tviewer->UpdateDefaultRowHeight(n);
461
void Table::SetDefaultColumnWidth(int n) {
462
string txt = "default column width is ";
465
tviewer->TextModeOff();
466
tviewer->UpdateDefaultColumnWidth(n);
469
void Table::SetMarginWidth(int n) {
470
string txt = "text margin width is ";
473
tviewer->TextModeOff();
474
tviewer->UpdateMarginWidth(n);
477
void Table::SetMarginHeight(int n) {
478
string txt = "text margin height is ";
481
tviewer->TextModeOff();
482
tviewer->UpdateMarginHeight(n);
485
void Table::ShowRowColumnLabels(bool b) {
486
string txt = (b ? "Show":"Don't show");
487
txt += " row and column labels";
489
tviewer->ShowRowColumnLabels(b);
492
void Table::PrintRowColumnLabels(bool b) {
493
string txt = (b ? "Print":"Don't print");
494
txt += " row and column labels";
496
tviewer->PrintRowColumnLabels(b);
499
void Table::SetDefaultNumberOfRows() {
500
SetStatus("action: set number of rows");
501
scaleDialog->SetTitle("Number of rows");
502
scaleDialog->SetScaleLabel("Default number of rows: ");
503
scaleDialog->SetScaleValues(MIN_NUMBER_OF_ROWS, MAX_NUMBER_OF_ROWS,
504
tviewer->GetDefaultNumberOfRows(), 0, defaultNumberOfRows);
505
scaleDialog->SetValueChangedCallback(TableStubs::NumberOfRowsCB, this);
506
scaleDialog->Popup();
509
void Table::SetDefaultNumberOfColumns() {
510
SetStatus("action: set number of columns");
511
scaleDialog->SetTitle("Number of columns");
512
scaleDialog->SetScaleLabel("Default number of columns: ");
513
scaleDialog->SetScaleValues(MIN_NUMBER_OF_COLUMNS,
514
MAX_NUMBER_OF_COLUMNS, tviewer->GetDefaultNumberOfColumns(),
515
0, defaultNumberOfColumns);
516
scaleDialog->SetValueChangedCallback(
517
TableStubs::NumberOfColumnsCB, this);
518
scaleDialog->Popup();
521
void Table::SetDefaultRowHeight() {
522
SetStatus("action: set default row height");
523
scaleDialog->SetTitle("Row Height");
524
scaleDialog->SetScaleLabel("Default row height (in pixels) ");
525
scaleDialog->SetScaleValues(MIN_ROW_HEIGHT, MAX_ROW_HEIGHT,
526
tviewer->GetDefaultRowHeight(), 0, defaultRowHeight);
527
scaleDialog->SetValueChangedCallback(TableStubs::RowHeightCB, this);
528
scaleDialog->Popup();
531
void Table::SetDefaultColumnWidth() {
532
SetStatus("action: set default column width");
533
scaleDialog->SetTitle("Column Width");
534
scaleDialog->SetScaleLabel("Default column width (in pixels) ");
535
scaleDialog->SetScaleValues(MIN_COLUMN_WIDTH,MAX_COLUMN_WIDTH,
536
tviewer->GetDefaultColumnWidth(), 0, defaultColumnWidth);
537
scaleDialog->SetValueChangedCallback(TableStubs::ColumnWidthCB, this);
538
scaleDialog->Popup();
541
void Table::UpdateLineStyle(Side::Type side,
542
LineStyle::Type ltype) {
543
SetStatus("action: update line style");
544
if (tviewer->NrSelected() > 0) {
545
tviewer->NewCommand(new UpdateLineStyleTableCmd(
546
this, tviewer, side, ltype));
547
tviewer->ExecuteCommand();
550
EmptySelectionMessage();
553
void Table::UpdateCellTextUnderline() {
554
SetStatus("action: set/unset cell text underlinings");
555
if (tviewer->NrSelected() > 0) {
556
tviewer->NewCommand(new UpdateCellTextUnderlineCmd(
558
tviewer->ExecuteCommand();
561
EmptySelectionMessage();
564
void Table::UpdateLineWidth(Side::Type side, unsigned width) {
565
SetStatus("action: update line width");
566
if (tviewer->NrSelected() > 0) {
567
tviewer->NewCommand(new UpdateLineWidthTableCmd(
568
this, tviewer, side, width));
569
tviewer->ExecuteCommand();
572
EmptySelectionMessage();
575
void Table::UpdateColumnAlignment(TextAlign::Type a) {
576
SetStatus("action: update column alignment");
577
if (tviewer->NrSelected() > 0) {
578
tviewer->NewCommand(new
579
UpdateColumnAlignmentCmd(this, tviewer, a));
580
tviewer->ExecuteCommand();
583
EmptySelectionMessage();
586
void Table::UpdateRowAlignment(TextAlign::Type a) {
587
SetStatus("action: update row alignment");
588
if (tviewer->NrSelected() > 0) {
589
tviewer->NewCommand(new
590
UpdateRowAlignmentCmd(this, tviewer, a));
591
tviewer->ExecuteCommand();
594
EmptySelectionMessage();
597
void Table::UpdateMarginWidth() {
598
SetStatus("action: set margin width");
599
scaleDialog->SetTitle("Text margin width");
600
scaleDialog->SetScaleLabel("New text margin width (in pixels) ");
601
scaleDialog->SetScaleValues(MIN_MARGIN_WIDTH, MAX_MARGIN_WIDTH,
602
tviewer->GetMarginWidth(), 0, defaultMarginWidth);
603
scaleDialog->SetValueChangedCallback(TableStubs::MarginWidthCB, this);
604
scaleDialog->Popup();
607
void Table::UpdateMarginHeight() {
608
SetStatus("action: set margin height");
609
scaleDialog->SetTitle("Text margin height");
610
scaleDialog->SetScaleLabel("New text margin height (in pixels) ");
611
scaleDialog->SetScaleValues(MIN_MARGIN_HEIGHT, MAX_MARGIN_HEIGHT,
612
tviewer->GetMarginHeight(), 0, defaultMarginHeight);
613
scaleDialog->SetValueChangedCallback(TableStubs::MarginHeightCB, this);
614
scaleDialog->Popup();
617
void Table::UpdateDefaultColumnAlignment(TextAlign::Type newType) {
618
SetStatus("action: default column alignment");
619
tviewer->SetDefaultColumnAlignment(newType);
620
List<CellColumn *> columns;
621
tviewer->GetEmptyColumns(&columns);
622
for (columns.first(); !columns.done(); columns.next())
623
columns.cur()->UpdateAlignment(newType);
626
void Table::UpdateDefaultRowAlignment(TextAlign::Type newType) {
627
SetStatus("action: default row alignment");
628
tviewer->SetDefaultRowAlignment(newType);
629
List<CellRow *> rows;
630
tviewer->GetEmptyRows(&rows);
631
for (rows.first(); !rows.done(); rows.next())
632
rows.cur()->UpdateAlignment(newType);
635
bool Table::UpdateText(Cell *c, const string *t) {
642
void Table::AnnotateCell() {
643
SetStatus("action: annotate cell");
644
if (tviewer->NrSelected() == 1) {
645
Cell *cell = (*tviewer->GetSelection())[0];
648
else if (tviewer->NrSelected() == 0)
649
EmptySelectionMessage();
651
(new MessageDialog(GetMainWindow()->GetWidget(),
652
MessageDialog::WARNING))->
653
Show("Warning", "Select only one single cell to annotate");
654
SetStatus("aborted: selection too large");
658
void Table::AnnotateCell(Cell *cell) {
659
if (GetEltAnnotationDialog()->IsManaged()) {
660
ShowDialog(MessageDialog::WARNING, "Warning",
661
"At most one cell annotation dialog "
662
"can be opened at a time");
665
string n = cell->GetRow()->GetNumber();
667
n += cell->GetColumn()->GetNumber();
668
const string *annot = cell->GetAnnotation();
669
annotationCell = cell;
670
string title = "Annotation of cell " + n;
671
GetEltAnnotationDialog()->SetTitle(&title);
672
GetEltAnnotationDialog()->SetTextString(annot);
673
GetEltAnnotationDialog()->Popup();
674
GetEltAnnotationDialog()->SetStatus(&title);
677
void Table::SetCellAnnotation(const string *s) {
678
SetStatus("action: update cell annotation");
679
if (!check(annotationCell))
681
// make here an undoable command!
682
annotationCell->SetAnnotation(s);
685
void Table::EmptySelectionMessage() {
686
(new MessageDialog(GetMainWindow()->GetWidget(),
687
MessageDialog::WARNING))->
688
Show("Warning", "No cells are selected");
689
SetStatus("aborted: selection is empty");
692
void Table::EmptyTableMessage() {
693
(new MessageDialog(GetMainWindow()->GetWidget(),
694
MessageDialog::WARNING))->Show("Warning", "Table is empty");
695
SetStatus("aborted: there are no cells");
698
void Table::DefaultRowAlignment() {
699
SetStatus("action: default row alignment");
700
rowAlignmentDialog->SetTitle("default row alignment");
701
rowAlignmentDialog->SetHelpCallback(
702
TableStubs::DefaultRowAlignmentDefaultCB, this);
703
rowAlignmentDialog->SetOKCallback(
704
TableStubs::DefaultRowAlignmentOKCB, this);
705
ShowDefaultRowAlignment();
706
rowAlignmentDialog->Popup();
709
void Table::DefaultColumnAlignment() {
710
SetStatus("action: default column alignment");
711
columnAlignmentDialog->SetTitle("default column alignment");
712
columnAlignmentDialog->SetHelpCallback(
713
TableStubs::DefaultColumnAlignmentDefaultCB, this);
714
columnAlignmentDialog->SetOKCallback(
715
TableStubs::DefaultColumnAlignmentOKCB, this);
716
ShowDefaultColumnAlignment();
717
columnAlignmentDialog->Popup();
720
void Table::UpdateRowAlignment() {
721
SetStatus("action: update row alignment");
722
rowAlignmentDialog->SetTitle("update row alignment");
723
rowAlignmentDialog->SetHelpCallback(
724
TableStubs::UpdateRowAlignmentDefaultCB, this);
725
rowAlignmentDialog->SetOKCallback(
726
TableStubs::UpdateRowAlignmentOKCB, this);
727
rowAlignmentDialog->Popup();
730
void Table::UpdateColumnAlignment() {
731
SetStatus("action: update column alignment");
732
columnAlignmentDialog->SetTitle("update column alignment");
733
columnAlignmentDialog->SetHelpCallback(
734
TableStubs::UpdateColumnAlignmentDefaultCB, this);
735
columnAlignmentDialog->SetOKCallback(
736
TableStubs::UpdateColumnAlignmentOKCB, this);
737
columnAlignmentDialog->Popup();
740
void Table::UpdateTableLineStyle() {
741
SetStatus("action: update line style");
742
tableLineStyleDialog->Popup();
745
void Table::UpdateTableLineWidth() {
746
SetStatus("action: update line width");
747
tableLineWidthDialog->Popup();
750
void Table::ShowDefaultLineStyle() {
751
SetStatus("reset to default line style");
753
LineStyle::Type2String(GetViewer()->GetDefaultLineStyle(), &text);
754
tableLineStyleDialog->SetValueOfText(0, &text);
755
tableLineStyleDialog->SetValue(1, 0);
758
void Table::ShowConfigLineStyle() {
759
SetStatus("reset to config line style");
761
LineStyle::Type2String(GetConfig()->GetLineStyle(), &text);
762
tableLineStyleDialog->SetValueOfText(0, &text);
763
tableLineStyleDialog->SetValue(1, 0);
766
void Table::ShowDefaultLineWidth() {
767
SetStatus("reset to default line width");
768
string text = GetViewer()->GetDefaultLineWidth();
769
tableLineWidthDialog->SetValueOfText(0, &text);
770
tableLineWidthDialog->SetValue(1, 0);
773
void Table::ShowConfigLineWidth() {
774
SetStatus("reset to config line width");
775
int wd = max(Viewer::MIN_LINE_WIDTH,
776
min(GetConfig()->GetLineWidth(), Viewer::MAX_LINE_WIDTH));
778
tableLineWidthDialog->SetValueOfText(0, &text);
779
tableLineWidthDialog->SetValue(1, 0);
782
void Table::ShowDefaultColumnAlignment() {
783
SetStatus("reset to default column alignment");
785
TextAlign::Type2String(tviewer->GetDefaultColumnAlignment(), &text);
786
columnAlignmentDialog->SetValueOfText(0, &text);
789
void Table::ShowConfigColumnAlignment() {
790
SetStatus("reset to config column alignment");
792
TextAlign::Type2String(GetConfig()->GetColumnAlignment(), &text);
793
columnAlignmentDialog->SetValueOfText(0, &text);
796
void Table::ShowDefaultRowAlignment() {
797
SetStatus("reset to default row alignment");
799
TextAlign::Type2String(tviewer->GetDefaultRowAlignment(), &text);
801
rowAlignmentDialog->SetValue(0, 0);
802
else if (text %= "Right")
803
rowAlignmentDialog->SetValue(0, 2);
805
rowAlignmentDialog->SetValue(0, 1);
808
void Table::ShowConfigRowAlignment() {
809
SetStatus("reset to config row alignment");
811
TextAlign::Type2String(GetConfig()->GetRowAlignment(), &text);
813
rowAlignmentDialog->SetValue(0, 0);
814
else if (text %= "Right")
815
rowAlignmentDialog->SetValue(0, 2);
817
rowAlignmentDialog->SetValue(0, 1);