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>
40 GuiTabular::GuiTabular(LyXView & lv)
41 : GuiDialog(lv, "tabular"), Controller(this)
43 active_cell_ = Tabular::npos;
46 setViewTitle(_("Table Settings"));
47 setController(this, false);
49 widthED->setValidator(unsignedLengthValidator(widthED));
50 topspaceED->setValidator(new LengthValidator(topspaceED));
51 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
52 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
54 connect(topspaceED, SIGNAL(returnPressed()),
55 this, SLOT(topspace_changed()));
56 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
57 this, SLOT(topspace_changed()));
58 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
59 connect(bottomspaceED, SIGNAL(returnPressed()),
60 this, SLOT(bottomspace_changed()));
61 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
62 this, SLOT(bottomspace_changed()));
63 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
64 connect(interlinespaceED, SIGNAL(returnPressed()),
65 this, SLOT(interlinespace_changed()));
66 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
67 this, SLOT(interlinespace_changed()));
68 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
69 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
70 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
71 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
72 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
73 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
74 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
75 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
76 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
77 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
78 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
79 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
80 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
81 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
82 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
83 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
84 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
85 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
86 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
87 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
88 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
89 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
90 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
91 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
92 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
93 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
94 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
95 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
96 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
97 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
98 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
99 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
100 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
101 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
102 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
103 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
105 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
106 bc().setCancel(closePB);
108 bc().addReadOnly(topspaceED);
109 bc().addReadOnly(topspaceUnit);
110 bc().addReadOnly(topspaceCO);
111 bc().addReadOnly(bottomspaceED);
112 bc().addReadOnly(bottomspaceUnit);
113 bc().addReadOnly(bottomspaceCO);
114 bc().addReadOnly(interlinespaceED);
115 bc().addReadOnly(interlinespaceUnit);
116 bc().addReadOnly(interlinespaceCO);
117 bc().addReadOnly(borderDefaultRB);
118 bc().addReadOnly(booktabsRB);
120 bc().addReadOnly(multicolumnCB);
121 bc().addReadOnly(rotateCellCB);
122 bc().addReadOnly(rotateTabularCB);
123 bc().addReadOnly(specialAlignmentED);
124 bc().addReadOnly(widthED);
125 bc().addReadOnly(widthUnit);
126 bc().addReadOnly(hAlignCB);
127 bc().addReadOnly(vAlignCB);
128 bc().addReadOnly(borderSetPB);
129 bc().addReadOnly(borderUnsetPB);
130 bc().addReadOnly(borders);
131 bc().addReadOnly(longTabularCB);
132 bc().addReadOnly(headerStatusCB);
133 bc().addReadOnly(headerBorderAboveCB);
134 bc().addReadOnly(headerBorderBelowCB);
135 bc().addReadOnly(firstheaderStatusCB);
136 bc().addReadOnly(firstheaderBorderAboveCB);
137 bc().addReadOnly(firstheaderBorderBelowCB);
138 bc().addReadOnly(firstheaderNoContentsCB);
139 bc().addReadOnly(footerStatusCB);
140 bc().addReadOnly(footerBorderAboveCB);
141 bc().addReadOnly(footerBorderBelowCB);
142 bc().addReadOnly(lastfooterStatusCB);
143 bc().addReadOnly(lastfooterBorderAboveCB);
144 bc().addReadOnly(lastfooterBorderBelowCB);
145 bc().addReadOnly(lastfooterNoContentsCB);
146 bc().addReadOnly(newpageCB);
148 // initialize the length validator
149 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
150 bc().addCheckedLineEdit(topspaceED, topspaceLA);
151 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
152 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
156 GuiTabular::~GuiTabular()
161 void GuiTabular::change_adaptor()
167 void GuiTabular::closeEvent(QCloseEvent * e)
170 GuiDialog::closeEvent(e);
174 void GuiTabular::booktabsChanged(bool)
177 booktabs(booktabsRB->isChecked());
182 void GuiTabular::topspace_changed()
184 switch (topspaceCO->currentIndex()) {
186 set(Tabular::SET_TOP_SPACE, "");
187 topspaceED->setEnabled(false);
188 topspaceUnit->setEnabled(false);
192 set(Tabular::SET_TOP_SPACE, "default");
193 topspaceED->setEnabled(false);
194 topspaceUnit->setEnabled(false);
198 if (!topspaceED->text().isEmpty())
199 set(Tabular::SET_TOP_SPACE,
200 widgetsToLength(topspaceED, topspaceUnit));
201 if (!bc().policy().isReadOnly()) {
202 topspaceED->setEnabled(true);
203 topspaceUnit->setEnabled(true);
212 void GuiTabular::bottomspace_changed()
214 switch (bottomspaceCO->currentIndex()) {
216 set(Tabular::SET_BOTTOM_SPACE, "");
217 bottomspaceED->setEnabled(false);
218 bottomspaceUnit->setEnabled(false);
222 set(Tabular::SET_BOTTOM_SPACE, "default");
223 bottomspaceED->setEnabled(false);
224 bottomspaceUnit->setEnabled(false);
228 if (!bottomspaceED->text().isEmpty())
229 set(Tabular::SET_BOTTOM_SPACE,
230 widgetsToLength(bottomspaceED, bottomspaceUnit));
231 if (!bc().policy().isReadOnly()) {
232 bottomspaceED->setEnabled(true);
233 bottomspaceUnit->setEnabled(true);
242 void GuiTabular::interlinespace_changed()
244 switch (interlinespaceCO->currentIndex()) {
246 set(Tabular::SET_INTERLINE_SPACE, "");
247 interlinespaceED->setEnabled(false);
248 interlinespaceUnit->setEnabled(false);
252 set(Tabular::SET_INTERLINE_SPACE, "default");
253 interlinespaceED->setEnabled(false);
254 interlinespaceUnit->setEnabled(false);
258 if (!interlinespaceED->text().isEmpty())
259 set(Tabular::SET_INTERLINE_SPACE,
260 widgetsToLength(interlinespaceED, interlinespaceUnit));
261 if (!bc().policy().isReadOnly()) {
262 interlinespaceED->setEnabled(true);
263 interlinespaceUnit->setEnabled(true);
272 void GuiTabular::close_clicked()
279 void GuiTabular::borderSet_clicked()
281 set(Tabular::SET_ALL_LINES);
287 void GuiTabular::borderUnset_clicked()
289 set(Tabular::UNSET_ALL_LINES);
295 void GuiTabular::leftBorder_changed()
302 void GuiTabular::rightBorder_changed()
309 void GuiTabular::topBorder_changed()
316 void GuiTabular::bottomBorder_changed()
323 void GuiTabular::specialAlignment_changed()
325 string special = fromqstr(specialAlignmentED->text());
331 void GuiTabular::width_changed()
334 string const width = widgetsToLength(widthED, widthUnit);
339 void GuiTabular::multicolumn_clicked()
346 void GuiTabular::rotateTabular()
348 rotateTabular(rotateTabularCB->isChecked());
353 void GuiTabular::rotateCell()
355 rotateCell(rotateCellCB->isChecked());
360 void GuiTabular::hAlign_changed(int align)
362 GuiTabular::HALIGN h = GuiTabular::LEFT;
365 case 0: h = GuiTabular::LEFT; break;
366 case 1: h = GuiTabular::CENTER; break;
367 case 2: h = GuiTabular::RIGHT; break;
368 case 3: h = GuiTabular::BLOCK; break;
375 void GuiTabular::vAlign_changed(int align)
377 GuiTabular::VALIGN v = GuiTabular::TOP;
380 case 0: v = GuiTabular::TOP; break;
381 case 1: v = GuiTabular::MIDDLE; break;
382 case 2: v = GuiTabular::BOTTOM; break;
389 void GuiTabular::longTabular()
391 longTabular(longTabularCB->isChecked());
396 void GuiTabular::ltNewpage_clicked()
398 set(Tabular::SET_LTNEWPAGE);
403 void GuiTabular::ltHeaderStatus_clicked()
405 bool enable = headerStatusCB->isChecked();
407 set(Tabular::SET_LTHEAD, "");
409 set(Tabular::UNSET_LTHEAD, "");
410 headerBorderAboveCB->setEnabled(enable);
411 headerBorderBelowCB->setEnabled(enable);
412 firstheaderNoContentsCB->setEnabled(enable);
417 void GuiTabular::ltHeaderBorderAbove_clicked()
419 if (headerBorderAboveCB->isChecked())
420 set(Tabular::SET_LTHEAD, "dl_above");
422 set(Tabular::UNSET_LTHEAD, "dl_above");
427 void GuiTabular::ltHeaderBorderBelow_clicked()
429 if (headerBorderBelowCB->isChecked())
430 set(Tabular::SET_LTHEAD, "dl_below");
432 set(Tabular::UNSET_LTHEAD, "dl_below");
437 void GuiTabular::ltFirstHeaderBorderAbove_clicked()
439 if (firstheaderBorderAboveCB->isChecked())
440 set(Tabular::SET_LTFIRSTHEAD, "dl_above");
442 set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
447 void GuiTabular::ltFirstHeaderBorderBelow_clicked()
449 if (firstheaderBorderBelowCB->isChecked())
450 set(Tabular::SET_LTFIRSTHEAD, "dl_below");
452 set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
457 void GuiTabular::ltFirstHeaderStatus_clicked()
459 bool enable = firstheaderStatusCB->isChecked();
461 set(Tabular::SET_LTFIRSTHEAD, "");
463 set(Tabular::UNSET_LTFIRSTHEAD, "");
464 firstheaderBorderAboveCB->setEnabled(enable);
465 firstheaderBorderBelowCB->setEnabled(enable);
470 void GuiTabular::ltFirstHeaderEmpty_clicked()
472 bool enable = firstheaderNoContentsCB->isChecked();
474 set(Tabular::SET_LTFIRSTHEAD, "empty");
476 set(Tabular::UNSET_LTFIRSTHEAD, "empty");
477 firstheaderStatusCB->setEnabled(!enable);
478 firstheaderBorderAboveCB->setEnabled(!enable);
479 firstheaderBorderBelowCB->setEnabled(!enable);
484 void GuiTabular::ltFooterStatus_clicked()
486 bool enable = footerStatusCB->isChecked();
488 set(Tabular::SET_LTFOOT, "");
490 set(Tabular::UNSET_LTFOOT, "");
491 footerBorderAboveCB->setEnabled(enable);
492 footerBorderBelowCB->setEnabled(enable);
493 lastfooterNoContentsCB->setEnabled(enable);
498 void GuiTabular::ltFooterBorderAbove_clicked()
500 if (footerBorderAboveCB->isChecked())
501 set(Tabular::SET_LTFOOT, "dl_above");
503 set(Tabular::UNSET_LTFOOT, "dl_above");
508 void GuiTabular::ltFooterBorderBelow_clicked()
510 if (footerBorderBelowCB->isChecked())
511 set(Tabular::SET_LTFOOT, "dl_below");
513 set(Tabular::UNSET_LTFOOT, "dl_below");
518 void GuiTabular::ltLastFooterStatus_clicked()
520 bool enable = lastfooterStatusCB->isChecked();
522 set(Tabular::SET_LTLASTFOOT, "");
524 set(Tabular::UNSET_LTLASTFOOT, "");
525 lastfooterBorderAboveCB->setEnabled(enable);
526 lastfooterBorderBelowCB->setEnabled(enable);
531 void GuiTabular::ltLastFooterBorderAbove_clicked()
533 if (lastfooterBorderAboveCB->isChecked())
534 set(Tabular::SET_LTLASTFOOT, "dl_above");
536 set(Tabular::UNSET_LTLASTFOOT, "dl_above");
541 void GuiTabular::ltLastFooterBorderBelow_clicked()
543 if (lastfooterBorderBelowCB->isChecked())
544 set(Tabular::SET_LTLASTFOOT, "dl_below");
546 set(Tabular::UNSET_LTLASTFOOT, "dl_below");
551 void GuiTabular::ltLastFooterEmpty_clicked()
553 bool enable = lastfooterNoContentsCB->isChecked();
555 set(Tabular::SET_LTLASTFOOT, "empty");
557 set(Tabular::UNSET_LTLASTFOOT, "empty");
558 lastfooterStatusCB->setEnabled(!enable);
559 lastfooterBorderAboveCB->setEnabled(!enable);
560 lastfooterBorderBelowCB->setEnabled(!enable);
565 void GuiTabular::update_borders()
567 Tabular::idx_type const cell = getActiveCell();
568 bool const isMulticolumnCell = tabular_.isMultiColumn(cell);
570 if (!isMulticolumnCell) {
571 borders->setLeftEnabled(true);
572 borders->setRightEnabled(true);
573 borders->setTop(tabular_.topLine(cell, true));
574 borders->setBottom(tabular_.bottomLine(cell, true));
575 borders->setLeft(tabular_.leftLine(cell, true));
576 borders->setRight(tabular_.rightLine(cell, true));
577 // repaint the setborder widget
582 borders->setTop(tabular_.topLine(cell));
583 borders->setBottom(tabular_.bottomLine(cell));
584 // pay attention to left/right lines: they are only allowed
585 // to set if we are in first/last cell of row or if the left/right
586 // cell is also a multicolumn.
587 if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) {
588 borders->setLeftEnabled(true);
589 borders->setLeft(tabular_.leftLine(cell));
591 borders->setLeft(false);
592 borders->setLeftEnabled(false);
594 if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) {
595 borders->setRightEnabled(true);
596 borders->setRight(tabular_.rightLine(cell));
598 borders->setRight(false);
599 borders->setRightEnabled(false);
601 // repaint the setborder widget
606 void GuiTabular::updateContents()
608 initialiseParams(string());
610 Tabular::idx_type const cell = getActiveCell();
612 Tabular::row_type const row = tabular_.cellRow(cell);
613 Tabular::col_type const col = tabular_.cellColumn(cell);
615 tabularRowED->setText(QString::number(row + 1));
616 tabularColumnED->setText(QString::number(col + 1));
618 bool const multicol(tabular_.isMultiColumn(cell));
620 multicolumnCB->setChecked(multicol);
622 rotateCellCB->setChecked(tabular_.getRotateCell(cell));
623 rotateTabularCB->setChecked(tabular_.getRotateTabular());
625 longTabularCB->setChecked(tabular_.isLongTabular());
633 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
634 pwidth = tabular_.getMColumnPWidth(cell);
636 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
637 pwidth = tabular_.getColumnPWidth(cell);
640 specialAlignmentED->setText(toqstr(special));
642 bool const isReadonly = bc().policy().isReadOnly();
643 specialAlignmentED->setEnabled(!isReadonly);
645 Length::UNIT default_unit =
646 useMetricUnits() ? Length::CM : Length::IN;
648 borderDefaultRB->setChecked(!tabular_.useBookTabs());
649 booktabsRB->setChecked(tabular_.useBookTabs());
651 if (tabular_.row_info[row].top_space.empty()
652 && !tabular_.row_info[row].top_space_default) {
653 topspaceCO->setCurrentIndex(0);
654 } else if (tabular_.row_info[row].top_space_default) {
655 topspaceCO->setCurrentIndex(1);
657 topspaceCO->setCurrentIndex(2);
658 lengthToWidgets(topspaceED,
660 tabular_.row_info[row].top_space.asString(),
663 topspaceED->setEnabled(!isReadonly
664 && (topspaceCO->currentIndex() == 2));
665 topspaceUnit->setEnabled(!isReadonly
666 && (topspaceCO->currentIndex() == 2));
667 topspaceCO->setEnabled(!isReadonly);
669 if (tabular_.row_info[row].bottom_space.empty()
670 && !tabular_.row_info[row].bottom_space_default) {
671 bottomspaceCO->setCurrentIndex(0);
672 } else if (tabular_.row_info[row].bottom_space_default) {
673 bottomspaceCO->setCurrentIndex(1);
675 bottomspaceCO->setCurrentIndex(2);
676 lengthToWidgets(bottomspaceED,
678 tabular_.row_info[row].bottom_space.asString(),
681 bottomspaceED->setEnabled(!isReadonly
682 && (bottomspaceCO->currentIndex() == 2));
683 bottomspaceUnit->setEnabled(!isReadonly
684 && (bottomspaceCO->currentIndex() == 2));
685 bottomspaceCO->setEnabled(!isReadonly);
687 if (tabular_.row_info[row].interline_space.empty()
688 && !tabular_.row_info[row].interline_space_default) {
689 interlinespaceCO->setCurrentIndex(0);
690 } else if (tabular_.row_info[row].interline_space_default) {
691 interlinespaceCO->setCurrentIndex(1);
693 interlinespaceCO->setCurrentIndex(2);
694 lengthToWidgets(interlinespaceED,
696 tabular_.row_info[row].interline_space.asString(),
699 interlinespaceED->setEnabled(!isReadonly
700 && (interlinespaceCO->currentIndex() == 2));
701 interlinespaceUnit->setEnabled(!isReadonly
702 && (interlinespaceCO->currentIndex() == 2));
703 interlinespaceCO->setEnabled(!isReadonly);
707 colwidth = pwidth.asString();
708 lengthToWidgets(widthED, widthUnit,
709 colwidth, default_unit);
711 widthED->setEnabled(!isReadonly);
712 widthUnit->setEnabled(!isReadonly);
715 hAlignCB->addItem(qt_("Left"));
716 hAlignCB->addItem(qt_("Center"));
717 hAlignCB->addItem(qt_("Right"));
718 if (!multicol && !pwidth.zero())
719 hAlignCB->addItem(qt_("Justified"));
722 switch (tabular_.getAlignment(cell)) {
726 case LYX_ALIGN_CENTER:
729 case LYX_ALIGN_RIGHT:
732 case LYX_ALIGN_BLOCK:
734 if (!multicol && !pwidth.zero())
742 hAlignCB->setCurrentIndex(align);
745 switch (tabular_.getVAlignment(cell)) {
746 case Tabular::LYX_VALIGN_TOP:
749 case Tabular::LYX_VALIGN_MIDDLE:
752 case Tabular::LYX_VALIGN_BOTTOM:
761 vAlignCB->setCurrentIndex(valign);
763 hAlignCB->setEnabled(true);
764 vAlignCB->setEnabled(!pwidth.zero());
766 if (!tabular_.isLongTabular()) {
767 headerStatusCB->setChecked(false);
768 headerBorderAboveCB->setChecked(false);
769 headerBorderBelowCB->setChecked(false);
770 firstheaderStatusCB->setChecked(false);
771 firstheaderBorderAboveCB->setChecked(false);
772 firstheaderBorderBelowCB->setChecked(false);
773 firstheaderNoContentsCB->setChecked(false);
774 footerStatusCB->setChecked(false);
775 footerBorderAboveCB->setChecked(false);
776 footerBorderBelowCB->setChecked(false);
777 lastfooterStatusCB->setChecked(false);
778 lastfooterBorderAboveCB->setChecked(false);
779 lastfooterBorderBelowCB->setChecked(false);
780 lastfooterNoContentsCB->setChecked(false);
781 newpageCB->setChecked(false);
782 newpageCB->setEnabled(false);
788 bool row_set = tabular_.getRowOfLTHead(row, ltt);
789 headerStatusCB->setChecked(row_set);
791 headerBorderAboveCB->setChecked(ltt.topDL);
792 headerBorderBelowCB->setChecked(ltt.bottomDL);
795 headerBorderAboveCB->setChecked(false);
796 headerBorderBelowCB->setChecked(false);
797 headerBorderAboveCB->setEnabled(false);
798 headerBorderBelowCB->setEnabled(false);
799 firstheaderNoContentsCB->setChecked(false);
800 firstheaderNoContentsCB->setEnabled(false);
804 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
805 firstheaderStatusCB->setChecked(row_set);
806 if (ltt.set && (!ltt.empty || !use_empty)) {
807 firstheaderBorderAboveCB->setChecked(ltt.topDL);
808 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
810 firstheaderBorderAboveCB->setEnabled(false);
811 firstheaderBorderBelowCB->setEnabled(false);
812 firstheaderBorderAboveCB->setChecked(false);
813 firstheaderBorderBelowCB->setChecked(false);
815 firstheaderNoContentsCB->setChecked(ltt.empty);
817 firstheaderStatusCB->setEnabled(false);
821 row_set = tabular_.getRowOfLTFoot(row, ltt);
822 footerStatusCB->setChecked(row_set);
824 footerBorderAboveCB->setChecked(ltt.topDL);
825 footerBorderBelowCB->setChecked(ltt.bottomDL);
828 footerBorderAboveCB->setChecked(false);
829 footerBorderBelowCB->setChecked(false);
830 footerBorderAboveCB->setEnabled(false);
831 footerBorderBelowCB->setEnabled(false);
832 lastfooterNoContentsCB->setChecked(false);
833 lastfooterNoContentsCB->setEnabled(false);
837 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
838 lastfooterStatusCB->setChecked(row_set);
839 if (ltt.set && (!ltt.empty || !use_empty)) {
840 lastfooterBorderAboveCB->setChecked(ltt.topDL);
841 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
843 lastfooterBorderAboveCB->setEnabled(false);
844 lastfooterBorderBelowCB->setEnabled(false);
845 lastfooterBorderAboveCB->setChecked(false);
846 lastfooterBorderBelowCB->setChecked(false);
848 lastfooterNoContentsCB->setChecked(ltt.empty);
850 lastfooterStatusCB->setEnabled(false);
853 newpageCB->setChecked(tabular_.getLTNewPage(row));
857 void GuiTabular::closeGUI()
859 // ugly hack to auto-apply the stuff that hasn't been
860 // yet. don't let this continue to exist ...
862 // Subtle here, we must /not/ apply any changes and
863 // then refer to tabular, as it will have been freed
864 // since the changes update the actual tabular_
866 // apply the fixed width values
867 Tabular::idx_type const cell = getActiveCell();
868 bool const multicol = tabular_.isMultiColumn(cell);
869 string width = widgetsToLength(widthED, widthUnit);
872 Length llen = tabular_.getColumnPWidth(cell);
873 Length llenMulti = tabular_.getMColumnPWidth(cell);
875 if (multicol && !llenMulti.zero())
876 width2 = llenMulti.asString();
877 else if (!multicol && !llen.zero())
878 width2 = llen.asString();
880 // apply the special alignment
881 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
885 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
887 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
891 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
893 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
896 if (width != width2) {
898 set(Tabular::SET_MPWIDTH, width);
900 set(Tabular::SET_PWIDTH, width);
904 switch (topspaceCO->currentIndex()) {
906 set(Tabular::SET_TOP_SPACE, "");
909 set(Tabular::SET_TOP_SPACE, "default");
912 set(Tabular::SET_TOP_SPACE,
913 widgetsToLength(topspaceED, topspaceUnit));
917 switch (bottomspaceCO->currentIndex()) {
919 set(Tabular::SET_BOTTOM_SPACE, "");
922 set(Tabular::SET_BOTTOM_SPACE, "default");
925 set(Tabular::SET_BOTTOM_SPACE,
926 widgetsToLength(bottomspaceED, bottomspaceUnit));
930 switch (interlinespaceCO->currentIndex()) {
932 set(Tabular::SET_INTERLINE_SPACE, "");
935 set(Tabular::SET_INTERLINE_SPACE, "default");
938 set(Tabular::SET_INTERLINE_SPACE,
939 widgetsToLength(interlinespaceED, interlinespaceUnit));
945 bool GuiTabular::initialiseParams(string const & data)
947 // try to get the current cell
948 BufferView const * const bv = bufferview();
949 InsetTabular const * current_inset = 0;
951 Cursor const & cur = bv->cursor();
952 // get the innermost tabular inset;
953 // assume that it is "ours"
954 for (int i = cur.depth() - 1; i >= 0; --i)
955 if (cur[i].inset().lyxCode() == Inset::TABULAR_CODE) {
956 current_inset = static_cast<InsetTabular const *>(&cur[i].inset());
957 active_cell_ = cur[i].idx();
962 if (current_inset && data.empty()) {
963 tabular_ = Tabular(current_inset->tabular);
967 InsetTabular tmp(buffer());
968 InsetTabularMailer::string2params(data, tmp);
969 tabular_ = Tabular(tmp.tabular);
974 void GuiTabular::clearParams()
976 InsetTabular tmp(buffer());
977 tabular_ = tmp.tabular;
978 active_cell_ = Tabular::npos;
982 Tabular::idx_type GuiTabular::getActiveCell() const
988 void GuiTabular::set(Tabular::Feature f, string const & arg)
990 string const data = featureAsString(f) + ' ' + arg;
991 dispatch(FuncRequest(getLfun(), data));
995 bool GuiTabular::useMetricUnits() const
997 return lyxrc.default_papersize > PAPER_USEXECUTIVE;
1001 void GuiTabular::toggleTopLine()
1003 if (tabular_.isMultiColumn(getActiveCell()))
1004 set(Tabular::M_TOGGLE_LINE_TOP);
1006 set(Tabular::TOGGLE_LINE_TOP);
1010 void GuiTabular::toggleBottomLine()
1012 if (tabular_.isMultiColumn(getActiveCell()))
1013 set(Tabular::M_TOGGLE_LINE_BOTTOM);
1015 set(Tabular::TOGGLE_LINE_BOTTOM);
1019 void GuiTabular::toggleLeftLine()
1021 if (tabular_.isMultiColumn(getActiveCell()))
1022 set(Tabular::M_TOGGLE_LINE_LEFT);
1024 set(Tabular::TOGGLE_LINE_LEFT);
1028 void GuiTabular::toggleRightLine()
1030 if (tabular_.isMultiColumn(getActiveCell()))
1031 set(Tabular::M_TOGGLE_LINE_RIGHT);
1033 set(Tabular::TOGGLE_LINE_RIGHT);
1037 void GuiTabular::setSpecial(string const & special)
1039 if (tabular_.isMultiColumn(getActiveCell()))
1040 set(Tabular::SET_SPECIAL_MULTI, special);
1042 set(Tabular::SET_SPECIAL_COLUMN, special);
1046 void GuiTabular::setWidth(string const & width)
1048 if (tabular_.isMultiColumn(getActiveCell()))
1049 set(Tabular::SET_MPWIDTH, width);
1051 set(Tabular::SET_PWIDTH, width);
1053 dialog().updateView();
1057 void GuiTabular::toggleMultiColumn()
1059 set(Tabular::MULTICOLUMN);
1060 dialog().updateView();
1064 void GuiTabular::rotateTabular(bool yes)
1067 set(Tabular::SET_ROTATE_TABULAR);
1069 set(Tabular::UNSET_ROTATE_TABULAR);
1073 void GuiTabular::rotateCell(bool yes)
1076 set(Tabular::SET_ROTATE_CELL);
1078 set(Tabular::UNSET_ROTATE_CELL);
1082 void GuiTabular::halign(GuiTabular::HALIGN h)
1084 Tabular::Feature num = Tabular::ALIGN_LEFT;
1085 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
1089 num = Tabular::ALIGN_LEFT;
1090 multi_num = Tabular::M_ALIGN_LEFT;
1093 num = Tabular::ALIGN_CENTER;
1094 multi_num = Tabular::M_ALIGN_CENTER;
1097 num = Tabular::ALIGN_RIGHT;
1098 multi_num = Tabular::M_ALIGN_RIGHT;
1101 num = Tabular::ALIGN_BLOCK;
1102 //multi_num: no equivalent
1106 if (tabular_.isMultiColumn(getActiveCell()))
1113 void GuiTabular::valign(GuiTabular::VALIGN v)
1115 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
1116 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
1120 num = Tabular::VALIGN_TOP;
1121 multi_num = Tabular::M_VALIGN_TOP;
1124 num = Tabular::VALIGN_MIDDLE;
1125 multi_num = Tabular::M_VALIGN_MIDDLE;
1128 num = Tabular::VALIGN_BOTTOM;
1129 multi_num = Tabular::M_VALIGN_BOTTOM;
1133 if (tabular_.isMultiColumn(getActiveCell()))
1140 void GuiTabular::booktabs(bool yes)
1143 set(Tabular::SET_BOOKTABS);
1145 set(Tabular::UNSET_BOOKTABS);
1149 void GuiTabular::longTabular(bool yes)
1152 set(Tabular::SET_LONGTABULAR);
1154 set(Tabular::UNSET_LONGTABULAR);
1158 Dialog * createGuiTabular(LyXView & lv) { return new GuiTabular(lv); }
1161 } // namespace frontend
1164 #include "GuiTabular_moc.cpp"