3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Jürgen Spitzmüller
10 * Full author contact details are available in file CREDITS.
15 #include "GuiTabular.h"
17 #include "ControlTabular.h"
18 #include "GuiSetBorder.h"
19 #include "LengthCombo.h"
20 #include "Validator.h"
21 #include "qt_helpers.h"
23 #include <QCloseEvent>
25 #include <QPushButton>
26 #include <QRadioButton>
35 GuiTabularDialog::GuiTabularDialog(LyXView & lv)
36 : GuiDialog(lv, "tabular")
39 setViewTitle(_("Table Settings"));
40 setController(new ControlTabular(*this));
42 widthED->setValidator(unsignedLengthValidator(widthED));
43 topspaceED->setValidator(new LengthValidator(topspaceED));
44 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
45 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
47 connect(topspaceED, SIGNAL(returnPressed()),
48 this, SLOT(topspace_changed()));
49 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
50 this, SLOT(topspace_changed()));
51 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
52 connect(bottomspaceED, SIGNAL(returnPressed()),
53 this, SLOT(bottomspace_changed()));
54 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
55 this, SLOT(bottomspace_changed()));
56 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
57 connect(interlinespaceED, SIGNAL(returnPressed()),
58 this, SLOT(interlinespace_changed()));
59 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
60 this, SLOT(interlinespace_changed()));
61 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
62 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
63 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
64 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
65 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
66 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
67 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
68 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
69 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
70 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
71 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
72 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
73 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
74 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
75 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
76 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
77 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
78 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
79 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
80 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
81 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
82 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
83 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
84 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
85 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
86 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
87 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
88 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
89 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
90 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
91 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
92 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
93 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
94 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
95 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
96 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
98 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
99 bc().setCancel(closePB);
101 bc().addReadOnly(topspaceED);
102 bc().addReadOnly(topspaceUnit);
103 bc().addReadOnly(topspaceCO);
104 bc().addReadOnly(bottomspaceED);
105 bc().addReadOnly(bottomspaceUnit);
106 bc().addReadOnly(bottomspaceCO);
107 bc().addReadOnly(interlinespaceED);
108 bc().addReadOnly(interlinespaceUnit);
109 bc().addReadOnly(interlinespaceCO);
110 bc().addReadOnly(borderDefaultRB);
111 bc().addReadOnly(booktabsRB);
113 bc().addReadOnly(multicolumnCB);
114 bc().addReadOnly(rotateCellCB);
115 bc().addReadOnly(rotateTabularCB);
116 bc().addReadOnly(specialAlignmentED);
117 bc().addReadOnly(widthED);
118 bc().addReadOnly(widthUnit);
119 bc().addReadOnly(hAlignCB);
120 bc().addReadOnly(vAlignCB);
121 bc().addReadOnly(borderSetPB);
122 bc().addReadOnly(borderUnsetPB);
123 bc().addReadOnly(borders);
124 bc().addReadOnly(longTabularCB);
125 bc().addReadOnly(headerStatusCB);
126 bc().addReadOnly(headerBorderAboveCB);
127 bc().addReadOnly(headerBorderBelowCB);
128 bc().addReadOnly(firstheaderStatusCB);
129 bc().addReadOnly(firstheaderBorderAboveCB);
130 bc().addReadOnly(firstheaderBorderBelowCB);
131 bc().addReadOnly(firstheaderNoContentsCB);
132 bc().addReadOnly(footerStatusCB);
133 bc().addReadOnly(footerBorderAboveCB);
134 bc().addReadOnly(footerBorderBelowCB);
135 bc().addReadOnly(lastfooterStatusCB);
136 bc().addReadOnly(lastfooterBorderAboveCB);
137 bc().addReadOnly(lastfooterBorderBelowCB);
138 bc().addReadOnly(lastfooterNoContentsCB);
139 bc().addReadOnly(newpageCB);
141 // initialize the length validator
142 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
143 bc().addCheckedLineEdit(topspaceED, topspaceLA);
144 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
145 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
149 ControlTabular & GuiTabularDialog::controller()
151 return static_cast<ControlTabular &>(GuiDialog::controller());
155 void GuiTabularDialog::change_adaptor()
161 void GuiTabularDialog::closeEvent(QCloseEvent * e)
164 GuiDialog::closeEvent(e);
168 void GuiTabularDialog::booktabsChanged(bool)
171 controller().booktabs(booktabsRB->isChecked());
176 void GuiTabularDialog::topspace_changed()
178 switch(topspaceCO->currentIndex()) {
180 controller().set(Tabular::SET_TOP_SPACE, "");
181 topspaceED->setEnabled(false);
182 topspaceUnit->setEnabled(false);
186 controller().set(Tabular::SET_TOP_SPACE, "default");
187 topspaceED->setEnabled(false);
188 topspaceUnit->setEnabled(false);
192 if (!topspaceED->text().isEmpty())
193 controller().set(Tabular::SET_TOP_SPACE,
194 widgetsToLength(topspaceED, topspaceUnit));
195 if (!bc().policy().isReadOnly()) {
196 topspaceED->setEnabled(true);
197 topspaceUnit->setEnabled(true);
206 void GuiTabularDialog::bottomspace_changed()
208 switch(bottomspaceCO->currentIndex()) {
210 controller().set(Tabular::SET_BOTTOM_SPACE, "");
211 bottomspaceED->setEnabled(false);
212 bottomspaceUnit->setEnabled(false);
216 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
217 bottomspaceED->setEnabled(false);
218 bottomspaceUnit->setEnabled(false);
222 if (!bottomspaceED->text().isEmpty())
223 controller().set(Tabular::SET_BOTTOM_SPACE,
224 widgetsToLength(bottomspaceED, bottomspaceUnit));
225 if (!bc().policy().isReadOnly()) {
226 bottomspaceED->setEnabled(true);
227 bottomspaceUnit->setEnabled(true);
236 void GuiTabularDialog::interlinespace_changed()
238 switch(interlinespaceCO->currentIndex()) {
240 controller().set(Tabular::SET_INTERLINE_SPACE, "");
241 interlinespaceED->setEnabled(false);
242 interlinespaceUnit->setEnabled(false);
246 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
247 interlinespaceED->setEnabled(false);
248 interlinespaceUnit->setEnabled(false);
252 if (!interlinespaceED->text().isEmpty())
253 controller().set(Tabular::SET_INTERLINE_SPACE,
254 widgetsToLength(interlinespaceED, interlinespaceUnit));
255 if (!bc().policy().isReadOnly()) {
256 interlinespaceED->setEnabled(true);
257 interlinespaceUnit->setEnabled(true);
266 void GuiTabularDialog::close_clicked()
273 void GuiTabularDialog::borderSet_clicked()
275 controller().set(Tabular::SET_ALL_LINES);
281 void GuiTabularDialog::borderUnset_clicked()
283 controller().set(Tabular::UNSET_ALL_LINES);
289 void GuiTabularDialog::leftBorder_changed()
291 controller().toggleLeftLine();
296 void GuiTabularDialog::rightBorder_changed()
298 controller().toggleRightLine();
303 void GuiTabularDialog::topBorder_changed()
305 controller().toggleTopLine();
310 void GuiTabularDialog::bottomBorder_changed()
312 controller().toggleBottomLine();
317 void GuiTabularDialog::specialAlignment_changed()
319 string special = fromqstr(specialAlignmentED->text());
320 controller().setSpecial(special);
325 void GuiTabularDialog::width_changed()
328 string const width = widgetsToLength(widthED, widthUnit);
329 controller().setWidth(width);
333 void GuiTabularDialog::multicolumn_clicked()
335 controller().toggleMultiColumn();
340 void GuiTabularDialog::rotateTabular()
342 controller().rotateTabular(rotateTabularCB->isChecked());
347 void GuiTabularDialog::rotateCell()
349 controller().rotateCell(rotateCellCB->isChecked());
354 void GuiTabularDialog::hAlign_changed(int align)
356 ControlTabular::HALIGN h = ControlTabular::LEFT;
359 case 0: h = ControlTabular::LEFT; break;
360 case 1: h = ControlTabular::CENTER; break;
361 case 2: h = ControlTabular::RIGHT; break;
362 case 3: h = ControlTabular::BLOCK; break;
365 controller().halign(h);
369 void GuiTabularDialog::vAlign_changed(int align)
371 ControlTabular::VALIGN v = ControlTabular::TOP;
374 case 0: v = ControlTabular::TOP; break;
375 case 1: v = ControlTabular::MIDDLE; break;
376 case 2: v = ControlTabular::BOTTOM; break;
379 controller().valign(v);
383 void GuiTabularDialog::longTabular()
385 controller().longTabular(longTabularCB->isChecked());
390 void GuiTabularDialog::ltNewpage_clicked()
392 controller().set(Tabular::SET_LTNEWPAGE);
397 void GuiTabularDialog::ltHeaderStatus_clicked()
399 bool enable(headerStatusCB->isChecked());
401 controller().set(Tabular::SET_LTHEAD, "");
403 controller().set(Tabular::UNSET_LTHEAD, "");
404 headerBorderAboveCB->setEnabled(enable);
405 headerBorderBelowCB->setEnabled(enable);
406 firstheaderNoContentsCB->setEnabled(enable);
411 void GuiTabularDialog::ltHeaderBorderAbove_clicked()
413 if (headerBorderAboveCB->isChecked())
414 controller().set(Tabular::SET_LTHEAD, "dl_above");
416 controller().set(Tabular::UNSET_LTHEAD, "dl_above");
421 void GuiTabularDialog::ltHeaderBorderBelow_clicked()
423 if (headerBorderBelowCB->isChecked())
424 controller().set(Tabular::SET_LTHEAD, "dl_below");
426 controller().set(Tabular::UNSET_LTHEAD, "dl_below");
431 void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
433 if (firstheaderBorderAboveCB->isChecked())
434 controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
436 controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
441 void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
443 if (firstheaderBorderBelowCB->isChecked())
444 controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
446 controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
451 void GuiTabularDialog::ltFirstHeaderStatus_clicked()
453 bool enable(firstheaderStatusCB->isChecked());
455 controller().set(Tabular::SET_LTFIRSTHEAD, "");
457 controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
458 firstheaderBorderAboveCB->setEnabled(enable);
459 firstheaderBorderBelowCB->setEnabled(enable);
464 void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
466 bool enable(firstheaderNoContentsCB->isChecked());
468 controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
470 controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
471 firstheaderStatusCB->setEnabled(!enable);
472 firstheaderBorderAboveCB->setEnabled(!enable);
473 firstheaderBorderBelowCB->setEnabled(!enable);
478 void GuiTabularDialog::ltFooterStatus_clicked()
480 bool enable(footerStatusCB->isChecked());
482 controller().set(Tabular::SET_LTFOOT, "");
484 controller().set(Tabular::UNSET_LTFOOT, "");
485 footerBorderAboveCB->setEnabled(enable);
486 footerBorderBelowCB->setEnabled(enable);
487 lastfooterNoContentsCB->setEnabled(enable);
492 void GuiTabularDialog::ltFooterBorderAbove_clicked()
494 if (footerBorderAboveCB->isChecked())
495 controller().set(Tabular::SET_LTFOOT, "dl_above");
497 controller().set(Tabular::UNSET_LTFOOT, "dl_above");
502 void GuiTabularDialog::ltFooterBorderBelow_clicked()
504 if (footerBorderBelowCB->isChecked())
505 controller().set(Tabular::SET_LTFOOT, "dl_below");
507 controller().set(Tabular::UNSET_LTFOOT, "dl_below");
512 void GuiTabularDialog::ltLastFooterStatus_clicked()
514 bool enable(lastfooterStatusCB->isChecked());
516 controller().set(Tabular::SET_LTLASTFOOT, "");
518 controller().set(Tabular::UNSET_LTLASTFOOT, "");
519 lastfooterBorderAboveCB->setEnabled(enable);
520 lastfooterBorderBelowCB->setEnabled(enable);
525 void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
527 if (lastfooterBorderAboveCB->isChecked())
528 controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
530 controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
535 void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
537 if (lastfooterBorderBelowCB->isChecked())
538 controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
540 controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
545 void GuiTabularDialog::ltLastFooterEmpty_clicked()
547 bool enable(lastfooterNoContentsCB->isChecked());
549 controller().set(Tabular::SET_LTLASTFOOT, "empty");
551 controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
552 lastfooterStatusCB->setEnabled(!enable);
553 lastfooterBorderAboveCB->setEnabled(!enable);
554 lastfooterBorderBelowCB->setEnabled(!enable);
559 void GuiTabularDialog::update_borders()
561 Tabular const & tabular = controller().tabular();
562 Tabular::idx_type const cell = controller().getActiveCell();
563 bool const isMulticolumnCell = tabular.isMultiColumn(cell);
565 if (!isMulticolumnCell) {
566 borders->setLeftEnabled(true);
567 borders->setRightEnabled(true);
568 borders->setTop(tabular.topLine(cell, true));
569 borders->setBottom(tabular.bottomLine(cell, true));
570 borders->setLeft(tabular.leftLine(cell, true));
571 borders->setRight(tabular.rightLine(cell, true));
572 // repaint the setborder widget
577 borders->setTop(tabular.topLine(cell));
578 borders->setBottom(tabular.bottomLine(cell));
579 // pay attention to left/right lines: they are only allowed
580 // to set if we are in first/last cell of row or if the left/right
581 // cell is also a multicolumn.
582 if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
583 borders->setLeftEnabled(true);
584 borders->setLeft(tabular.leftLine(cell));
586 borders->setLeft(false);
587 borders->setLeftEnabled(false);
589 if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
590 borders->setRightEnabled(true);
591 borders->setRight(tabular.rightLine(cell));
593 borders->setRight(false);
594 borders->setRightEnabled(false);
596 // repaint the setborder widget
601 void GuiTabularDialog::updateContents()
603 controller().initialiseParams(string());
605 Tabular const & tabular(controller().tabular());
606 Tabular::idx_type const cell = controller().getActiveCell();
608 Tabular::row_type const row = tabular.cellRow(cell);
609 Tabular::col_type const col = tabular.cellColumn(cell);
611 tabularRowED->setText(QString::number(row + 1));
612 tabularColumnED->setText(QString::number(col + 1));
614 bool const multicol(tabular.isMultiColumn(cell));
616 multicolumnCB->setChecked(multicol);
618 rotateCellCB->setChecked(tabular.getRotateCell(cell));
619 rotateTabularCB->setChecked(tabular.getRotateTabular());
621 longTabularCB->setChecked(tabular.isLongTabular());
629 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
630 pwidth = tabular.getMColumnPWidth(cell);
632 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
633 pwidth = tabular.getColumnPWidth(cell);
636 specialAlignmentED->setText(toqstr(special));
638 bool const isReadonly = bc().policy().isReadOnly();
639 specialAlignmentED->setEnabled(!isReadonly);
641 Length::UNIT default_unit =
642 controller().useMetricUnits() ? Length::CM : Length::IN;
644 borderDefaultRB->setChecked(!tabular.useBookTabs());
645 booktabsRB->setChecked(tabular.useBookTabs());
647 if (tabular.row_info[row].top_space.empty()
648 && !tabular.row_info[row].top_space_default) {
649 topspaceCO->setCurrentIndex(0);
650 } else if (tabular.row_info[row].top_space_default) {
651 topspaceCO->setCurrentIndex(1);
653 topspaceCO->setCurrentIndex(2);
654 lengthToWidgets(topspaceED,
656 tabular.row_info[row].top_space.asString(),
659 topspaceED->setEnabled(!isReadonly
660 && (topspaceCO->currentIndex() == 2));
661 topspaceUnit->setEnabled(!isReadonly
662 && (topspaceCO->currentIndex() == 2));
663 topspaceCO->setEnabled(!isReadonly);
665 if (tabular.row_info[row].bottom_space.empty()
666 && !tabular.row_info[row].bottom_space_default) {
667 bottomspaceCO->setCurrentIndex(0);
668 } else if (tabular.row_info[row].bottom_space_default) {
669 bottomspaceCO->setCurrentIndex(1);
671 bottomspaceCO->setCurrentIndex(2);
672 lengthToWidgets(bottomspaceED,
674 tabular.row_info[row].bottom_space.asString(),
677 bottomspaceED->setEnabled(!isReadonly
678 && (bottomspaceCO->currentIndex() == 2));
679 bottomspaceUnit->setEnabled(!isReadonly
680 && (bottomspaceCO->currentIndex() == 2));
681 bottomspaceCO->setEnabled(!isReadonly);
683 if (tabular.row_info[row].interline_space.empty()
684 && !tabular.row_info[row].interline_space_default) {
685 interlinespaceCO->setCurrentIndex(0);
686 } else if (tabular.row_info[row].interline_space_default) {
687 interlinespaceCO->setCurrentIndex(1);
689 interlinespaceCO->setCurrentIndex(2);
690 lengthToWidgets(interlinespaceED,
692 tabular.row_info[row].interline_space.asString(),
695 interlinespaceED->setEnabled(!isReadonly
696 && (interlinespaceCO->currentIndex() == 2));
697 interlinespaceUnit->setEnabled(!isReadonly
698 && (interlinespaceCO->currentIndex() == 2));
699 interlinespaceCO->setEnabled(!isReadonly);
703 colwidth = pwidth.asString();
704 lengthToWidgets(widthED, widthUnit,
705 colwidth, default_unit);
707 widthED->setEnabled(!isReadonly);
708 widthUnit->setEnabled(!isReadonly);
711 hAlignCB->addItem(qt_("Left"));
712 hAlignCB->addItem(qt_("Center"));
713 hAlignCB->addItem(qt_("Right"));
714 if (!multicol && !pwidth.zero())
715 hAlignCB->addItem(qt_("Justified"));
718 switch (tabular.getAlignment(cell)) {
722 case LYX_ALIGN_CENTER:
725 case LYX_ALIGN_RIGHT:
728 case LYX_ALIGN_BLOCK:
730 if (!multicol && !pwidth.zero())
738 hAlignCB->setCurrentIndex(align);
741 switch (tabular.getVAlignment(cell)) {
742 case Tabular::LYX_VALIGN_TOP:
745 case Tabular::LYX_VALIGN_MIDDLE:
748 case Tabular::LYX_VALIGN_BOTTOM:
757 vAlignCB->setCurrentIndex(valign);
759 hAlignCB->setEnabled(true);
760 vAlignCB->setEnabled(!pwidth.zero());
762 if (!tabular.isLongTabular()) {
763 headerStatusCB->setChecked(false);
764 headerBorderAboveCB->setChecked(false);
765 headerBorderBelowCB->setChecked(false);
766 firstheaderStatusCB->setChecked(false);
767 firstheaderBorderAboveCB->setChecked(false);
768 firstheaderBorderBelowCB->setChecked(false);
769 firstheaderNoContentsCB->setChecked(false);
770 footerStatusCB->setChecked(false);
771 footerBorderAboveCB->setChecked(false);
772 footerBorderBelowCB->setChecked(false);
773 lastfooterStatusCB->setChecked(false);
774 lastfooterBorderAboveCB->setChecked(false);
775 lastfooterBorderBelowCB->setChecked(false);
776 lastfooterNoContentsCB->setChecked(false);
777 newpageCB->setChecked(false);
778 newpageCB->setEnabled(false);
784 bool row_set = tabular.getRowOfLTHead(row, ltt);
785 headerStatusCB->setChecked(row_set);
787 headerBorderAboveCB->setChecked(ltt.topDL);
788 headerBorderBelowCB->setChecked(ltt.bottomDL);
791 headerBorderAboveCB->setChecked(false);
792 headerBorderBelowCB->setChecked(false);
793 headerBorderAboveCB->setEnabled(false);
794 headerBorderBelowCB->setEnabled(false);
795 firstheaderNoContentsCB->setChecked(false);
796 firstheaderNoContentsCB->setEnabled(false);
800 row_set = tabular.getRowOfLTFirstHead(row, ltt);
801 firstheaderStatusCB->setChecked(row_set);
802 if (ltt.set && (!ltt.empty || !use_empty)) {
803 firstheaderBorderAboveCB->setChecked(ltt.topDL);
804 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
806 firstheaderBorderAboveCB->setEnabled(false);
807 firstheaderBorderBelowCB->setEnabled(false);
808 firstheaderBorderAboveCB->setChecked(false);
809 firstheaderBorderBelowCB->setChecked(false);
811 firstheaderNoContentsCB->setChecked(ltt.empty);
813 firstheaderStatusCB->setEnabled(false);
817 row_set = tabular.getRowOfLTFoot(row, ltt);
818 footerStatusCB->setChecked(row_set);
820 footerBorderAboveCB->setChecked(ltt.topDL);
821 footerBorderBelowCB->setChecked(ltt.bottomDL);
824 footerBorderAboveCB->setChecked(false);
825 footerBorderBelowCB->setChecked(false);
826 footerBorderAboveCB->setEnabled(false);
827 footerBorderBelowCB->setEnabled(false);
828 lastfooterNoContentsCB->setChecked(false);
829 lastfooterNoContentsCB->setEnabled(false);
833 row_set = tabular.getRowOfLTLastFoot(row, ltt);
834 lastfooterStatusCB->setChecked(row_set);
835 if (ltt.set && (!ltt.empty || !use_empty)) {
836 lastfooterBorderAboveCB->setChecked(ltt.topDL);
837 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
839 lastfooterBorderAboveCB->setEnabled(false);
840 lastfooterBorderBelowCB->setEnabled(false);
841 lastfooterBorderAboveCB->setChecked(false);
842 lastfooterBorderBelowCB->setChecked(false);
844 lastfooterNoContentsCB->setChecked(ltt.empty);
846 lastfooterStatusCB->setEnabled(false);
849 newpageCB->setChecked(tabular.getLTNewPage(row));
853 void GuiTabularDialog::closeGUI()
855 // ugly hack to auto-apply the stuff that hasn't been
856 // yet. don't let this continue to exist ...
858 // Subtle here, we must /not/ apply any changes and
859 // then refer to tabular, as it will have been freed
860 // since the changes update the actual controller().tabular()
861 Tabular const & tabular(controller().tabular());
863 // apply the fixed width values
864 Tabular::idx_type const cell = controller().getActiveCell();
865 bool const multicol = tabular.isMultiColumn(cell);
866 string width = widgetsToLength(widthED, widthUnit);
869 Length llen = tabular.getColumnPWidth(cell);
870 Length llenMulti = tabular.getMColumnPWidth(cell);
872 if (multicol && !llenMulti.zero())
873 width2 = llenMulti.asString();
874 else if (!multicol && !llen.zero())
875 width2 = llen.asString();
877 // apply the special alignment
878 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
882 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
884 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
888 controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
890 controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
893 if (width != width2) {
895 controller().set(Tabular::SET_MPWIDTH, width);
897 controller().set(Tabular::SET_PWIDTH, width);
901 switch (topspaceCO->currentIndex()) {
903 controller().set(Tabular::SET_TOP_SPACE, "");
906 controller().set(Tabular::SET_TOP_SPACE, "default");
909 controller().set(Tabular::SET_TOP_SPACE,
910 widgetsToLength(topspaceED,
915 switch (bottomspaceCO->currentIndex()) {
917 controller().set(Tabular::SET_BOTTOM_SPACE, "");
920 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
923 controller().set(Tabular::SET_BOTTOM_SPACE,
924 widgetsToLength(bottomspaceED,
929 switch (interlinespaceCO->currentIndex()) {
931 controller().set(Tabular::SET_INTERLINE_SPACE, "");
934 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
937 controller().set(Tabular::SET_INTERLINE_SPACE,
938 widgetsToLength(interlinespaceED,
939 interlinespaceUnit));
945 } // namespace frontend
948 #include "GuiTabular_moc.cpp"