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(GuiView & lv)
41 : GuiDialog(lv, "tabular")
43 active_cell_ = Tabular::npos;
46 setViewTitle(_("Table Settings"));
48 widthED->setValidator(unsignedLengthValidator(widthED));
49 topspaceED->setValidator(new LengthValidator(topspaceED));
50 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
51 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
53 connect(topspaceED, SIGNAL(returnPressed()),
54 this, SLOT(topspace_changed()));
55 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
56 this, SLOT(topspace_changed()));
57 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
58 connect(bottomspaceED, SIGNAL(returnPressed()),
59 this, SLOT(bottomspace_changed()));
60 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
61 this, SLOT(bottomspace_changed()));
62 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
63 connect(interlinespaceED, SIGNAL(returnPressed()),
64 this, SLOT(interlinespace_changed()));
65 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
66 this, SLOT(interlinespace_changed()));
67 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
68 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
69 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
70 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
71 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
72 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
73 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
74 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
75 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
76 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
77 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
78 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
79 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
80 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
81 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
82 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
83 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
84 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
85 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
86 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
87 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
88 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
89 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
90 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
91 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
92 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
93 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
94 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
95 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
96 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
97 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
98 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
99 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
100 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
101 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
102 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
104 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
105 bc().setCancel(closePB);
107 bc().addReadOnly(topspaceED);
108 bc().addReadOnly(topspaceUnit);
109 bc().addReadOnly(topspaceCO);
110 bc().addReadOnly(bottomspaceED);
111 bc().addReadOnly(bottomspaceUnit);
112 bc().addReadOnly(bottomspaceCO);
113 bc().addReadOnly(interlinespaceED);
114 bc().addReadOnly(interlinespaceUnit);
115 bc().addReadOnly(interlinespaceCO);
116 bc().addReadOnly(borderDefaultRB);
117 bc().addReadOnly(booktabsRB);
119 bc().addReadOnly(multicolumnCB);
120 bc().addReadOnly(rotateCellCB);
121 bc().addReadOnly(rotateTabularCB);
122 bc().addReadOnly(specialAlignmentED);
123 bc().addReadOnly(widthED);
124 bc().addReadOnly(widthUnit);
125 bc().addReadOnly(hAlignCB);
126 bc().addReadOnly(vAlignCB);
127 bc().addReadOnly(borderSetPB);
128 bc().addReadOnly(borderUnsetPB);
129 bc().addReadOnly(borders);
130 bc().addReadOnly(longTabularCB);
131 bc().addReadOnly(headerStatusCB);
132 bc().addReadOnly(headerBorderAboveCB);
133 bc().addReadOnly(headerBorderBelowCB);
134 bc().addReadOnly(firstheaderStatusCB);
135 bc().addReadOnly(firstheaderBorderAboveCB);
136 bc().addReadOnly(firstheaderBorderBelowCB);
137 bc().addReadOnly(firstheaderNoContentsCB);
138 bc().addReadOnly(footerStatusCB);
139 bc().addReadOnly(footerBorderAboveCB);
140 bc().addReadOnly(footerBorderBelowCB);
141 bc().addReadOnly(lastfooterStatusCB);
142 bc().addReadOnly(lastfooterBorderAboveCB);
143 bc().addReadOnly(lastfooterBorderBelowCB);
144 bc().addReadOnly(lastfooterNoContentsCB);
145 bc().addReadOnly(newpageCB);
147 // initialize the length validator
148 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
149 bc().addCheckedLineEdit(topspaceED, topspaceLA);
150 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
151 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
155 GuiTabular::~GuiTabular()
160 void GuiTabular::change_adaptor()
166 void GuiTabular::closeEvent(QCloseEvent * e)
169 GuiDialog::closeEvent(e);
173 void GuiTabular::booktabsChanged(bool)
176 booktabs(booktabsRB->isChecked());
181 void GuiTabular::topspace_changed()
183 switch (topspaceCO->currentIndex()) {
185 set(Tabular::SET_TOP_SPACE, "");
186 topspaceED->setEnabled(false);
187 topspaceUnit->setEnabled(false);
191 set(Tabular::SET_TOP_SPACE, "default");
192 topspaceED->setEnabled(false);
193 topspaceUnit->setEnabled(false);
197 if (!topspaceED->text().isEmpty())
198 set(Tabular::SET_TOP_SPACE,
199 widgetsToLength(topspaceED, topspaceUnit));
200 if (!bc().policy().isReadOnly()) {
201 topspaceED->setEnabled(true);
202 topspaceUnit->setEnabled(true);
211 void GuiTabular::bottomspace_changed()
213 switch (bottomspaceCO->currentIndex()) {
215 set(Tabular::SET_BOTTOM_SPACE, "");
216 bottomspaceED->setEnabled(false);
217 bottomspaceUnit->setEnabled(false);
221 set(Tabular::SET_BOTTOM_SPACE, "default");
222 bottomspaceED->setEnabled(false);
223 bottomspaceUnit->setEnabled(false);
227 if (!bottomspaceED->text().isEmpty())
228 set(Tabular::SET_BOTTOM_SPACE,
229 widgetsToLength(bottomspaceED, bottomspaceUnit));
230 if (!bc().policy().isReadOnly()) {
231 bottomspaceED->setEnabled(true);
232 bottomspaceUnit->setEnabled(true);
241 void GuiTabular::interlinespace_changed()
243 switch (interlinespaceCO->currentIndex()) {
245 set(Tabular::SET_INTERLINE_SPACE, "");
246 interlinespaceED->setEnabled(false);
247 interlinespaceUnit->setEnabled(false);
251 set(Tabular::SET_INTERLINE_SPACE, "default");
252 interlinespaceED->setEnabled(false);
253 interlinespaceUnit->setEnabled(false);
257 if (!interlinespaceED->text().isEmpty())
258 set(Tabular::SET_INTERLINE_SPACE,
259 widgetsToLength(interlinespaceED, interlinespaceUnit));
260 if (!bc().policy().isReadOnly()) {
261 interlinespaceED->setEnabled(true);
262 interlinespaceUnit->setEnabled(true);
271 void GuiTabular::close_clicked()
278 void GuiTabular::borderSet_clicked()
280 set(Tabular::SET_ALL_LINES);
286 void GuiTabular::borderUnset_clicked()
288 set(Tabular::UNSET_ALL_LINES);
294 void GuiTabular::leftBorder_changed()
301 void GuiTabular::rightBorder_changed()
308 void GuiTabular::topBorder_changed()
315 void GuiTabular::bottomBorder_changed()
322 void GuiTabular::specialAlignment_changed()
324 string special = fromqstr(specialAlignmentED->text());
330 void GuiTabular::width_changed()
333 string const width = widgetsToLength(widthED, widthUnit);
338 void GuiTabular::multicolumn_clicked()
345 void GuiTabular::rotateTabular()
347 rotateTabular(rotateTabularCB->isChecked());
352 void GuiTabular::rotateCell()
354 rotateCell(rotateCellCB->isChecked());
359 void GuiTabular::hAlign_changed(int align)
361 GuiTabular::HALIGN h = GuiTabular::LEFT;
364 case 0: h = GuiTabular::LEFT; break;
365 case 1: h = GuiTabular::CENTER; break;
366 case 2: h = GuiTabular::RIGHT; break;
367 case 3: h = GuiTabular::BLOCK; break;
374 void GuiTabular::vAlign_changed(int align)
376 GuiTabular::VALIGN v = GuiTabular::TOP;
379 case 0: v = GuiTabular::TOP; break;
380 case 1: v = GuiTabular::MIDDLE; break;
381 case 2: v = GuiTabular::BOTTOM; break;
388 void GuiTabular::longTabular()
390 longTabular(longTabularCB->isChecked());
395 void GuiTabular::ltNewpage_clicked()
397 set(Tabular::SET_LTNEWPAGE);
402 void GuiTabular::ltHeaderStatus_clicked()
404 bool enable = headerStatusCB->isChecked();
406 set(Tabular::SET_LTHEAD, "");
408 set(Tabular::UNSET_LTHEAD, "");
409 headerBorderAboveCB->setEnabled(enable);
410 headerBorderBelowCB->setEnabled(enable);
411 firstheaderNoContentsCB->setEnabled(enable);
416 void GuiTabular::ltHeaderBorderAbove_clicked()
418 if (headerBorderAboveCB->isChecked())
419 set(Tabular::SET_LTHEAD, "dl_above");
421 set(Tabular::UNSET_LTHEAD, "dl_above");
426 void GuiTabular::ltHeaderBorderBelow_clicked()
428 if (headerBorderBelowCB->isChecked())
429 set(Tabular::SET_LTHEAD, "dl_below");
431 set(Tabular::UNSET_LTHEAD, "dl_below");
436 void GuiTabular::ltFirstHeaderBorderAbove_clicked()
438 if (firstheaderBorderAboveCB->isChecked())
439 set(Tabular::SET_LTFIRSTHEAD, "dl_above");
441 set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
446 void GuiTabular::ltFirstHeaderBorderBelow_clicked()
448 if (firstheaderBorderBelowCB->isChecked())
449 set(Tabular::SET_LTFIRSTHEAD, "dl_below");
451 set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
456 void GuiTabular::ltFirstHeaderStatus_clicked()
458 bool enable = firstheaderStatusCB->isChecked();
460 set(Tabular::SET_LTFIRSTHEAD, "");
462 set(Tabular::UNSET_LTFIRSTHEAD, "");
463 firstheaderBorderAboveCB->setEnabled(enable);
464 firstheaderBorderBelowCB->setEnabled(enable);
469 void GuiTabular::ltFirstHeaderEmpty_clicked()
471 bool enable = firstheaderNoContentsCB->isChecked();
473 set(Tabular::SET_LTFIRSTHEAD, "empty");
475 set(Tabular::UNSET_LTFIRSTHEAD, "empty");
476 firstheaderStatusCB->setEnabled(!enable);
477 firstheaderBorderAboveCB->setEnabled(!enable);
478 firstheaderBorderBelowCB->setEnabled(!enable);
483 void GuiTabular::ltFooterStatus_clicked()
485 bool enable = footerStatusCB->isChecked();
487 set(Tabular::SET_LTFOOT, "");
489 set(Tabular::UNSET_LTFOOT, "");
490 footerBorderAboveCB->setEnabled(enable);
491 footerBorderBelowCB->setEnabled(enable);
492 lastfooterNoContentsCB->setEnabled(enable);
497 void GuiTabular::ltFooterBorderAbove_clicked()
499 if (footerBorderAboveCB->isChecked())
500 set(Tabular::SET_LTFOOT, "dl_above");
502 set(Tabular::UNSET_LTFOOT, "dl_above");
507 void GuiTabular::ltFooterBorderBelow_clicked()
509 if (footerBorderBelowCB->isChecked())
510 set(Tabular::SET_LTFOOT, "dl_below");
512 set(Tabular::UNSET_LTFOOT, "dl_below");
517 void GuiTabular::ltLastFooterStatus_clicked()
519 bool enable = lastfooterStatusCB->isChecked();
521 set(Tabular::SET_LTLASTFOOT, "");
523 set(Tabular::UNSET_LTLASTFOOT, "");
524 lastfooterBorderAboveCB->setEnabled(enable);
525 lastfooterBorderBelowCB->setEnabled(enable);
530 void GuiTabular::ltLastFooterBorderAbove_clicked()
532 if (lastfooterBorderAboveCB->isChecked())
533 set(Tabular::SET_LTLASTFOOT, "dl_above");
535 set(Tabular::UNSET_LTLASTFOOT, "dl_above");
540 void GuiTabular::ltLastFooterBorderBelow_clicked()
542 if (lastfooterBorderBelowCB->isChecked())
543 set(Tabular::SET_LTLASTFOOT, "dl_below");
545 set(Tabular::UNSET_LTLASTFOOT, "dl_below");
550 void GuiTabular::ltLastFooterEmpty_clicked()
552 bool enable = lastfooterNoContentsCB->isChecked();
554 set(Tabular::SET_LTLASTFOOT, "empty");
556 set(Tabular::UNSET_LTLASTFOOT, "empty");
557 lastfooterStatusCB->setEnabled(!enable);
558 lastfooterBorderAboveCB->setEnabled(!enable);
559 lastfooterBorderBelowCB->setEnabled(!enable);
564 void GuiTabular::update_borders()
566 Tabular::idx_type const cell = getActiveCell();
567 bool const isMulticolumnCell = tabular_.isMultiColumn(cell);
569 if (!isMulticolumnCell) {
570 borders->setLeftEnabled(true);
571 borders->setRightEnabled(true);
572 borders->setTop(tabular_.topLine(cell, true));
573 borders->setBottom(tabular_.bottomLine(cell, true));
574 borders->setLeft(tabular_.leftLine(cell, true));
575 borders->setRight(tabular_.rightLine(cell, true));
576 // repaint the setborder widget
581 borders->setTop(tabular_.topLine(cell));
582 borders->setBottom(tabular_.bottomLine(cell));
583 // pay attention to left/right lines: they are only allowed
584 // to set if we are in first/last cell of row or if the left/right
585 // cell is also a multicolumn.
586 if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) {
587 borders->setLeftEnabled(true);
588 borders->setLeft(tabular_.leftLine(cell));
590 borders->setLeft(false);
591 borders->setLeftEnabled(false);
593 if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) {
594 borders->setRightEnabled(true);
595 borders->setRight(tabular_.rightLine(cell));
597 borders->setRight(false);
598 borders->setRightEnabled(false);
600 // repaint the setborder widget
605 void GuiTabular::updateContents()
607 initialiseParams(string());
609 Tabular::idx_type const cell = getActiveCell();
611 Tabular::row_type const row = tabular_.cellRow(cell);
612 Tabular::col_type const col = tabular_.cellColumn(cell);
614 tabularRowED->setText(QString::number(row + 1));
615 tabularColumnED->setText(QString::number(col + 1));
617 bool const multicol(tabular_.isMultiColumn(cell));
619 multicolumnCB->setChecked(multicol);
621 rotateCellCB->setChecked(tabular_.getRotateCell(cell));
622 rotateTabularCB->setChecked(tabular_.getRotateTabular());
624 longTabularCB->setChecked(tabular_.isLongTabular());
632 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
633 pwidth = tabular_.getMColumnPWidth(cell);
635 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
636 pwidth = tabular_.getColumnPWidth(cell);
639 specialAlignmentED->setText(toqstr(special));
641 bool const isReadonly = bc().policy().isReadOnly();
642 specialAlignmentED->setEnabled(!isReadonly);
644 Length::UNIT default_unit =
645 useMetricUnits() ? Length::CM : Length::IN;
647 borderDefaultRB->setChecked(!tabular_.useBookTabs());
648 booktabsRB->setChecked(tabular_.useBookTabs());
650 if (tabular_.row_info[row].top_space.empty()
651 && !tabular_.row_info[row].top_space_default) {
652 topspaceCO->setCurrentIndex(0);
653 } else if (tabular_.row_info[row].top_space_default) {
654 topspaceCO->setCurrentIndex(1);
656 topspaceCO->setCurrentIndex(2);
657 lengthToWidgets(topspaceED,
659 tabular_.row_info[row].top_space.asString(),
662 topspaceED->setEnabled(!isReadonly
663 && (topspaceCO->currentIndex() == 2));
664 topspaceUnit->setEnabled(!isReadonly
665 && (topspaceCO->currentIndex() == 2));
666 topspaceCO->setEnabled(!isReadonly);
668 if (tabular_.row_info[row].bottom_space.empty()
669 && !tabular_.row_info[row].bottom_space_default) {
670 bottomspaceCO->setCurrentIndex(0);
671 } else if (tabular_.row_info[row].bottom_space_default) {
672 bottomspaceCO->setCurrentIndex(1);
674 bottomspaceCO->setCurrentIndex(2);
675 lengthToWidgets(bottomspaceED,
677 tabular_.row_info[row].bottom_space.asString(),
680 bottomspaceED->setEnabled(!isReadonly
681 && (bottomspaceCO->currentIndex() == 2));
682 bottomspaceUnit->setEnabled(!isReadonly
683 && (bottomspaceCO->currentIndex() == 2));
684 bottomspaceCO->setEnabled(!isReadonly);
686 if (tabular_.row_info[row].interline_space.empty()
687 && !tabular_.row_info[row].interline_space_default) {
688 interlinespaceCO->setCurrentIndex(0);
689 } else if (tabular_.row_info[row].interline_space_default) {
690 interlinespaceCO->setCurrentIndex(1);
692 interlinespaceCO->setCurrentIndex(2);
693 lengthToWidgets(interlinespaceED,
695 tabular_.row_info[row].interline_space.asString(),
698 interlinespaceED->setEnabled(!isReadonly
699 && (interlinespaceCO->currentIndex() == 2));
700 interlinespaceUnit->setEnabled(!isReadonly
701 && (interlinespaceCO->currentIndex() == 2));
702 interlinespaceCO->setEnabled(!isReadonly);
706 colwidth = pwidth.asString();
707 lengthToWidgets(widthED, widthUnit,
708 colwidth, default_unit);
710 widthED->setEnabled(!isReadonly);
711 widthUnit->setEnabled(!isReadonly);
714 hAlignCB->addItem(qt_("Left"));
715 hAlignCB->addItem(qt_("Center"));
716 hAlignCB->addItem(qt_("Right"));
717 if (!multicol && !pwidth.zero())
718 hAlignCB->addItem(qt_("Justified"));
721 switch (tabular_.getAlignment(cell)) {
725 case LYX_ALIGN_CENTER:
728 case LYX_ALIGN_RIGHT:
731 case LYX_ALIGN_BLOCK:
733 if (!multicol && !pwidth.zero())
741 hAlignCB->setCurrentIndex(align);
744 switch (tabular_.getVAlignment(cell)) {
745 case Tabular::LYX_VALIGN_TOP:
748 case Tabular::LYX_VALIGN_MIDDLE:
751 case Tabular::LYX_VALIGN_BOTTOM:
760 vAlignCB->setCurrentIndex(valign);
762 hAlignCB->setEnabled(true);
763 vAlignCB->setEnabled(!pwidth.zero());
765 if (!tabular_.isLongTabular()) {
766 headerStatusCB->setChecked(false);
767 headerBorderAboveCB->setChecked(false);
768 headerBorderBelowCB->setChecked(false);
769 firstheaderStatusCB->setChecked(false);
770 firstheaderBorderAboveCB->setChecked(false);
771 firstheaderBorderBelowCB->setChecked(false);
772 firstheaderNoContentsCB->setChecked(false);
773 footerStatusCB->setChecked(false);
774 footerBorderAboveCB->setChecked(false);
775 footerBorderBelowCB->setChecked(false);
776 lastfooterStatusCB->setChecked(false);
777 lastfooterBorderAboveCB->setChecked(false);
778 lastfooterBorderBelowCB->setChecked(false);
779 lastfooterNoContentsCB->setChecked(false);
780 newpageCB->setChecked(false);
781 newpageCB->setEnabled(false);
787 bool row_set = tabular_.getRowOfLTHead(row, ltt);
788 headerStatusCB->setChecked(row_set);
790 headerBorderAboveCB->setChecked(ltt.topDL);
791 headerBorderBelowCB->setChecked(ltt.bottomDL);
794 headerBorderAboveCB->setChecked(false);
795 headerBorderBelowCB->setChecked(false);
796 headerBorderAboveCB->setEnabled(false);
797 headerBorderBelowCB->setEnabled(false);
798 firstheaderNoContentsCB->setChecked(false);
799 firstheaderNoContentsCB->setEnabled(false);
803 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
804 firstheaderStatusCB->setChecked(row_set);
805 if (ltt.set && (!ltt.empty || !use_empty)) {
806 firstheaderBorderAboveCB->setChecked(ltt.topDL);
807 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
809 firstheaderBorderAboveCB->setEnabled(false);
810 firstheaderBorderBelowCB->setEnabled(false);
811 firstheaderBorderAboveCB->setChecked(false);
812 firstheaderBorderBelowCB->setChecked(false);
814 firstheaderNoContentsCB->setChecked(ltt.empty);
816 firstheaderStatusCB->setEnabled(false);
820 row_set = tabular_.getRowOfLTFoot(row, ltt);
821 footerStatusCB->setChecked(row_set);
823 footerBorderAboveCB->setChecked(ltt.topDL);
824 footerBorderBelowCB->setChecked(ltt.bottomDL);
827 footerBorderAboveCB->setChecked(false);
828 footerBorderBelowCB->setChecked(false);
829 footerBorderAboveCB->setEnabled(false);
830 footerBorderBelowCB->setEnabled(false);
831 lastfooterNoContentsCB->setChecked(false);
832 lastfooterNoContentsCB->setEnabled(false);
836 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
837 lastfooterStatusCB->setChecked(row_set);
838 if (ltt.set && (!ltt.empty || !use_empty)) {
839 lastfooterBorderAboveCB->setChecked(ltt.topDL);
840 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
842 lastfooterBorderAboveCB->setEnabled(false);
843 lastfooterBorderBelowCB->setEnabled(false);
844 lastfooterBorderAboveCB->setChecked(false);
845 lastfooterBorderBelowCB->setChecked(false);
847 lastfooterNoContentsCB->setChecked(ltt.empty);
849 lastfooterStatusCB->setEnabled(false);
852 newpageCB->setChecked(tabular_.getLTNewPage(row));
856 void GuiTabular::closeGUI()
858 // ugly hack to auto-apply the stuff that hasn't been
859 // yet. don't let this continue to exist ...
861 // Subtle here, we must /not/ apply any changes and
862 // then refer to tabular, as it will have been freed
863 // since the changes update the actual tabular_
865 // apply the fixed width values
866 Tabular::idx_type const cell = getActiveCell();
867 bool const multicol = tabular_.isMultiColumn(cell);
868 string width = widgetsToLength(widthED, widthUnit);
871 Length llen = tabular_.getColumnPWidth(cell);
872 Length llenMulti = tabular_.getMColumnPWidth(cell);
874 if (multicol && !llenMulti.zero())
875 width2 = llenMulti.asString();
876 else if (!multicol && !llen.zero())
877 width2 = llen.asString();
879 // apply the special alignment
880 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
884 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
886 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
890 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
892 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
895 if (width != width2) {
897 set(Tabular::SET_MPWIDTH, width);
899 set(Tabular::SET_PWIDTH, width);
903 switch (topspaceCO->currentIndex()) {
905 set(Tabular::SET_TOP_SPACE, "");
908 set(Tabular::SET_TOP_SPACE, "default");
911 set(Tabular::SET_TOP_SPACE,
912 widgetsToLength(topspaceED, topspaceUnit));
916 switch (bottomspaceCO->currentIndex()) {
918 set(Tabular::SET_BOTTOM_SPACE, "");
921 set(Tabular::SET_BOTTOM_SPACE, "default");
924 set(Tabular::SET_BOTTOM_SPACE,
925 widgetsToLength(bottomspaceED, bottomspaceUnit));
929 switch (interlinespaceCO->currentIndex()) {
931 set(Tabular::SET_INTERLINE_SPACE, "");
934 set(Tabular::SET_INTERLINE_SPACE, "default");
937 set(Tabular::SET_INTERLINE_SPACE,
938 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() == 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);
1057 void GuiTabular::toggleMultiColumn()
1059 set(Tabular::MULTICOLUMN);
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(GuiView & lv) { return new GuiTabular(lv); }
1161 } // namespace frontend
1164 #include "GuiTabular_moc.cpp"