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 "BufferView.h"
19 #include "FuncRequest.h"
20 #include "GuiSetBorder.h"
21 #include "LengthCombo.h"
23 #include "qt_helpers.h"
24 #include "Validator.h"
26 #include "insets/InsetTabular.h"
28 #include <QCloseEvent>
30 #include <QPushButton>
31 #include <QRadioButton>
39 GuiTabular::GuiTabular(GuiView & lv)
40 : GuiDialog(lv, "tabular")
42 active_cell_ = Tabular::npos;
45 setViewTitle(_("Table Settings"));
47 widthED->setValidator(unsignedLengthValidator(widthED));
48 topspaceED->setValidator(new LengthValidator(topspaceED));
49 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
50 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
52 connect(topspaceED, SIGNAL(returnPressed()),
53 this, SLOT(topspace_changed()));
54 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
55 this, SLOT(topspace_changed()));
56 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
57 connect(bottomspaceED, SIGNAL(returnPressed()),
58 this, SLOT(bottomspace_changed()));
59 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
60 this, SLOT(bottomspace_changed()));
61 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
62 connect(interlinespaceED, SIGNAL(returnPressed()),
63 this, SLOT(interlinespace_changed()));
64 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
65 this, SLOT(interlinespace_changed()));
66 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
67 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
68 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
69 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
70 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
71 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
72 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
73 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
74 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
75 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
76 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
77 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
78 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
79 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
80 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
81 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
82 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
83 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
84 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
85 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
86 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
87 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
88 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
89 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
90 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
91 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
92 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
93 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
94 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
95 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
96 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
97 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
98 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
99 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
100 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
101 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
103 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
104 bc().setCancel(closePB);
106 bc().addReadOnly(topspaceED);
107 bc().addReadOnly(topspaceUnit);
108 bc().addReadOnly(topspaceCO);
109 bc().addReadOnly(bottomspaceED);
110 bc().addReadOnly(bottomspaceUnit);
111 bc().addReadOnly(bottomspaceCO);
112 bc().addReadOnly(interlinespaceED);
113 bc().addReadOnly(interlinespaceUnit);
114 bc().addReadOnly(interlinespaceCO);
115 bc().addReadOnly(borderDefaultRB);
116 bc().addReadOnly(booktabsRB);
118 bc().addReadOnly(multicolumnCB);
119 bc().addReadOnly(rotateCellCB);
120 bc().addReadOnly(rotateTabularCB);
121 bc().addReadOnly(specialAlignmentED);
122 bc().addReadOnly(widthED);
123 bc().addReadOnly(widthUnit);
124 bc().addReadOnly(hAlignCB);
125 bc().addReadOnly(vAlignCB);
126 bc().addReadOnly(borderSetPB);
127 bc().addReadOnly(borderUnsetPB);
128 bc().addReadOnly(borders);
129 bc().addReadOnly(longTabularCB);
130 bc().addReadOnly(headerStatusCB);
131 bc().addReadOnly(headerBorderAboveCB);
132 bc().addReadOnly(headerBorderBelowCB);
133 bc().addReadOnly(firstheaderStatusCB);
134 bc().addReadOnly(firstheaderBorderAboveCB);
135 bc().addReadOnly(firstheaderBorderBelowCB);
136 bc().addReadOnly(firstheaderNoContentsCB);
137 bc().addReadOnly(footerStatusCB);
138 bc().addReadOnly(footerBorderAboveCB);
139 bc().addReadOnly(footerBorderBelowCB);
140 bc().addReadOnly(lastfooterStatusCB);
141 bc().addReadOnly(lastfooterBorderAboveCB);
142 bc().addReadOnly(lastfooterBorderBelowCB);
143 bc().addReadOnly(lastfooterNoContentsCB);
144 bc().addReadOnly(newpageCB);
146 // initialize the length validator
147 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
148 bc().addCheckedLineEdit(topspaceED, topspaceLA);
149 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
150 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
154 GuiTabular::~GuiTabular()
159 void GuiTabular::change_adaptor()
165 void GuiTabular::closeEvent(QCloseEvent * e)
168 GuiDialog::closeEvent(e);
172 void GuiTabular::booktabsChanged(bool)
175 booktabs(booktabsRB->isChecked());
180 void GuiTabular::topspace_changed()
182 switch (topspaceCO->currentIndex()) {
184 set(Tabular::SET_TOP_SPACE, "");
185 topspaceED->setEnabled(false);
186 topspaceUnit->setEnabled(false);
190 set(Tabular::SET_TOP_SPACE, "default");
191 topspaceED->setEnabled(false);
192 topspaceUnit->setEnabled(false);
196 if (!topspaceED->text().isEmpty())
197 set(Tabular::SET_TOP_SPACE,
198 widgetsToLength(topspaceED, topspaceUnit));
199 if (!bc().policy().isReadOnly()) {
200 topspaceED->setEnabled(true);
201 topspaceUnit->setEnabled(true);
210 void GuiTabular::bottomspace_changed()
212 switch (bottomspaceCO->currentIndex()) {
214 set(Tabular::SET_BOTTOM_SPACE, "");
215 bottomspaceED->setEnabled(false);
216 bottomspaceUnit->setEnabled(false);
220 set(Tabular::SET_BOTTOM_SPACE, "default");
221 bottomspaceED->setEnabled(false);
222 bottomspaceUnit->setEnabled(false);
226 if (!bottomspaceED->text().isEmpty())
227 set(Tabular::SET_BOTTOM_SPACE,
228 widgetsToLength(bottomspaceED, bottomspaceUnit));
229 if (!bc().policy().isReadOnly()) {
230 bottomspaceED->setEnabled(true);
231 bottomspaceUnit->setEnabled(true);
240 void GuiTabular::interlinespace_changed()
242 switch (interlinespaceCO->currentIndex()) {
244 set(Tabular::SET_INTERLINE_SPACE, "");
245 interlinespaceED->setEnabled(false);
246 interlinespaceUnit->setEnabled(false);
250 set(Tabular::SET_INTERLINE_SPACE, "default");
251 interlinespaceED->setEnabled(false);
252 interlinespaceUnit->setEnabled(false);
256 if (!interlinespaceED->text().isEmpty())
257 set(Tabular::SET_INTERLINE_SPACE,
258 widgetsToLength(interlinespaceED, interlinespaceUnit));
259 if (!bc().policy().isReadOnly()) {
260 interlinespaceED->setEnabled(true);
261 interlinespaceUnit->setEnabled(true);
270 void GuiTabular::close_clicked()
277 void GuiTabular::borderSet_clicked()
279 set(Tabular::SET_ALL_LINES);
285 void GuiTabular::borderUnset_clicked()
287 set(Tabular::UNSET_ALL_LINES);
293 void GuiTabular::leftBorder_changed()
300 void GuiTabular::rightBorder_changed()
307 void GuiTabular::topBorder_changed()
314 void GuiTabular::bottomBorder_changed()
321 void GuiTabular::specialAlignment_changed()
323 string special = fromqstr(specialAlignmentED->text());
329 void GuiTabular::width_changed()
332 string const width = widgetsToLength(widthED, widthUnit);
337 void GuiTabular::multicolumn_clicked()
344 void GuiTabular::rotateTabular()
346 rotateTabular(rotateTabularCB->isChecked());
351 void GuiTabular::rotateCell()
353 rotateCell(rotateCellCB->isChecked());
358 void GuiTabular::hAlign_changed(int align)
360 GuiTabular::HALIGN h = GuiTabular::LEFT;
363 case 0: h = GuiTabular::LEFT; break;
364 case 1: h = GuiTabular::CENTER; break;
365 case 2: h = GuiTabular::RIGHT; break;
366 case 3: h = GuiTabular::BLOCK; break;
373 void GuiTabular::vAlign_changed(int align)
375 GuiTabular::VALIGN v = GuiTabular::TOP;
378 case 0: v = GuiTabular::TOP; break;
379 case 1: v = GuiTabular::MIDDLE; break;
380 case 2: v = GuiTabular::BOTTOM; break;
387 void GuiTabular::longTabular()
389 longTabular(longTabularCB->isChecked());
394 void GuiTabular::ltNewpage_clicked()
396 set(Tabular::SET_LTNEWPAGE);
401 void GuiTabular::ltHeaderStatus_clicked()
403 bool enable = headerStatusCB->isChecked();
405 set(Tabular::SET_LTHEAD, "");
407 set(Tabular::UNSET_LTHEAD, "");
408 headerBorderAboveCB->setEnabled(enable);
409 headerBorderBelowCB->setEnabled(enable);
410 firstheaderNoContentsCB->setEnabled(enable);
415 void GuiTabular::ltHeaderBorderAbove_clicked()
417 if (headerBorderAboveCB->isChecked())
418 set(Tabular::SET_LTHEAD, "dl_above");
420 set(Tabular::UNSET_LTHEAD, "dl_above");
425 void GuiTabular::ltHeaderBorderBelow_clicked()
427 if (headerBorderBelowCB->isChecked())
428 set(Tabular::SET_LTHEAD, "dl_below");
430 set(Tabular::UNSET_LTHEAD, "dl_below");
435 void GuiTabular::ltFirstHeaderBorderAbove_clicked()
437 if (firstheaderBorderAboveCB->isChecked())
438 set(Tabular::SET_LTFIRSTHEAD, "dl_above");
440 set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
445 void GuiTabular::ltFirstHeaderBorderBelow_clicked()
447 if (firstheaderBorderBelowCB->isChecked())
448 set(Tabular::SET_LTFIRSTHEAD, "dl_below");
450 set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
455 void GuiTabular::ltFirstHeaderStatus_clicked()
457 bool enable = firstheaderStatusCB->isChecked();
459 set(Tabular::SET_LTFIRSTHEAD, "");
461 set(Tabular::UNSET_LTFIRSTHEAD, "");
462 firstheaderBorderAboveCB->setEnabled(enable);
463 firstheaderBorderBelowCB->setEnabled(enable);
468 void GuiTabular::ltFirstHeaderEmpty_clicked()
470 bool enable = firstheaderNoContentsCB->isChecked();
472 set(Tabular::SET_LTFIRSTHEAD, "empty");
474 set(Tabular::UNSET_LTFIRSTHEAD, "empty");
475 firstheaderStatusCB->setEnabled(!enable);
476 firstheaderBorderAboveCB->setEnabled(!enable);
477 firstheaderBorderBelowCB->setEnabled(!enable);
482 void GuiTabular::ltFooterStatus_clicked()
484 bool enable = footerStatusCB->isChecked();
486 set(Tabular::SET_LTFOOT, "");
488 set(Tabular::UNSET_LTFOOT, "");
489 footerBorderAboveCB->setEnabled(enable);
490 footerBorderBelowCB->setEnabled(enable);
491 lastfooterNoContentsCB->setEnabled(enable);
496 void GuiTabular::ltFooterBorderAbove_clicked()
498 if (footerBorderAboveCB->isChecked())
499 set(Tabular::SET_LTFOOT, "dl_above");
501 set(Tabular::UNSET_LTFOOT, "dl_above");
506 void GuiTabular::ltFooterBorderBelow_clicked()
508 if (footerBorderBelowCB->isChecked())
509 set(Tabular::SET_LTFOOT, "dl_below");
511 set(Tabular::UNSET_LTFOOT, "dl_below");
516 void GuiTabular::ltLastFooterStatus_clicked()
518 bool enable = lastfooterStatusCB->isChecked();
520 set(Tabular::SET_LTLASTFOOT, "");
522 set(Tabular::UNSET_LTLASTFOOT, "");
523 lastfooterBorderAboveCB->setEnabled(enable);
524 lastfooterBorderBelowCB->setEnabled(enable);
529 void GuiTabular::ltLastFooterBorderAbove_clicked()
531 if (lastfooterBorderAboveCB->isChecked())
532 set(Tabular::SET_LTLASTFOOT, "dl_above");
534 set(Tabular::UNSET_LTLASTFOOT, "dl_above");
539 void GuiTabular::ltLastFooterBorderBelow_clicked()
541 if (lastfooterBorderBelowCB->isChecked())
542 set(Tabular::SET_LTLASTFOOT, "dl_below");
544 set(Tabular::UNSET_LTLASTFOOT, "dl_below");
549 void GuiTabular::ltLastFooterEmpty_clicked()
551 bool enable = lastfooterNoContentsCB->isChecked();
553 set(Tabular::SET_LTLASTFOOT, "empty");
555 set(Tabular::UNSET_LTLASTFOOT, "empty");
556 lastfooterStatusCB->setEnabled(!enable);
557 lastfooterBorderAboveCB->setEnabled(!enable);
558 lastfooterBorderBelowCB->setEnabled(!enable);
563 void GuiTabular::update_borders()
565 Tabular::idx_type const cell = getActiveCell();
566 bool const isMulticolumnCell = tabular_.isMultiColumn(cell);
568 if (!isMulticolumnCell) {
569 borders->setLeftEnabled(true);
570 borders->setRightEnabled(true);
571 borders->setTop(tabular_.topLine(cell, true));
572 borders->setBottom(tabular_.bottomLine(cell, true));
573 borders->setLeft(tabular_.leftLine(cell, true));
574 borders->setRight(tabular_.rightLine(cell, true));
575 // repaint the setborder widget
580 borders->setTop(tabular_.topLine(cell));
581 borders->setBottom(tabular_.bottomLine(cell));
582 // pay attention to left/right lines: they are only allowed
583 // to set if we are in first/last cell of row or if the left/right
584 // cell is also a multicolumn.
585 if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) {
586 borders->setLeftEnabled(true);
587 borders->setLeft(tabular_.leftLine(cell));
589 borders->setLeft(false);
590 borders->setLeftEnabled(false);
592 if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) {
593 borders->setRightEnabled(true);
594 borders->setRight(tabular_.rightLine(cell));
596 borders->setRight(false);
597 borders->setRightEnabled(false);
599 // repaint the setborder widget
604 void GuiTabular::updateContents()
606 initialiseParams(string());
608 Tabular::idx_type const cell = getActiveCell();
610 Tabular::row_type const row = tabular_.cellRow(cell);
611 Tabular::col_type const col = tabular_.cellColumn(cell);
613 tabularRowED->setText(QString::number(row + 1));
614 tabularColumnED->setText(QString::number(col + 1));
616 bool const multicol(tabular_.isMultiColumn(cell));
618 multicolumnCB->setChecked(multicol);
620 rotateCellCB->setChecked(tabular_.getRotateCell(cell));
621 rotateTabularCB->setChecked(tabular_.getRotateTabular());
623 longTabularCB->setChecked(tabular_.isLongTabular());
631 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
632 pwidth = tabular_.getMColumnPWidth(cell);
634 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
635 pwidth = tabular_.getColumnPWidth(cell);
638 specialAlignmentED->setText(toqstr(special));
640 bool const isReadonly = bc().policy().isReadOnly();
641 specialAlignmentED->setEnabled(!isReadonly);
643 Length::UNIT default_unit =
644 useMetricUnits() ? Length::CM : Length::IN;
646 borderDefaultRB->setChecked(!tabular_.useBookTabs());
647 booktabsRB->setChecked(tabular_.useBookTabs());
649 if (tabular_.row_info[row].top_space.empty()
650 && !tabular_.row_info[row].top_space_default) {
651 topspaceCO->setCurrentIndex(0);
652 } else if (tabular_.row_info[row].top_space_default) {
653 topspaceCO->setCurrentIndex(1);
655 topspaceCO->setCurrentIndex(2);
656 lengthToWidgets(topspaceED,
658 tabular_.row_info[row].top_space.asString(),
661 topspaceED->setEnabled(!isReadonly
662 && (topspaceCO->currentIndex() == 2));
663 topspaceUnit->setEnabled(!isReadonly
664 && (topspaceCO->currentIndex() == 2));
665 topspaceCO->setEnabled(!isReadonly);
667 if (tabular_.row_info[row].bottom_space.empty()
668 && !tabular_.row_info[row].bottom_space_default) {
669 bottomspaceCO->setCurrentIndex(0);
670 } else if (tabular_.row_info[row].bottom_space_default) {
671 bottomspaceCO->setCurrentIndex(1);
673 bottomspaceCO->setCurrentIndex(2);
674 lengthToWidgets(bottomspaceED,
676 tabular_.row_info[row].bottom_space.asString(),
679 bottomspaceED->setEnabled(!isReadonly
680 && (bottomspaceCO->currentIndex() == 2));
681 bottomspaceUnit->setEnabled(!isReadonly
682 && (bottomspaceCO->currentIndex() == 2));
683 bottomspaceCO->setEnabled(!isReadonly);
685 if (tabular_.row_info[row].interline_space.empty()
686 && !tabular_.row_info[row].interline_space_default) {
687 interlinespaceCO->setCurrentIndex(0);
688 } else if (tabular_.row_info[row].interline_space_default) {
689 interlinespaceCO->setCurrentIndex(1);
691 interlinespaceCO->setCurrentIndex(2);
692 lengthToWidgets(interlinespaceED,
694 tabular_.row_info[row].interline_space.asString(),
697 interlinespaceED->setEnabled(!isReadonly
698 && (interlinespaceCO->currentIndex() == 2));
699 interlinespaceUnit->setEnabled(!isReadonly
700 && (interlinespaceCO->currentIndex() == 2));
701 interlinespaceCO->setEnabled(!isReadonly);
705 colwidth = pwidth.asString();
706 lengthToWidgets(widthED, widthUnit,
707 colwidth, default_unit);
709 widthED->setEnabled(!isReadonly);
710 widthUnit->setEnabled(!isReadonly);
713 hAlignCB->addItem(qt_("Left"));
714 hAlignCB->addItem(qt_("Center"));
715 hAlignCB->addItem(qt_("Right"));
716 if (!multicol && !pwidth.zero())
717 hAlignCB->addItem(qt_("Justified"));
720 switch (tabular_.getAlignment(cell)) {
724 case LYX_ALIGN_CENTER:
727 case LYX_ALIGN_RIGHT:
730 case LYX_ALIGN_BLOCK:
732 if (!multicol && !pwidth.zero())
740 hAlignCB->setCurrentIndex(align);
743 switch (tabular_.getVAlignment(cell)) {
744 case Tabular::LYX_VALIGN_TOP:
747 case Tabular::LYX_VALIGN_MIDDLE:
750 case Tabular::LYX_VALIGN_BOTTOM:
759 vAlignCB->setCurrentIndex(valign);
761 hAlignCB->setEnabled(true);
762 vAlignCB->setEnabled(!pwidth.zero());
764 if (!tabular_.isLongTabular()) {
765 headerStatusCB->setChecked(false);
766 headerBorderAboveCB->setChecked(false);
767 headerBorderBelowCB->setChecked(false);
768 firstheaderStatusCB->setChecked(false);
769 firstheaderBorderAboveCB->setChecked(false);
770 firstheaderBorderBelowCB->setChecked(false);
771 firstheaderNoContentsCB->setChecked(false);
772 footerStatusCB->setChecked(false);
773 footerBorderAboveCB->setChecked(false);
774 footerBorderBelowCB->setChecked(false);
775 lastfooterStatusCB->setChecked(false);
776 lastfooterBorderAboveCB->setChecked(false);
777 lastfooterBorderBelowCB->setChecked(false);
778 lastfooterNoContentsCB->setChecked(false);
779 newpageCB->setChecked(false);
780 newpageCB->setEnabled(false);
786 bool row_set = tabular_.getRowOfLTHead(row, ltt);
787 headerStatusCB->setChecked(row_set);
789 headerBorderAboveCB->setChecked(ltt.topDL);
790 headerBorderBelowCB->setChecked(ltt.bottomDL);
793 headerBorderAboveCB->setChecked(false);
794 headerBorderBelowCB->setChecked(false);
795 headerBorderAboveCB->setEnabled(false);
796 headerBorderBelowCB->setEnabled(false);
797 firstheaderNoContentsCB->setChecked(false);
798 firstheaderNoContentsCB->setEnabled(false);
802 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
803 firstheaderStatusCB->setChecked(row_set);
804 if (ltt.set && (!ltt.empty || !use_empty)) {
805 firstheaderBorderAboveCB->setChecked(ltt.topDL);
806 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
808 firstheaderBorderAboveCB->setEnabled(false);
809 firstheaderBorderBelowCB->setEnabled(false);
810 firstheaderBorderAboveCB->setChecked(false);
811 firstheaderBorderBelowCB->setChecked(false);
813 firstheaderNoContentsCB->setChecked(ltt.empty);
815 firstheaderStatusCB->setEnabled(false);
819 row_set = tabular_.getRowOfLTFoot(row, ltt);
820 footerStatusCB->setChecked(row_set);
822 footerBorderAboveCB->setChecked(ltt.topDL);
823 footerBorderBelowCB->setChecked(ltt.bottomDL);
826 footerBorderAboveCB->setChecked(false);
827 footerBorderBelowCB->setChecked(false);
828 footerBorderAboveCB->setEnabled(false);
829 footerBorderBelowCB->setEnabled(false);
830 lastfooterNoContentsCB->setChecked(false);
831 lastfooterNoContentsCB->setEnabled(false);
835 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
836 lastfooterStatusCB->setChecked(row_set);
837 if (ltt.set && (!ltt.empty || !use_empty)) {
838 lastfooterBorderAboveCB->setChecked(ltt.topDL);
839 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
841 lastfooterBorderAboveCB->setEnabled(false);
842 lastfooterBorderBelowCB->setEnabled(false);
843 lastfooterBorderAboveCB->setChecked(false);
844 lastfooterBorderBelowCB->setChecked(false);
846 lastfooterNoContentsCB->setChecked(ltt.empty);
848 lastfooterStatusCB->setEnabled(false);
851 newpageCB->setChecked(tabular_.getLTNewPage(row));
855 void GuiTabular::closeGUI()
857 // ugly hack to auto-apply the stuff that hasn't been
858 // yet. don't let this continue to exist ...
860 // Subtle here, we must /not/ apply any changes and
861 // then refer to tabular, as it will have been freed
862 // since the changes update the actual tabular_
864 // apply the fixed width values
865 Tabular::idx_type const cell = getActiveCell();
866 bool const multicol = tabular_.isMultiColumn(cell);
867 string width = widgetsToLength(widthED, widthUnit);
870 Length llen = tabular_.getColumnPWidth(cell);
871 Length llenMulti = tabular_.getMColumnPWidth(cell);
873 if (multicol && !llenMulti.zero())
874 width2 = llenMulti.asString();
875 else if (!multicol && !llen.zero())
876 width2 = llen.asString();
878 // apply the special alignment
879 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
883 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
885 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
889 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
891 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
894 if (width != width2) {
896 set(Tabular::SET_MPWIDTH, width);
898 set(Tabular::SET_PWIDTH, width);
902 switch (topspaceCO->currentIndex()) {
904 set(Tabular::SET_TOP_SPACE, "");
907 set(Tabular::SET_TOP_SPACE, "default");
910 set(Tabular::SET_TOP_SPACE,
911 widgetsToLength(topspaceED, topspaceUnit));
915 switch (bottomspaceCO->currentIndex()) {
917 set(Tabular::SET_BOTTOM_SPACE, "");
920 set(Tabular::SET_BOTTOM_SPACE, "default");
923 set(Tabular::SET_BOTTOM_SPACE,
924 widgetsToLength(bottomspaceED, bottomspaceUnit));
928 switch (interlinespaceCO->currentIndex()) {
930 set(Tabular::SET_INTERLINE_SPACE, "");
933 set(Tabular::SET_INTERLINE_SPACE, "default");
936 set(Tabular::SET_INTERLINE_SPACE,
937 widgetsToLength(interlinespaceED, interlinespaceUnit));
944 bool GuiTabular::initialiseParams(string const & data)
946 // try to get the current cell
947 BufferView const * const bv = bufferview();
948 InsetTabular const * current_inset = 0;
950 Cursor const & cur = bv->cursor();
951 // get the innermost tabular inset;
952 // assume that it is "ours"
953 for (int i = cur.depth() - 1; i >= 0; --i)
954 if (cur[i].inset().lyxCode() == TABULAR_CODE) {
955 current_inset = static_cast<InsetTabular const *>(&cur[i].inset());
956 active_cell_ = cur[i].idx();
961 if (current_inset && data.empty()) {
962 tabular_ = Tabular(current_inset->tabular);
966 InsetTabular tmp(buffer());
967 InsetTabularMailer::string2params(data, tmp);
968 tabular_ = Tabular(tmp.tabular);
973 void GuiTabular::clearParams()
975 InsetTabular tmp(buffer());
976 tabular_ = tmp.tabular;
977 active_cell_ = Tabular::npos;
981 Tabular::idx_type GuiTabular::getActiveCell() const
987 void GuiTabular::set(Tabular::Feature f, string const & arg)
989 string const data = featureAsString(f) + ' ' + arg;
990 dispatch(FuncRequest(getLfun(), data));
994 bool GuiTabular::useMetricUnits() const
996 return lyxrc.default_papersize > PAPER_USEXECUTIVE;
1000 void GuiTabular::toggleTopLine()
1002 if (tabular_.isMultiColumn(getActiveCell()))
1003 set(Tabular::M_TOGGLE_LINE_TOP);
1005 set(Tabular::TOGGLE_LINE_TOP);
1009 void GuiTabular::toggleBottomLine()
1011 if (tabular_.isMultiColumn(getActiveCell()))
1012 set(Tabular::M_TOGGLE_LINE_BOTTOM);
1014 set(Tabular::TOGGLE_LINE_BOTTOM);
1018 void GuiTabular::toggleLeftLine()
1020 if (tabular_.isMultiColumn(getActiveCell()))
1021 set(Tabular::M_TOGGLE_LINE_LEFT);
1023 set(Tabular::TOGGLE_LINE_LEFT);
1027 void GuiTabular::toggleRightLine()
1029 if (tabular_.isMultiColumn(getActiveCell()))
1030 set(Tabular::M_TOGGLE_LINE_RIGHT);
1032 set(Tabular::TOGGLE_LINE_RIGHT);
1036 void GuiTabular::setSpecial(string const & special)
1038 if (tabular_.isMultiColumn(getActiveCell()))
1039 set(Tabular::SET_SPECIAL_MULTI, special);
1041 set(Tabular::SET_SPECIAL_COLUMN, special);
1045 void GuiTabular::setWidth(string const & width)
1047 if (tabular_.isMultiColumn(getActiveCell()))
1048 set(Tabular::SET_MPWIDTH, width);
1050 set(Tabular::SET_PWIDTH, width);
1056 void GuiTabular::toggleMultiColumn()
1058 set(Tabular::MULTICOLUMN);
1063 void GuiTabular::rotateTabular(bool yes)
1066 set(Tabular::SET_ROTATE_TABULAR);
1068 set(Tabular::UNSET_ROTATE_TABULAR);
1072 void GuiTabular::rotateCell(bool yes)
1075 set(Tabular::SET_ROTATE_CELL);
1077 set(Tabular::UNSET_ROTATE_CELL);
1081 void GuiTabular::halign(GuiTabular::HALIGN h)
1083 Tabular::Feature num = Tabular::ALIGN_LEFT;
1084 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
1088 num = Tabular::ALIGN_LEFT;
1089 multi_num = Tabular::M_ALIGN_LEFT;
1092 num = Tabular::ALIGN_CENTER;
1093 multi_num = Tabular::M_ALIGN_CENTER;
1096 num = Tabular::ALIGN_RIGHT;
1097 multi_num = Tabular::M_ALIGN_RIGHT;
1100 num = Tabular::ALIGN_BLOCK;
1101 //multi_num: no equivalent
1105 if (tabular_.isMultiColumn(getActiveCell()))
1112 void GuiTabular::valign(GuiTabular::VALIGN v)
1114 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
1115 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
1119 num = Tabular::VALIGN_TOP;
1120 multi_num = Tabular::M_VALIGN_TOP;
1123 num = Tabular::VALIGN_MIDDLE;
1124 multi_num = Tabular::M_VALIGN_MIDDLE;
1127 num = Tabular::VALIGN_BOTTOM;
1128 multi_num = Tabular::M_VALIGN_BOTTOM;
1132 if (tabular_.isMultiColumn(getActiveCell()))
1139 void GuiTabular::booktabs(bool yes)
1142 set(Tabular::SET_BOOKTABS);
1144 set(Tabular::UNSET_BOOKTABS);
1148 void GuiTabular::longTabular(bool yes)
1151 set(Tabular::SET_LONGTABULAR);
1153 set(Tabular::UNSET_LONGTABULAR);
1157 Dialog * createGuiTabular(GuiView & lv) { return new GuiTabular(lv); }
1160 } // namespace frontend
1163 #include "GuiTabular_moc.cpp"