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", qt_("Table Settings"))
42 active_cell_ = Tabular::npos;
46 widthED->setValidator(unsignedLengthValidator(widthED));
47 topspaceED->setValidator(new LengthValidator(topspaceED));
48 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
49 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
51 connect(topspaceED, SIGNAL(returnPressed()),
52 this, SLOT(topspace_changed()));
53 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
54 this, SLOT(topspace_changed()));
55 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
56 connect(bottomspaceED, SIGNAL(returnPressed()),
57 this, SLOT(bottomspace_changed()));
58 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
59 this, SLOT(bottomspace_changed()));
60 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
61 connect(interlinespaceED, SIGNAL(returnPressed()),
62 this, SLOT(interlinespace_changed()));
63 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
64 this, SLOT(interlinespace_changed()));
65 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
66 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
67 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
68 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
69 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
70 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
71 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
72 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
73 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
74 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
75 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
76 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
77 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
78 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
79 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
80 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
81 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
82 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
83 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
84 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
85 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
86 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
87 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
88 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
89 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
90 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
91 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
92 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
93 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
94 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
95 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
96 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
97 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
98 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
99 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
100 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
102 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
103 bc().setCancel(closePB);
105 bc().addReadOnly(topspaceED);
106 bc().addReadOnly(topspaceUnit);
107 bc().addReadOnly(topspaceCO);
108 bc().addReadOnly(bottomspaceED);
109 bc().addReadOnly(bottomspaceUnit);
110 bc().addReadOnly(bottomspaceCO);
111 bc().addReadOnly(interlinespaceED);
112 bc().addReadOnly(interlinespaceUnit);
113 bc().addReadOnly(interlinespaceCO);
114 bc().addReadOnly(borderDefaultRB);
115 bc().addReadOnly(booktabsRB);
117 bc().addReadOnly(multicolumnCB);
118 bc().addReadOnly(rotateCellCB);
119 bc().addReadOnly(rotateTabularCB);
120 bc().addReadOnly(specialAlignmentED);
121 bc().addReadOnly(widthED);
122 bc().addReadOnly(widthUnit);
123 bc().addReadOnly(hAlignCB);
124 bc().addReadOnly(vAlignCB);
125 bc().addReadOnly(borderSetPB);
126 bc().addReadOnly(borderUnsetPB);
127 bc().addReadOnly(borders);
128 bc().addReadOnly(longTabularCB);
129 bc().addReadOnly(headerStatusCB);
130 bc().addReadOnly(headerBorderAboveCB);
131 bc().addReadOnly(headerBorderBelowCB);
132 bc().addReadOnly(firstheaderStatusCB);
133 bc().addReadOnly(firstheaderBorderAboveCB);
134 bc().addReadOnly(firstheaderBorderBelowCB);
135 bc().addReadOnly(firstheaderNoContentsCB);
136 bc().addReadOnly(footerStatusCB);
137 bc().addReadOnly(footerBorderAboveCB);
138 bc().addReadOnly(footerBorderBelowCB);
139 bc().addReadOnly(lastfooterStatusCB);
140 bc().addReadOnly(lastfooterBorderAboveCB);
141 bc().addReadOnly(lastfooterBorderBelowCB);
142 bc().addReadOnly(lastfooterNoContentsCB);
143 bc().addReadOnly(newpageCB);
145 // initialize the length validator
146 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
147 bc().addCheckedLineEdit(topspaceED, topspaceLA);
148 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
149 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
153 GuiTabular::~GuiTabular()
158 void GuiTabular::change_adaptor()
164 void GuiTabular::booktabsChanged(bool)
167 booktabs(booktabsRB->isChecked());
172 void GuiTabular::topspace_changed()
174 switch (topspaceCO->currentIndex()) {
176 set(Tabular::SET_TOP_SPACE, "");
177 topspaceED->setEnabled(false);
178 topspaceUnit->setEnabled(false);
182 set(Tabular::SET_TOP_SPACE, "default");
183 topspaceED->setEnabled(false);
184 topspaceUnit->setEnabled(false);
188 if (!topspaceED->text().isEmpty())
189 set(Tabular::SET_TOP_SPACE,
190 widgetsToLength(topspaceED, topspaceUnit));
191 if (!bc().policy().isReadOnly()) {
192 topspaceED->setEnabled(true);
193 topspaceUnit->setEnabled(true);
202 void GuiTabular::bottomspace_changed()
204 switch (bottomspaceCO->currentIndex()) {
206 set(Tabular::SET_BOTTOM_SPACE, "");
207 bottomspaceED->setEnabled(false);
208 bottomspaceUnit->setEnabled(false);
212 set(Tabular::SET_BOTTOM_SPACE, "default");
213 bottomspaceED->setEnabled(false);
214 bottomspaceUnit->setEnabled(false);
218 if (!bottomspaceED->text().isEmpty())
219 set(Tabular::SET_BOTTOM_SPACE,
220 widgetsToLength(bottomspaceED, bottomspaceUnit));
221 if (!bc().policy().isReadOnly()) {
222 bottomspaceED->setEnabled(true);
223 bottomspaceUnit->setEnabled(true);
232 void GuiTabular::interlinespace_changed()
234 switch (interlinespaceCO->currentIndex()) {
236 set(Tabular::SET_INTERLINE_SPACE, "");
237 interlinespaceED->setEnabled(false);
238 interlinespaceUnit->setEnabled(false);
242 set(Tabular::SET_INTERLINE_SPACE, "default");
243 interlinespaceED->setEnabled(false);
244 interlinespaceUnit->setEnabled(false);
248 if (!interlinespaceED->text().isEmpty())
249 set(Tabular::SET_INTERLINE_SPACE,
250 widgetsToLength(interlinespaceED, interlinespaceUnit));
251 if (!bc().policy().isReadOnly()) {
252 interlinespaceED->setEnabled(true);
253 interlinespaceUnit->setEnabled(true);
262 void GuiTabular::close_clicked()
269 void GuiTabular::borderSet_clicked()
271 set(Tabular::SET_ALL_LINES);
277 void GuiTabular::borderUnset_clicked()
279 set(Tabular::UNSET_ALL_LINES);
285 void GuiTabular::leftBorder_changed()
292 void GuiTabular::rightBorder_changed()
299 void GuiTabular::topBorder_changed()
306 void GuiTabular::bottomBorder_changed()
313 void GuiTabular::specialAlignment_changed()
315 string special = fromqstr(specialAlignmentED->text());
321 void GuiTabular::width_changed()
324 string const width = widgetsToLength(widthED, widthUnit);
329 void GuiTabular::multicolumn_clicked()
336 void GuiTabular::rotateTabular()
338 rotateTabular(rotateTabularCB->isChecked());
343 void GuiTabular::rotateCell()
345 rotateCell(rotateCellCB->isChecked());
350 void GuiTabular::hAlign_changed(int align)
352 GuiTabular::HALIGN h = GuiTabular::LEFT;
355 case 0: h = GuiTabular::LEFT; break;
356 case 1: h = GuiTabular::CENTER; break;
357 case 2: h = GuiTabular::RIGHT; break;
358 case 3: h = GuiTabular::BLOCK; break;
365 void GuiTabular::vAlign_changed(int align)
367 GuiTabular::VALIGN v = GuiTabular::TOP;
370 case 0: v = GuiTabular::TOP; break;
371 case 1: v = GuiTabular::MIDDLE; break;
372 case 2: v = GuiTabular::BOTTOM; break;
379 void GuiTabular::longTabular()
381 longTabular(longTabularCB->isChecked());
386 void GuiTabular::ltNewpage_clicked()
388 set(Tabular::SET_LTNEWPAGE);
393 void GuiTabular::ltHeaderStatus_clicked()
395 bool enable = headerStatusCB->isChecked();
397 set(Tabular::SET_LTHEAD, "");
399 set(Tabular::UNSET_LTHEAD, "");
400 headerBorderAboveCB->setEnabled(enable);
401 headerBorderBelowCB->setEnabled(enable);
402 firstheaderNoContentsCB->setEnabled(enable);
407 void GuiTabular::ltHeaderBorderAbove_clicked()
409 if (headerBorderAboveCB->isChecked())
410 set(Tabular::SET_LTHEAD, "dl_above");
412 set(Tabular::UNSET_LTHEAD, "dl_above");
417 void GuiTabular::ltHeaderBorderBelow_clicked()
419 if (headerBorderBelowCB->isChecked())
420 set(Tabular::SET_LTHEAD, "dl_below");
422 set(Tabular::UNSET_LTHEAD, "dl_below");
427 void GuiTabular::ltFirstHeaderBorderAbove_clicked()
429 if (firstheaderBorderAboveCB->isChecked())
430 set(Tabular::SET_LTFIRSTHEAD, "dl_above");
432 set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
437 void GuiTabular::ltFirstHeaderBorderBelow_clicked()
439 if (firstheaderBorderBelowCB->isChecked())
440 set(Tabular::SET_LTFIRSTHEAD, "dl_below");
442 set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
447 void GuiTabular::ltFirstHeaderStatus_clicked()
449 bool enable = firstheaderStatusCB->isChecked();
451 set(Tabular::SET_LTFIRSTHEAD, "");
453 set(Tabular::UNSET_LTFIRSTHEAD, "");
454 firstheaderBorderAboveCB->setEnabled(enable);
455 firstheaderBorderBelowCB->setEnabled(enable);
460 void GuiTabular::ltFirstHeaderEmpty_clicked()
462 bool enable = firstheaderNoContentsCB->isChecked();
464 set(Tabular::SET_LTFIRSTHEAD, "empty");
466 set(Tabular::UNSET_LTFIRSTHEAD, "empty");
467 firstheaderStatusCB->setEnabled(!enable);
468 firstheaderBorderAboveCB->setEnabled(!enable);
469 firstheaderBorderBelowCB->setEnabled(!enable);
474 void GuiTabular::ltFooterStatus_clicked()
476 bool enable = footerStatusCB->isChecked();
478 set(Tabular::SET_LTFOOT, "");
480 set(Tabular::UNSET_LTFOOT, "");
481 footerBorderAboveCB->setEnabled(enable);
482 footerBorderBelowCB->setEnabled(enable);
483 lastfooterNoContentsCB->setEnabled(enable);
488 void GuiTabular::ltFooterBorderAbove_clicked()
490 if (footerBorderAboveCB->isChecked())
491 set(Tabular::SET_LTFOOT, "dl_above");
493 set(Tabular::UNSET_LTFOOT, "dl_above");
498 void GuiTabular::ltFooterBorderBelow_clicked()
500 if (footerBorderBelowCB->isChecked())
501 set(Tabular::SET_LTFOOT, "dl_below");
503 set(Tabular::UNSET_LTFOOT, "dl_below");
508 void GuiTabular::ltLastFooterStatus_clicked()
510 bool enable = lastfooterStatusCB->isChecked();
512 set(Tabular::SET_LTLASTFOOT, "");
514 set(Tabular::UNSET_LTLASTFOOT, "");
515 lastfooterBorderAboveCB->setEnabled(enable);
516 lastfooterBorderBelowCB->setEnabled(enable);
521 void GuiTabular::ltLastFooterBorderAbove_clicked()
523 if (lastfooterBorderAboveCB->isChecked())
524 set(Tabular::SET_LTLASTFOOT, "dl_above");
526 set(Tabular::UNSET_LTLASTFOOT, "dl_above");
531 void GuiTabular::ltLastFooterBorderBelow_clicked()
533 if (lastfooterBorderBelowCB->isChecked())
534 set(Tabular::SET_LTLASTFOOT, "dl_below");
536 set(Tabular::UNSET_LTLASTFOOT, "dl_below");
541 void GuiTabular::ltLastFooterEmpty_clicked()
543 bool enable = lastfooterNoContentsCB->isChecked();
545 set(Tabular::SET_LTLASTFOOT, "empty");
547 set(Tabular::UNSET_LTLASTFOOT, "empty");
548 lastfooterStatusCB->setEnabled(!enable);
549 lastfooterBorderAboveCB->setEnabled(!enable);
550 lastfooterBorderBelowCB->setEnabled(!enable);
555 void GuiTabular::update_borders()
557 Tabular::idx_type const cell = getActiveCell();
558 bool const isMulticolumnCell = tabular_.isMultiColumn(cell);
560 if (!isMulticolumnCell) {
561 borders->setLeftEnabled(true);
562 borders->setRightEnabled(true);
563 borders->setTop(tabular_.topLine(cell, true));
564 borders->setBottom(tabular_.bottomLine(cell, true));
565 borders->setLeft(tabular_.leftLine(cell, true));
566 borders->setRight(tabular_.rightLine(cell, true));
567 // repaint the setborder widget
572 borders->setTop(tabular_.topLine(cell));
573 borders->setBottom(tabular_.bottomLine(cell));
574 // pay attention to left/right lines: they are only allowed
575 // to set if we are in first/last cell of row or if the left/right
576 // cell is also a multicolumn.
577 if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) {
578 borders->setLeftEnabled(true);
579 borders->setLeft(tabular_.leftLine(cell));
581 borders->setLeft(false);
582 borders->setLeftEnabled(false);
584 if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) {
585 borders->setRightEnabled(true);
586 borders->setRight(tabular_.rightLine(cell));
588 borders->setRight(false);
589 borders->setRightEnabled(false);
591 // repaint the setborder widget
596 void GuiTabular::updateContents()
598 initialiseParams(string());
600 Tabular::idx_type const cell = getActiveCell();
602 Tabular::row_type const row = tabular_.cellRow(cell);
603 Tabular::col_type const col = tabular_.cellColumn(cell);
605 tabularRowED->setText(QString::number(row + 1));
606 tabularColumnED->setText(QString::number(col + 1));
608 bool const multicol(tabular_.isMultiColumn(cell));
610 multicolumnCB->setChecked(multicol);
612 rotateCellCB->setChecked(tabular_.getRotateCell(cell));
613 rotateTabularCB->setChecked(tabular_.getRotateTabular());
615 longTabularCB->setChecked(tabular_.isLongTabular());
623 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
624 pwidth = tabular_.getMColumnPWidth(cell);
626 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
627 pwidth = tabular_.getColumnPWidth(cell);
630 specialAlignmentED->setText(toqstr(special));
632 bool const isReadonly = bc().policy().isReadOnly();
633 specialAlignmentED->setEnabled(!isReadonly);
635 Length::UNIT default_unit =
636 useMetricUnits() ? Length::CM : Length::IN;
638 borderDefaultRB->setChecked(!tabular_.useBookTabs());
639 booktabsRB->setChecked(tabular_.useBookTabs());
641 if (tabular_.row_info[row].top_space.empty()
642 && !tabular_.row_info[row].top_space_default) {
643 topspaceCO->setCurrentIndex(0);
644 } else if (tabular_.row_info[row].top_space_default) {
645 topspaceCO->setCurrentIndex(1);
647 topspaceCO->setCurrentIndex(2);
648 lengthToWidgets(topspaceED,
650 tabular_.row_info[row].top_space.asString(),
653 topspaceED->setEnabled(!isReadonly
654 && (topspaceCO->currentIndex() == 2));
655 topspaceUnit->setEnabled(!isReadonly
656 && (topspaceCO->currentIndex() == 2));
657 topspaceCO->setEnabled(!isReadonly);
659 if (tabular_.row_info[row].bottom_space.empty()
660 && !tabular_.row_info[row].bottom_space_default) {
661 bottomspaceCO->setCurrentIndex(0);
662 } else if (tabular_.row_info[row].bottom_space_default) {
663 bottomspaceCO->setCurrentIndex(1);
665 bottomspaceCO->setCurrentIndex(2);
666 lengthToWidgets(bottomspaceED,
668 tabular_.row_info[row].bottom_space.asString(),
671 bottomspaceED->setEnabled(!isReadonly
672 && (bottomspaceCO->currentIndex() == 2));
673 bottomspaceUnit->setEnabled(!isReadonly
674 && (bottomspaceCO->currentIndex() == 2));
675 bottomspaceCO->setEnabled(!isReadonly);
677 if (tabular_.row_info[row].interline_space.empty()
678 && !tabular_.row_info[row].interline_space_default) {
679 interlinespaceCO->setCurrentIndex(0);
680 } else if (tabular_.row_info[row].interline_space_default) {
681 interlinespaceCO->setCurrentIndex(1);
683 interlinespaceCO->setCurrentIndex(2);
684 lengthToWidgets(interlinespaceED,
686 tabular_.row_info[row].interline_space.asString(),
689 interlinespaceED->setEnabled(!isReadonly
690 && (interlinespaceCO->currentIndex() == 2));
691 interlinespaceUnit->setEnabled(!isReadonly
692 && (interlinespaceCO->currentIndex() == 2));
693 interlinespaceCO->setEnabled(!isReadonly);
697 colwidth = pwidth.asString();
698 lengthToWidgets(widthED, widthUnit,
699 colwidth, default_unit);
701 widthED->setEnabled(!isReadonly);
702 widthUnit->setEnabled(!isReadonly);
705 hAlignCB->addItem(qt_("Left"));
706 hAlignCB->addItem(qt_("Center"));
707 hAlignCB->addItem(qt_("Right"));
708 if (!multicol && !pwidth.zero())
709 hAlignCB->addItem(qt_("Justified"));
712 switch (tabular_.getAlignment(cell)) {
716 case LYX_ALIGN_CENTER:
719 case LYX_ALIGN_RIGHT:
722 case LYX_ALIGN_BLOCK:
724 if (!multicol && !pwidth.zero())
732 hAlignCB->setCurrentIndex(align);
735 switch (tabular_.getVAlignment(cell)) {
736 case Tabular::LYX_VALIGN_TOP:
739 case Tabular::LYX_VALIGN_MIDDLE:
742 case Tabular::LYX_VALIGN_BOTTOM:
751 vAlignCB->setCurrentIndex(valign);
753 hAlignCB->setEnabled(true);
754 vAlignCB->setEnabled(!pwidth.zero());
756 if (!tabular_.isLongTabular()) {
757 headerStatusCB->setChecked(false);
758 headerBorderAboveCB->setChecked(false);
759 headerBorderBelowCB->setChecked(false);
760 firstheaderStatusCB->setChecked(false);
761 firstheaderBorderAboveCB->setChecked(false);
762 firstheaderBorderBelowCB->setChecked(false);
763 firstheaderNoContentsCB->setChecked(false);
764 footerStatusCB->setChecked(false);
765 footerBorderAboveCB->setChecked(false);
766 footerBorderBelowCB->setChecked(false);
767 lastfooterStatusCB->setChecked(false);
768 lastfooterBorderAboveCB->setChecked(false);
769 lastfooterBorderBelowCB->setChecked(false);
770 lastfooterNoContentsCB->setChecked(false);
771 newpageCB->setChecked(false);
772 newpageCB->setEnabled(false);
778 bool row_set = tabular_.getRowOfLTHead(row, ltt);
779 headerStatusCB->setChecked(row_set);
781 headerBorderAboveCB->setChecked(ltt.topDL);
782 headerBorderBelowCB->setChecked(ltt.bottomDL);
785 headerBorderAboveCB->setChecked(false);
786 headerBorderBelowCB->setChecked(false);
787 headerBorderAboveCB->setEnabled(false);
788 headerBorderBelowCB->setEnabled(false);
789 firstheaderNoContentsCB->setChecked(false);
790 firstheaderNoContentsCB->setEnabled(false);
794 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
795 firstheaderStatusCB->setChecked(row_set);
796 if (ltt.set && (!ltt.empty || !use_empty)) {
797 firstheaderBorderAboveCB->setChecked(ltt.topDL);
798 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
800 firstheaderBorderAboveCB->setEnabled(false);
801 firstheaderBorderBelowCB->setEnabled(false);
802 firstheaderBorderAboveCB->setChecked(false);
803 firstheaderBorderBelowCB->setChecked(false);
805 firstheaderNoContentsCB->setChecked(ltt.empty);
807 firstheaderStatusCB->setEnabled(false);
811 row_set = tabular_.getRowOfLTFoot(row, ltt);
812 footerStatusCB->setChecked(row_set);
814 footerBorderAboveCB->setChecked(ltt.topDL);
815 footerBorderBelowCB->setChecked(ltt.bottomDL);
818 footerBorderAboveCB->setChecked(false);
819 footerBorderBelowCB->setChecked(false);
820 footerBorderAboveCB->setEnabled(false);
821 footerBorderBelowCB->setEnabled(false);
822 lastfooterNoContentsCB->setChecked(false);
823 lastfooterNoContentsCB->setEnabled(false);
827 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
828 lastfooterStatusCB->setChecked(row_set);
829 if (ltt.set && (!ltt.empty || !use_empty)) {
830 lastfooterBorderAboveCB->setChecked(ltt.topDL);
831 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
833 lastfooterBorderAboveCB->setEnabled(false);
834 lastfooterBorderBelowCB->setEnabled(false);
835 lastfooterBorderAboveCB->setChecked(false);
836 lastfooterBorderBelowCB->setChecked(false);
838 lastfooterNoContentsCB->setChecked(ltt.empty);
840 lastfooterStatusCB->setEnabled(false);
843 newpageCB->setChecked(tabular_.getLTNewPage(row));
847 void GuiTabular::closeGUI()
849 // ugly hack to auto-apply the stuff that hasn't been
850 // yet. don't let this continue to exist ...
852 // Subtle here, we must /not/ apply any changes and
853 // then refer to tabular, as it will have been freed
854 // since the changes update the actual tabular_
856 // apply the fixed width values
857 Tabular::idx_type const cell = getActiveCell();
858 bool const multicol = tabular_.isMultiColumn(cell);
859 string width = widgetsToLength(widthED, widthUnit);
862 Length llen = tabular_.getColumnPWidth(cell);
863 Length llenMulti = tabular_.getMColumnPWidth(cell);
865 if (multicol && !llenMulti.zero())
866 width2 = llenMulti.asString();
867 else if (!multicol && !llen.zero())
868 width2 = llen.asString();
870 // apply the special alignment
871 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
875 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
877 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
881 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
883 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
886 if (width != width2) {
888 set(Tabular::SET_MPWIDTH, width);
890 set(Tabular::SET_PWIDTH, width);
894 switch (topspaceCO->currentIndex()) {
896 set(Tabular::SET_TOP_SPACE, "");
899 set(Tabular::SET_TOP_SPACE, "default");
902 set(Tabular::SET_TOP_SPACE,
903 widgetsToLength(topspaceED, topspaceUnit));
907 switch (bottomspaceCO->currentIndex()) {
909 set(Tabular::SET_BOTTOM_SPACE, "");
912 set(Tabular::SET_BOTTOM_SPACE, "default");
915 set(Tabular::SET_BOTTOM_SPACE,
916 widgetsToLength(bottomspaceED, bottomspaceUnit));
920 switch (interlinespaceCO->currentIndex()) {
922 set(Tabular::SET_INTERLINE_SPACE, "");
925 set(Tabular::SET_INTERLINE_SPACE, "default");
928 set(Tabular::SET_INTERLINE_SPACE,
929 widgetsToLength(interlinespaceED, interlinespaceUnit));
936 bool GuiTabular::initialiseParams(string const & data)
938 // try to get the current cell
939 BufferView const * const bv = bufferview();
940 InsetTabular const * current_inset = 0;
942 Cursor const & cur = bv->cursor();
943 // get the innermost tabular inset;
944 // assume that it is "ours"
945 for (int i = cur.depth() - 1; i >= 0; --i)
946 if (cur[i].inset().lyxCode() == TABULAR_CODE) {
947 current_inset = static_cast<InsetTabular const *>(&cur[i].inset());
948 active_cell_ = cur[i].idx();
953 if (current_inset && data.empty()) {
954 tabular_ = Tabular(current_inset->tabular);
958 InsetTabular tmp(buffer());
959 InsetTabularMailer::string2params(data, tmp);
960 tabular_ = Tabular(tmp.tabular);
965 void GuiTabular::clearParams()
967 InsetTabular tmp(buffer());
968 tabular_ = tmp.tabular;
969 active_cell_ = Tabular::npos;
973 Tabular::idx_type GuiTabular::getActiveCell() const
979 void GuiTabular::set(Tabular::Feature f, string const & arg)
981 string const data = featureAsString(f) + ' ' + arg;
982 dispatch(FuncRequest(getLfun(), data));
986 bool GuiTabular::useMetricUnits() const
988 return lyxrc.default_papersize > PAPER_USEXECUTIVE;
992 void GuiTabular::toggleTopLine()
994 if (tabular_.isMultiColumn(getActiveCell()))
995 set(Tabular::M_TOGGLE_LINE_TOP);
997 set(Tabular::TOGGLE_LINE_TOP);
1001 void GuiTabular::toggleBottomLine()
1003 if (tabular_.isMultiColumn(getActiveCell()))
1004 set(Tabular::M_TOGGLE_LINE_BOTTOM);
1006 set(Tabular::TOGGLE_LINE_BOTTOM);
1010 void GuiTabular::toggleLeftLine()
1012 if (tabular_.isMultiColumn(getActiveCell()))
1013 set(Tabular::M_TOGGLE_LINE_LEFT);
1015 set(Tabular::TOGGLE_LINE_LEFT);
1019 void GuiTabular::toggleRightLine()
1021 if (tabular_.isMultiColumn(getActiveCell()))
1022 set(Tabular::M_TOGGLE_LINE_RIGHT);
1024 set(Tabular::TOGGLE_LINE_RIGHT);
1028 void GuiTabular::setSpecial(string const & special)
1030 if (tabular_.isMultiColumn(getActiveCell()))
1031 set(Tabular::SET_SPECIAL_MULTI, special);
1033 set(Tabular::SET_SPECIAL_COLUMN, special);
1037 void GuiTabular::setWidth(string const & width)
1039 if (tabular_.isMultiColumn(getActiveCell()))
1040 set(Tabular::SET_MPWIDTH, width);
1042 set(Tabular::SET_PWIDTH, width);
1048 void GuiTabular::toggleMultiColumn()
1050 set(Tabular::MULTICOLUMN);
1055 void GuiTabular::rotateTabular(bool yes)
1058 set(Tabular::SET_ROTATE_TABULAR);
1060 set(Tabular::UNSET_ROTATE_TABULAR);
1064 void GuiTabular::rotateCell(bool yes)
1067 set(Tabular::SET_ROTATE_CELL);
1069 set(Tabular::UNSET_ROTATE_CELL);
1073 void GuiTabular::halign(GuiTabular::HALIGN h)
1075 Tabular::Feature num = Tabular::ALIGN_LEFT;
1076 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
1080 num = Tabular::ALIGN_LEFT;
1081 multi_num = Tabular::M_ALIGN_LEFT;
1084 num = Tabular::ALIGN_CENTER;
1085 multi_num = Tabular::M_ALIGN_CENTER;
1088 num = Tabular::ALIGN_RIGHT;
1089 multi_num = Tabular::M_ALIGN_RIGHT;
1092 num = Tabular::ALIGN_BLOCK;
1093 //multi_num: no equivalent
1097 if (tabular_.isMultiColumn(getActiveCell()))
1104 void GuiTabular::valign(GuiTabular::VALIGN v)
1106 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
1107 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
1111 num = Tabular::VALIGN_TOP;
1112 multi_num = Tabular::M_VALIGN_TOP;
1115 num = Tabular::VALIGN_MIDDLE;
1116 multi_num = Tabular::M_VALIGN_MIDDLE;
1119 num = Tabular::VALIGN_BOTTOM;
1120 multi_num = Tabular::M_VALIGN_BOTTOM;
1124 if (tabular_.isMultiColumn(getActiveCell()))
1131 void GuiTabular::booktabs(bool yes)
1134 set(Tabular::SET_BOOKTABS);
1136 set(Tabular::UNSET_BOOKTABS);
1140 void GuiTabular::longTabular(bool yes)
1143 set(Tabular::SET_LONGTABULAR);
1145 set(Tabular::UNSET_LONGTABULAR);
1149 Dialog * createGuiTabular(GuiView & lv) { return new GuiTabular(lv); }
1152 } // namespace frontend
1155 #include "GuiTabular_moc.cpp"