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 "GuiSetBorder.h"
19 #include "LengthCombo.h"
20 #include "qt_helpers.h"
21 #include "Validator.h"
23 #include "BufferView.h"
25 #include "FuncRequest.h"
27 #include "insets/InsetTabular.h"
30 #include <QPushButton>
31 #include <QRadioButton>
39 GuiTabular::GuiTabular(GuiView & lv)
40 : GuiDialog(lv, "tabular", qt_("Table Settings")),
41 // tabular_ is initialised at dialog construction in initialiseParams()
42 tabular_(*lv.buffer(), 0, 0)
44 active_cell_ = Tabular::npos;
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(editingFinished()), 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::IgnorantPolicy);
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::booktabsChanged(bool)
168 booktabs(booktabsRB->isChecked());
173 void GuiTabular::topspace_changed()
175 switch (topspaceCO->currentIndex()) {
177 set(Tabular::SET_TOP_SPACE, "");
178 topspaceED->setEnabled(false);
179 topspaceUnit->setEnabled(false);
183 set(Tabular::SET_TOP_SPACE, "default");
184 topspaceED->setEnabled(false);
185 topspaceUnit->setEnabled(false);
189 if (!topspaceED->text().isEmpty())
190 set(Tabular::SET_TOP_SPACE,
191 widgetsToLength(topspaceED, topspaceUnit));
192 if (!bc().policy().isReadOnly()) {
193 topspaceED->setEnabled(true);
194 topspaceUnit->setEnabled(true);
203 void GuiTabular::bottomspace_changed()
205 switch (bottomspaceCO->currentIndex()) {
207 set(Tabular::SET_BOTTOM_SPACE, "");
208 bottomspaceED->setEnabled(false);
209 bottomspaceUnit->setEnabled(false);
213 set(Tabular::SET_BOTTOM_SPACE, "default");
214 bottomspaceED->setEnabled(false);
215 bottomspaceUnit->setEnabled(false);
219 if (!bottomspaceED->text().isEmpty())
220 set(Tabular::SET_BOTTOM_SPACE,
221 widgetsToLength(bottomspaceED, bottomspaceUnit));
222 if (!bc().policy().isReadOnly()) {
223 bottomspaceED->setEnabled(true);
224 bottomspaceUnit->setEnabled(true);
233 void GuiTabular::interlinespace_changed()
235 switch (interlinespaceCO->currentIndex()) {
237 set(Tabular::SET_INTERLINE_SPACE, "");
238 interlinespaceED->setEnabled(false);
239 interlinespaceUnit->setEnabled(false);
243 set(Tabular::SET_INTERLINE_SPACE, "default");
244 interlinespaceED->setEnabled(false);
245 interlinespaceUnit->setEnabled(false);
249 if (!interlinespaceED->text().isEmpty())
250 set(Tabular::SET_INTERLINE_SPACE,
251 widgetsToLength(interlinespaceED, interlinespaceUnit));
252 if (!bc().policy().isReadOnly()) {
253 interlinespaceED->setEnabled(true);
254 interlinespaceUnit->setEnabled(true);
263 void GuiTabular::close_clicked()
270 void GuiTabular::borderSet_clicked()
272 set(Tabular::SET_ALL_LINES);
278 void GuiTabular::borderUnset_clicked()
280 set(Tabular::UNSET_ALL_LINES);
286 void GuiTabular::leftBorder_changed()
288 set(Tabular::TOGGLE_LINE_LEFT);
293 void GuiTabular::rightBorder_changed()
295 set(Tabular::TOGGLE_LINE_RIGHT);
300 void GuiTabular::topBorder_changed()
302 set(Tabular::TOGGLE_LINE_TOP);
307 void GuiTabular::bottomBorder_changed()
309 set(Tabular::TOGGLE_LINE_BOTTOM);
314 void GuiTabular::specialAlignment_changed()
316 string special = fromqstr(specialAlignmentED->text());
322 void GuiTabular::width_changed()
325 string const width = widgetsToLength(widthED, widthUnit);
330 void GuiTabular::multicolumn_clicked()
337 void GuiTabular::rotateTabular()
339 rotateTabular(rotateTabularCB->isChecked());
344 void GuiTabular::rotateCell()
346 rotateCell(rotateCellCB->isChecked());
351 void GuiTabular::hAlign_changed(int align)
353 GuiTabular::HALIGN h = GuiTabular::LEFT;
356 case 0: h = GuiTabular::LEFT; break;
357 case 1: h = GuiTabular::CENTER; break;
358 case 2: h = GuiTabular::RIGHT; break;
359 case 3: h = GuiTabular::BLOCK; break;
366 void GuiTabular::vAlign_changed(int align)
368 GuiTabular::VALIGN v = GuiTabular::TOP;
371 case 0: v = GuiTabular::TOP; break;
372 case 1: v = GuiTabular::MIDDLE; break;
373 case 2: v = GuiTabular::BOTTOM; break;
380 void GuiTabular::longTabular()
382 longTabular(longTabularCB->isChecked());
387 void GuiTabular::ltNewpage_clicked()
389 set(Tabular::SET_LTNEWPAGE);
394 void GuiTabular::on_captionStatusCB_toggled()
396 set(Tabular::TOGGLE_LTCAPTION);
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 borders->setTop(tabular_.topLine(cell));
567 borders->setBottom(tabular_.bottomLine(cell));
568 borders->setLeft(tabular_.leftLine(cell));
569 borders->setRight(tabular_.rightLine(cell));
570 // repaint the setborder widget
577 Length getColumnPWidth(Tabular const & t, size_t cell)
579 return t.column_info[t.cellColumn(cell)].p_width;
583 Length getMColumnPWidth(Tabular const & t, size_t cell)
585 if (t.isMultiColumn(cell))
586 return t.cellInfo(cell).p_width;
591 docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
593 if (what == Tabular::SET_SPECIAL_MULTI)
594 return t.cellInfo(cell).align_special;
595 return t.column_info[t.cellColumn(cell)].align_special;
602 void GuiTabular::updateContents()
604 initialiseParams(string());
606 size_t const cell = 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_.rotate);
621 longTabularCB->setChecked(tabular_.is_long_tabular);
629 special = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_MULTI);
630 pwidth = getMColumnPWidth(tabular_, cell);
632 special = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_COLUMN);
633 pwidth = getColumnPWidth(tabular_, cell);
636 specialAlignmentED->setText(toqstr(special));
638 bool const isReadonly = bc().policy().isReadOnly();
639 specialAlignmentED->setEnabled(!isReadonly);
641 Length::UNIT const default_unit = Length::defaultUnit();
643 borderDefaultRB->setChecked(!tabular_.use_booktabs);
644 booktabsRB->setChecked(tabular_.use_booktabs);
646 if (tabular_.row_info[row].top_space.empty()
647 && !tabular_.row_info[row].top_space_default) {
648 topspaceCO->setCurrentIndex(0);
649 } else if (tabular_.row_info[row].top_space_default) {
650 topspaceCO->setCurrentIndex(1);
652 topspaceCO->setCurrentIndex(2);
653 lengthToWidgets(topspaceED,
655 tabular_.row_info[row].top_space.asString(),
658 topspaceED->setEnabled(!isReadonly
659 && (topspaceCO->currentIndex() == 2));
660 topspaceUnit->setEnabled(!isReadonly
661 && (topspaceCO->currentIndex() == 2));
662 topspaceCO->setEnabled(!isReadonly);
664 if (tabular_.row_info[row].bottom_space.empty()
665 && !tabular_.row_info[row].bottom_space_default) {
666 bottomspaceCO->setCurrentIndex(0);
667 } else if (tabular_.row_info[row].bottom_space_default) {
668 bottomspaceCO->setCurrentIndex(1);
670 bottomspaceCO->setCurrentIndex(2);
671 lengthToWidgets(bottomspaceED,
673 tabular_.row_info[row].bottom_space.asString(),
676 bottomspaceED->setEnabled(!isReadonly
677 && (bottomspaceCO->currentIndex() == 2));
678 bottomspaceUnit->setEnabled(!isReadonly
679 && (bottomspaceCO->currentIndex() == 2));
680 bottomspaceCO->setEnabled(!isReadonly);
682 if (tabular_.row_info[row].interline_space.empty()
683 && !tabular_.row_info[row].interline_space_default) {
684 interlinespaceCO->setCurrentIndex(0);
685 } else if (tabular_.row_info[row].interline_space_default) {
686 interlinespaceCO->setCurrentIndex(1);
688 interlinespaceCO->setCurrentIndex(2);
689 lengthToWidgets(interlinespaceED,
691 tabular_.row_info[row].interline_space.asString(),
694 interlinespaceED->setEnabled(!isReadonly
695 && (interlinespaceCO->currentIndex() == 2));
696 interlinespaceUnit->setEnabled(!isReadonly
697 && (interlinespaceCO->currentIndex() == 2));
698 interlinespaceCO->setEnabled(!isReadonly);
702 colwidth = pwidth.asString();
703 lengthToWidgets(widthED, widthUnit,
704 colwidth, default_unit);
706 widthED->setEnabled(!isReadonly);
707 widthUnit->setEnabled(!isReadonly);
710 hAlignCB->addItem(qt_("Left"));
711 hAlignCB->addItem(qt_("Center"));
712 hAlignCB->addItem(qt_("Right"));
713 if (!multicol && !pwidth.zero())
714 hAlignCB->addItem(qt_("Justified"));
717 switch (tabular_.getAlignment(cell)) {
721 case LYX_ALIGN_CENTER:
724 case LYX_ALIGN_RIGHT:
727 case LYX_ALIGN_BLOCK:
729 if (!multicol && !pwidth.zero())
737 hAlignCB->setCurrentIndex(align);
740 switch (tabular_.getVAlignment(cell)) {
741 case Tabular::LYX_VALIGN_TOP:
744 case Tabular::LYX_VALIGN_MIDDLE:
747 case Tabular::LYX_VALIGN_BOTTOM:
756 vAlignCB->setCurrentIndex(valign);
758 hAlignCB->setEnabled(true);
759 vAlignCB->setEnabled(!pwidth.zero());
761 if (!tabular_.is_long_tabular) {
762 headerStatusCB->setChecked(false);
763 headerBorderAboveCB->setChecked(false);
764 headerBorderBelowCB->setChecked(false);
765 firstheaderStatusCB->setChecked(false);
766 firstheaderBorderAboveCB->setChecked(false);
767 firstheaderBorderBelowCB->setChecked(false);
768 firstheaderNoContentsCB->setChecked(false);
769 footerStatusCB->setChecked(false);
770 footerBorderAboveCB->setChecked(false);
771 footerBorderBelowCB->setChecked(false);
772 lastfooterStatusCB->setChecked(false);
773 lastfooterBorderAboveCB->setChecked(false);
774 lastfooterBorderBelowCB->setChecked(false);
775 lastfooterNoContentsCB->setChecked(false);
776 newpageCB->setChecked(false);
777 newpageCB->setEnabled(false);
778 captionStatusCB->blockSignals(true);
779 captionStatusCB->setChecked(false);
780 captionStatusCB->blockSignals(false);
783 captionStatusCB->blockSignals(true);
784 captionStatusCB->setChecked(tabular_.ltCaption(row));
785 captionStatusCB->blockSignals(false);
789 bool row_set = tabular_.getRowOfLTHead(row, ltt);
790 headerStatusCB->setChecked(row_set);
792 headerBorderAboveCB->setChecked(ltt.topDL);
793 headerBorderBelowCB->setChecked(ltt.bottomDL);
796 headerBorderAboveCB->setChecked(false);
797 headerBorderBelowCB->setChecked(false);
798 headerBorderAboveCB->setEnabled(false);
799 headerBorderBelowCB->setEnabled(false);
800 firstheaderNoContentsCB->setChecked(false);
801 firstheaderNoContentsCB->setEnabled(false);
805 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
806 firstheaderStatusCB->setChecked(row_set);
807 if (ltt.set && (!ltt.empty || !use_empty)) {
808 firstheaderBorderAboveCB->setChecked(ltt.topDL);
809 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
811 firstheaderBorderAboveCB->setEnabled(false);
812 firstheaderBorderBelowCB->setEnabled(false);
813 firstheaderBorderAboveCB->setChecked(false);
814 firstheaderBorderBelowCB->setChecked(false);
816 firstheaderNoContentsCB->setChecked(ltt.empty);
818 firstheaderStatusCB->setEnabled(false);
822 row_set = tabular_.getRowOfLTFoot(row, ltt);
823 footerStatusCB->setChecked(row_set);
825 footerBorderAboveCB->setChecked(ltt.topDL);
826 footerBorderBelowCB->setChecked(ltt.bottomDL);
829 footerBorderAboveCB->setChecked(false);
830 footerBorderBelowCB->setChecked(false);
831 footerBorderAboveCB->setEnabled(false);
832 footerBorderBelowCB->setEnabled(false);
833 lastfooterNoContentsCB->setChecked(false);
834 lastfooterNoContentsCB->setEnabled(false);
838 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
839 lastfooterStatusCB->setChecked(row_set);
840 if (ltt.set && (!ltt.empty || !use_empty)) {
841 lastfooterBorderAboveCB->setChecked(ltt.topDL);
842 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
844 lastfooterBorderAboveCB->setEnabled(false);
845 lastfooterBorderBelowCB->setEnabled(false);
846 lastfooterBorderAboveCB->setChecked(false);
847 lastfooterBorderBelowCB->setChecked(false);
849 lastfooterNoContentsCB->setChecked(ltt.empty);
851 lastfooterStatusCB->setEnabled(false);
854 newpageCB->setChecked(tabular_.getLTNewPage(row));
858 void GuiTabular::closeGUI()
860 // ugly hack to auto-apply the stuff that hasn't been
861 // yet. don't let this continue to exist ...
863 // Subtle here, we must /not/ apply any changes and
864 // then refer to tabular, as it will have been freed
865 // since the changes update the actual tabular_
867 // apply the fixed width values
868 size_t const cell = getActiveCell();
869 bool const multicol = tabular_.isMultiColumn(cell);
870 string width = widgetsToLength(widthED, widthUnit);
873 Length llen = getColumnPWidth(tabular_, cell);
874 Length llenMulti = getMColumnPWidth(tabular_, cell);
876 if (multicol && !llenMulti.zero())
877 width2 = llenMulti.asString();
878 else if (!multicol && !llen.zero())
879 width2 = llen.asString();
881 // apply the special alignment
882 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
886 sa2 = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_MULTI);
888 sa2 = getAlignSpecial(tabular_, cell, Tabular::SET_SPECIAL_COLUMN);
892 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
894 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
897 if (width != width2) {
899 set(Tabular::SET_MPWIDTH, width);
901 set(Tabular::SET_PWIDTH, width);
905 switch (topspaceCO->currentIndex()) {
907 set(Tabular::SET_TOP_SPACE, "");
910 set(Tabular::SET_TOP_SPACE, "default");
913 set(Tabular::SET_TOP_SPACE,
914 widgetsToLength(topspaceED, topspaceUnit));
918 switch (bottomspaceCO->currentIndex()) {
920 set(Tabular::SET_BOTTOM_SPACE, "");
923 set(Tabular::SET_BOTTOM_SPACE, "default");
926 set(Tabular::SET_BOTTOM_SPACE,
927 widgetsToLength(bottomspaceED, bottomspaceUnit));
931 switch (interlinespaceCO->currentIndex()) {
933 set(Tabular::SET_INTERLINE_SPACE, "");
936 set(Tabular::SET_INTERLINE_SPACE, "default");
939 set(Tabular::SET_INTERLINE_SPACE,
940 widgetsToLength(interlinespaceED, interlinespaceUnit));
947 bool GuiTabular::initialiseParams(string const & data)
949 // try to get the current cell
950 BufferView const * const bv = bufferview();
951 InsetTabular const * current_inset = 0;
953 Cursor const & cur = bv->cursor();
954 // get the innermost tabular inset;
955 // assume that it is "ours"
956 for (int i = cur.depth() - 1; i >= 0; --i)
957 if (cur[i].inset().lyxCode() == TABULAR_CODE) {
958 current_inset = static_cast<InsetTabular const *>(&cur[i].inset());
959 active_cell_ = cur[i].idx();
964 if (current_inset && data.empty()) {
965 tabular_ = Tabular(current_inset->tabular);
969 InsetTabular tmp(const_cast<Buffer &>(buffer()));
970 InsetTabular::string2params(data, tmp);
971 tabular_ = Tabular(tmp.tabular);
976 void GuiTabular::clearParams()
978 InsetTabular tmp(const_cast<Buffer &>(buffer()));
979 tabular_ = tmp.tabular;
980 active_cell_ = Tabular::npos;
984 Tabular::idx_type GuiTabular::getActiveCell() const
990 void GuiTabular::set(Tabular::Feature f, string const & arg)
992 string const data = featureAsString(f) + ' ' + arg;
993 dispatch(FuncRequest(getLfun(), data));
997 void GuiTabular::setSpecial(string const & special)
999 if (tabular_.isMultiColumn(getActiveCell()))
1000 set(Tabular::SET_SPECIAL_MULTI, special);
1002 set(Tabular::SET_SPECIAL_COLUMN, special);
1006 void GuiTabular::setWidth(string const & width)
1008 if (tabular_.isMultiColumn(getActiveCell()))
1009 set(Tabular::SET_MPWIDTH, width);
1011 set(Tabular::SET_PWIDTH, width);
1017 void GuiTabular::toggleMultiColumn()
1019 set(Tabular::MULTICOLUMN);
1024 void GuiTabular::rotateTabular(bool yes)
1027 set(Tabular::SET_ROTATE_TABULAR);
1029 set(Tabular::UNSET_ROTATE_TABULAR);
1033 void GuiTabular::rotateCell(bool yes)
1036 set(Tabular::SET_ROTATE_CELL);
1038 set(Tabular::UNSET_ROTATE_CELL);
1042 void GuiTabular::halign(GuiTabular::HALIGN h)
1044 Tabular::Feature num = Tabular::ALIGN_LEFT;
1045 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
1049 num = Tabular::ALIGN_LEFT;
1050 multi_num = Tabular::M_ALIGN_LEFT;
1053 num = Tabular::ALIGN_CENTER;
1054 multi_num = Tabular::M_ALIGN_CENTER;
1057 num = Tabular::ALIGN_RIGHT;
1058 multi_num = Tabular::M_ALIGN_RIGHT;
1061 num = Tabular::ALIGN_BLOCK;
1062 //multi_num: no equivalent
1066 if (tabular_.isMultiColumn(getActiveCell()))
1073 void GuiTabular::valign(GuiTabular::VALIGN v)
1075 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
1076 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
1080 num = Tabular::VALIGN_TOP;
1081 multi_num = Tabular::M_VALIGN_TOP;
1084 num = Tabular::VALIGN_MIDDLE;
1085 multi_num = Tabular::M_VALIGN_MIDDLE;
1088 num = Tabular::VALIGN_BOTTOM;
1089 multi_num = Tabular::M_VALIGN_BOTTOM;
1093 if (tabular_.isMultiColumn(getActiveCell()))
1100 void GuiTabular::booktabs(bool yes)
1103 set(Tabular::SET_BOOKTABS);
1105 set(Tabular::UNSET_BOOKTABS);
1109 void GuiTabular::longTabular(bool yes)
1112 set(Tabular::SET_LONGTABULAR);
1114 set(Tabular::UNSET_LONGTABULAR);
1118 Dialog * createGuiTabular(GuiView & lv) { return new GuiTabular(lv); }
1121 } // namespace frontend
1124 #include "moc_GuiTabular.cpp"