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"
29 #include <QPushButton>
30 #include <QRadioButton>
38 GuiTabular::GuiTabular(GuiView & lv)
39 : GuiDialog(lv, "tabular", qt_("Table Settings"))
41 active_cell_ = Tabular::npos;
45 widthED->setValidator(unsignedLengthValidator(widthED));
46 topspaceED->setValidator(new LengthValidator(topspaceED));
47 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
48 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
50 connect(topspaceED, SIGNAL(returnPressed()),
51 this, SLOT(topspace_changed()));
52 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
53 this, SLOT(topspace_changed()));
54 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
55 connect(bottomspaceED, SIGNAL(returnPressed()),
56 this, SLOT(bottomspace_changed()));
57 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
58 this, SLOT(bottomspace_changed()));
59 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
60 connect(interlinespaceED, SIGNAL(returnPressed()),
61 this, SLOT(interlinespace_changed()));
62 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
63 this, SLOT(interlinespace_changed()));
64 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
65 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
66 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
67 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
68 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
69 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
70 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
71 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
72 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
73 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
74 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
75 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
76 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
77 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
78 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
79 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
80 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
81 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
82 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
83 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
84 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
85 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
86 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
87 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
88 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
89 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
90 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
91 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
92 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
93 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
94 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
95 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
96 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
97 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
98 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
99 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
101 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
102 bc().setCancel(closePB);
104 bc().addReadOnly(topspaceED);
105 bc().addReadOnly(topspaceUnit);
106 bc().addReadOnly(topspaceCO);
107 bc().addReadOnly(bottomspaceED);
108 bc().addReadOnly(bottomspaceUnit);
109 bc().addReadOnly(bottomspaceCO);
110 bc().addReadOnly(interlinespaceED);
111 bc().addReadOnly(interlinespaceUnit);
112 bc().addReadOnly(interlinespaceCO);
113 bc().addReadOnly(borderDefaultRB);
114 bc().addReadOnly(booktabsRB);
116 bc().addReadOnly(multicolumnCB);
117 bc().addReadOnly(rotateCellCB);
118 bc().addReadOnly(rotateTabularCB);
119 bc().addReadOnly(specialAlignmentED);
120 bc().addReadOnly(widthED);
121 bc().addReadOnly(widthUnit);
122 bc().addReadOnly(hAlignCB);
123 bc().addReadOnly(vAlignCB);
124 bc().addReadOnly(borderSetPB);
125 bc().addReadOnly(borderUnsetPB);
126 bc().addReadOnly(borders);
127 bc().addReadOnly(longTabularCB);
128 bc().addReadOnly(headerStatusCB);
129 bc().addReadOnly(headerBorderAboveCB);
130 bc().addReadOnly(headerBorderBelowCB);
131 bc().addReadOnly(firstheaderStatusCB);
132 bc().addReadOnly(firstheaderBorderAboveCB);
133 bc().addReadOnly(firstheaderBorderBelowCB);
134 bc().addReadOnly(firstheaderNoContentsCB);
135 bc().addReadOnly(footerStatusCB);
136 bc().addReadOnly(footerBorderAboveCB);
137 bc().addReadOnly(footerBorderBelowCB);
138 bc().addReadOnly(lastfooterStatusCB);
139 bc().addReadOnly(lastfooterBorderAboveCB);
140 bc().addReadOnly(lastfooterBorderBelowCB);
141 bc().addReadOnly(lastfooterNoContentsCB);
142 bc().addReadOnly(newpageCB);
144 // initialize the length validator
145 bc().addCheckedLineEdit(widthED, fixedWidthColLA);
146 bc().addCheckedLineEdit(topspaceED, topspaceLA);
147 bc().addCheckedLineEdit(bottomspaceED, bottomspaceLA);
148 bc().addCheckedLineEdit(interlinespaceED, interlinespaceLA);
152 GuiTabular::~GuiTabular()
157 void GuiTabular::change_adaptor()
163 void GuiTabular::booktabsChanged(bool)
166 booktabs(booktabsRB->isChecked());
171 void GuiTabular::topspace_changed()
173 switch (topspaceCO->currentIndex()) {
175 set(Tabular::SET_TOP_SPACE, "");
176 topspaceED->setEnabled(false);
177 topspaceUnit->setEnabled(false);
181 set(Tabular::SET_TOP_SPACE, "default");
182 topspaceED->setEnabled(false);
183 topspaceUnit->setEnabled(false);
187 if (!topspaceED->text().isEmpty())
188 set(Tabular::SET_TOP_SPACE,
189 widgetsToLength(topspaceED, topspaceUnit));
190 if (!bc().policy().isReadOnly()) {
191 topspaceED->setEnabled(true);
192 topspaceUnit->setEnabled(true);
201 void GuiTabular::bottomspace_changed()
203 switch (bottomspaceCO->currentIndex()) {
205 set(Tabular::SET_BOTTOM_SPACE, "");
206 bottomspaceED->setEnabled(false);
207 bottomspaceUnit->setEnabled(false);
211 set(Tabular::SET_BOTTOM_SPACE, "default");
212 bottomspaceED->setEnabled(false);
213 bottomspaceUnit->setEnabled(false);
217 if (!bottomspaceED->text().isEmpty())
218 set(Tabular::SET_BOTTOM_SPACE,
219 widgetsToLength(bottomspaceED, bottomspaceUnit));
220 if (!bc().policy().isReadOnly()) {
221 bottomspaceED->setEnabled(true);
222 bottomspaceUnit->setEnabled(true);
231 void GuiTabular::interlinespace_changed()
233 switch (interlinespaceCO->currentIndex()) {
235 set(Tabular::SET_INTERLINE_SPACE, "");
236 interlinespaceED->setEnabled(false);
237 interlinespaceUnit->setEnabled(false);
241 set(Tabular::SET_INTERLINE_SPACE, "default");
242 interlinespaceED->setEnabled(false);
243 interlinespaceUnit->setEnabled(false);
247 if (!interlinespaceED->text().isEmpty())
248 set(Tabular::SET_INTERLINE_SPACE,
249 widgetsToLength(interlinespaceED, interlinespaceUnit));
250 if (!bc().policy().isReadOnly()) {
251 interlinespaceED->setEnabled(true);
252 interlinespaceUnit->setEnabled(true);
261 void GuiTabular::close_clicked()
268 void GuiTabular::borderSet_clicked()
270 set(Tabular::SET_ALL_LINES);
276 void GuiTabular::borderUnset_clicked()
278 set(Tabular::UNSET_ALL_LINES);
284 void GuiTabular::leftBorder_changed()
286 set(Tabular::TOGGLE_LINE_LEFT);
291 void GuiTabular::rightBorder_changed()
293 set(Tabular::TOGGLE_LINE_RIGHT);
298 void GuiTabular::topBorder_changed()
300 set(Tabular::TOGGLE_LINE_TOP);
305 void GuiTabular::bottomBorder_changed()
307 set(Tabular::TOGGLE_LINE_BOTTOM);
312 void GuiTabular::specialAlignment_changed()
314 string special = fromqstr(specialAlignmentED->text());
320 void GuiTabular::width_changed()
323 string const width = widgetsToLength(widthED, widthUnit);
328 void GuiTabular::multicolumn_clicked()
335 void GuiTabular::rotateTabular()
337 rotateTabular(rotateTabularCB->isChecked());
342 void GuiTabular::rotateCell()
344 rotateCell(rotateCellCB->isChecked());
349 void GuiTabular::hAlign_changed(int align)
351 GuiTabular::HALIGN h = GuiTabular::LEFT;
354 case 0: h = GuiTabular::LEFT; break;
355 case 1: h = GuiTabular::CENTER; break;
356 case 2: h = GuiTabular::RIGHT; break;
357 case 3: h = GuiTabular::BLOCK; break;
364 void GuiTabular::vAlign_changed(int align)
366 GuiTabular::VALIGN v = GuiTabular::TOP;
369 case 0: v = GuiTabular::TOP; break;
370 case 1: v = GuiTabular::MIDDLE; break;
371 case 2: v = GuiTabular::BOTTOM; break;
378 void GuiTabular::longTabular()
380 longTabular(longTabularCB->isChecked());
385 void GuiTabular::ltNewpage_clicked()
387 set(Tabular::SET_LTNEWPAGE);
392 void GuiTabular::ltHeaderStatus_clicked()
394 bool enable = headerStatusCB->isChecked();
396 set(Tabular::SET_LTHEAD, "");
398 set(Tabular::UNSET_LTHEAD, "");
399 headerBorderAboveCB->setEnabled(enable);
400 headerBorderBelowCB->setEnabled(enable);
401 firstheaderNoContentsCB->setEnabled(enable);
406 void GuiTabular::ltHeaderBorderAbove_clicked()
408 if (headerBorderAboveCB->isChecked())
409 set(Tabular::SET_LTHEAD, "dl_above");
411 set(Tabular::UNSET_LTHEAD, "dl_above");
416 void GuiTabular::ltHeaderBorderBelow_clicked()
418 if (headerBorderBelowCB->isChecked())
419 set(Tabular::SET_LTHEAD, "dl_below");
421 set(Tabular::UNSET_LTHEAD, "dl_below");
426 void GuiTabular::ltFirstHeaderBorderAbove_clicked()
428 if (firstheaderBorderAboveCB->isChecked())
429 set(Tabular::SET_LTFIRSTHEAD, "dl_above");
431 set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
436 void GuiTabular::ltFirstHeaderBorderBelow_clicked()
438 if (firstheaderBorderBelowCB->isChecked())
439 set(Tabular::SET_LTFIRSTHEAD, "dl_below");
441 set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
446 void GuiTabular::ltFirstHeaderStatus_clicked()
448 bool enable = firstheaderStatusCB->isChecked();
450 set(Tabular::SET_LTFIRSTHEAD, "");
452 set(Tabular::UNSET_LTFIRSTHEAD, "");
453 firstheaderBorderAboveCB->setEnabled(enable);
454 firstheaderBorderBelowCB->setEnabled(enable);
459 void GuiTabular::ltFirstHeaderEmpty_clicked()
461 bool enable = firstheaderNoContentsCB->isChecked();
463 set(Tabular::SET_LTFIRSTHEAD, "empty");
465 set(Tabular::UNSET_LTFIRSTHEAD, "empty");
466 firstheaderStatusCB->setEnabled(!enable);
467 firstheaderBorderAboveCB->setEnabled(!enable);
468 firstheaderBorderBelowCB->setEnabled(!enable);
473 void GuiTabular::ltFooterStatus_clicked()
475 bool enable = footerStatusCB->isChecked();
477 set(Tabular::SET_LTFOOT, "");
479 set(Tabular::UNSET_LTFOOT, "");
480 footerBorderAboveCB->setEnabled(enable);
481 footerBorderBelowCB->setEnabled(enable);
482 lastfooterNoContentsCB->setEnabled(enable);
487 void GuiTabular::ltFooterBorderAbove_clicked()
489 if (footerBorderAboveCB->isChecked())
490 set(Tabular::SET_LTFOOT, "dl_above");
492 set(Tabular::UNSET_LTFOOT, "dl_above");
497 void GuiTabular::ltFooterBorderBelow_clicked()
499 if (footerBorderBelowCB->isChecked())
500 set(Tabular::SET_LTFOOT, "dl_below");
502 set(Tabular::UNSET_LTFOOT, "dl_below");
507 void GuiTabular::ltLastFooterStatus_clicked()
509 bool enable = lastfooterStatusCB->isChecked();
511 set(Tabular::SET_LTLASTFOOT, "");
513 set(Tabular::UNSET_LTLASTFOOT, "");
514 lastfooterBorderAboveCB->setEnabled(enable);
515 lastfooterBorderBelowCB->setEnabled(enable);
520 void GuiTabular::ltLastFooterBorderAbove_clicked()
522 if (lastfooterBorderAboveCB->isChecked())
523 set(Tabular::SET_LTLASTFOOT, "dl_above");
525 set(Tabular::UNSET_LTLASTFOOT, "dl_above");
530 void GuiTabular::ltLastFooterBorderBelow_clicked()
532 if (lastfooterBorderBelowCB->isChecked())
533 set(Tabular::SET_LTLASTFOOT, "dl_below");
535 set(Tabular::UNSET_LTLASTFOOT, "dl_below");
540 void GuiTabular::ltLastFooterEmpty_clicked()
542 bool enable = lastfooterNoContentsCB->isChecked();
544 set(Tabular::SET_LTLASTFOOT, "empty");
546 set(Tabular::UNSET_LTLASTFOOT, "empty");
547 lastfooterStatusCB->setEnabled(!enable);
548 lastfooterBorderAboveCB->setEnabled(!enable);
549 lastfooterBorderBelowCB->setEnabled(!enable);
554 void GuiTabular::update_borders()
556 Tabular::idx_type const cell = getActiveCell();
557 borders->setTop(tabular_.topLine(cell));
558 borders->setBottom(tabular_.bottomLine(cell));
559 borders->setLeft(tabular_.leftLine(cell));
560 borders->setRight(tabular_.rightLine(cell));
561 // repaint the setborder widget
566 void GuiTabular::updateContents()
568 initialiseParams(string());
570 Tabular::idx_type const cell = getActiveCell();
572 Tabular::row_type const row = tabular_.cellRow(cell);
573 Tabular::col_type const col = tabular_.cellColumn(cell);
575 tabularRowED->setText(QString::number(row + 1));
576 tabularColumnED->setText(QString::number(col + 1));
578 bool const multicol(tabular_.isMultiColumn(cell));
580 multicolumnCB->setChecked(multicol);
582 rotateCellCB->setChecked(tabular_.getRotateCell(cell));
583 rotateTabularCB->setChecked(tabular_.getRotateTabular());
585 longTabularCB->setChecked(tabular_.isLongTabular());
593 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
594 pwidth = tabular_.getMColumnPWidth(cell);
596 special = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
597 pwidth = tabular_.getColumnPWidth(cell);
600 specialAlignmentED->setText(toqstr(special));
602 bool const isReadonly = bc().policy().isReadOnly();
603 specialAlignmentED->setEnabled(!isReadonly);
605 Length::UNIT default_unit =
606 useMetricUnits() ? Length::CM : Length::IN;
608 borderDefaultRB->setChecked(!tabular_.useBookTabs());
609 booktabsRB->setChecked(tabular_.useBookTabs());
611 if (tabular_.row_info[row].top_space.empty()
612 && !tabular_.row_info[row].top_space_default) {
613 topspaceCO->setCurrentIndex(0);
614 } else if (tabular_.row_info[row].top_space_default) {
615 topspaceCO->setCurrentIndex(1);
617 topspaceCO->setCurrentIndex(2);
618 lengthToWidgets(topspaceED,
620 tabular_.row_info[row].top_space.asString(),
623 topspaceED->setEnabled(!isReadonly
624 && (topspaceCO->currentIndex() == 2));
625 topspaceUnit->setEnabled(!isReadonly
626 && (topspaceCO->currentIndex() == 2));
627 topspaceCO->setEnabled(!isReadonly);
629 if (tabular_.row_info[row].bottom_space.empty()
630 && !tabular_.row_info[row].bottom_space_default) {
631 bottomspaceCO->setCurrentIndex(0);
632 } else if (tabular_.row_info[row].bottom_space_default) {
633 bottomspaceCO->setCurrentIndex(1);
635 bottomspaceCO->setCurrentIndex(2);
636 lengthToWidgets(bottomspaceED,
638 tabular_.row_info[row].bottom_space.asString(),
641 bottomspaceED->setEnabled(!isReadonly
642 && (bottomspaceCO->currentIndex() == 2));
643 bottomspaceUnit->setEnabled(!isReadonly
644 && (bottomspaceCO->currentIndex() == 2));
645 bottomspaceCO->setEnabled(!isReadonly);
647 if (tabular_.row_info[row].interline_space.empty()
648 && !tabular_.row_info[row].interline_space_default) {
649 interlinespaceCO->setCurrentIndex(0);
650 } else if (tabular_.row_info[row].interline_space_default) {
651 interlinespaceCO->setCurrentIndex(1);
653 interlinespaceCO->setCurrentIndex(2);
654 lengthToWidgets(interlinespaceED,
656 tabular_.row_info[row].interline_space.asString(),
659 interlinespaceED->setEnabled(!isReadonly
660 && (interlinespaceCO->currentIndex() == 2));
661 interlinespaceUnit->setEnabled(!isReadonly
662 && (interlinespaceCO->currentIndex() == 2));
663 interlinespaceCO->setEnabled(!isReadonly);
667 colwidth = pwidth.asString();
668 lengthToWidgets(widthED, widthUnit,
669 colwidth, default_unit);
671 widthED->setEnabled(!isReadonly);
672 widthUnit->setEnabled(!isReadonly);
675 hAlignCB->addItem(qt_("Left"));
676 hAlignCB->addItem(qt_("Center"));
677 hAlignCB->addItem(qt_("Right"));
678 if (!multicol && !pwidth.zero())
679 hAlignCB->addItem(qt_("Justified"));
682 switch (tabular_.getAlignment(cell)) {
686 case LYX_ALIGN_CENTER:
689 case LYX_ALIGN_RIGHT:
692 case LYX_ALIGN_BLOCK:
694 if (!multicol && !pwidth.zero())
702 hAlignCB->setCurrentIndex(align);
705 switch (tabular_.getVAlignment(cell)) {
706 case Tabular::LYX_VALIGN_TOP:
709 case Tabular::LYX_VALIGN_MIDDLE:
712 case Tabular::LYX_VALIGN_BOTTOM:
721 vAlignCB->setCurrentIndex(valign);
723 hAlignCB->setEnabled(true);
724 vAlignCB->setEnabled(!pwidth.zero());
726 if (!tabular_.isLongTabular()) {
727 headerStatusCB->setChecked(false);
728 headerBorderAboveCB->setChecked(false);
729 headerBorderBelowCB->setChecked(false);
730 firstheaderStatusCB->setChecked(false);
731 firstheaderBorderAboveCB->setChecked(false);
732 firstheaderBorderBelowCB->setChecked(false);
733 firstheaderNoContentsCB->setChecked(false);
734 footerStatusCB->setChecked(false);
735 footerBorderAboveCB->setChecked(false);
736 footerBorderBelowCB->setChecked(false);
737 lastfooterStatusCB->setChecked(false);
738 lastfooterBorderAboveCB->setChecked(false);
739 lastfooterBorderBelowCB->setChecked(false);
740 lastfooterNoContentsCB->setChecked(false);
741 newpageCB->setChecked(false);
742 newpageCB->setEnabled(false);
748 bool row_set = tabular_.getRowOfLTHead(row, ltt);
749 headerStatusCB->setChecked(row_set);
751 headerBorderAboveCB->setChecked(ltt.topDL);
752 headerBorderBelowCB->setChecked(ltt.bottomDL);
755 headerBorderAboveCB->setChecked(false);
756 headerBorderBelowCB->setChecked(false);
757 headerBorderAboveCB->setEnabled(false);
758 headerBorderBelowCB->setEnabled(false);
759 firstheaderNoContentsCB->setChecked(false);
760 firstheaderNoContentsCB->setEnabled(false);
764 row_set = tabular_.getRowOfLTFirstHead(row, ltt);
765 firstheaderStatusCB->setChecked(row_set);
766 if (ltt.set && (!ltt.empty || !use_empty)) {
767 firstheaderBorderAboveCB->setChecked(ltt.topDL);
768 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
770 firstheaderBorderAboveCB->setEnabled(false);
771 firstheaderBorderBelowCB->setEnabled(false);
772 firstheaderBorderAboveCB->setChecked(false);
773 firstheaderBorderBelowCB->setChecked(false);
775 firstheaderNoContentsCB->setChecked(ltt.empty);
777 firstheaderStatusCB->setEnabled(false);
781 row_set = tabular_.getRowOfLTFoot(row, ltt);
782 footerStatusCB->setChecked(row_set);
784 footerBorderAboveCB->setChecked(ltt.topDL);
785 footerBorderBelowCB->setChecked(ltt.bottomDL);
788 footerBorderAboveCB->setChecked(false);
789 footerBorderBelowCB->setChecked(false);
790 footerBorderAboveCB->setEnabled(false);
791 footerBorderBelowCB->setEnabled(false);
792 lastfooterNoContentsCB->setChecked(false);
793 lastfooterNoContentsCB->setEnabled(false);
797 row_set = tabular_.getRowOfLTLastFoot(row, ltt);
798 lastfooterStatusCB->setChecked(row_set);
799 if (ltt.set && (!ltt.empty || !use_empty)) {
800 lastfooterBorderAboveCB->setChecked(ltt.topDL);
801 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
803 lastfooterBorderAboveCB->setEnabled(false);
804 lastfooterBorderBelowCB->setEnabled(false);
805 lastfooterBorderAboveCB->setChecked(false);
806 lastfooterBorderBelowCB->setChecked(false);
808 lastfooterNoContentsCB->setChecked(ltt.empty);
810 lastfooterStatusCB->setEnabled(false);
813 newpageCB->setChecked(tabular_.getLTNewPage(row));
817 void GuiTabular::closeGUI()
819 // ugly hack to auto-apply the stuff that hasn't been
820 // yet. don't let this continue to exist ...
822 // Subtle here, we must /not/ apply any changes and
823 // then refer to tabular, as it will have been freed
824 // since the changes update the actual tabular_
826 // apply the fixed width values
827 Tabular::idx_type const cell = getActiveCell();
828 bool const multicol = tabular_.isMultiColumn(cell);
829 string width = widgetsToLength(widthED, widthUnit);
832 Length llen = tabular_.getColumnPWidth(cell);
833 Length llenMulti = tabular_.getMColumnPWidth(cell);
835 if (multicol && !llenMulti.zero())
836 width2 = llenMulti.asString();
837 else if (!multicol && !llen.zero())
838 width2 = llen.asString();
840 // apply the special alignment
841 docstring const sa1 = qstring_to_ucs4(specialAlignmentED->text());
845 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
847 sa2 = tabular_.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
851 set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
853 set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
856 if (width != width2) {
858 set(Tabular::SET_MPWIDTH, width);
860 set(Tabular::SET_PWIDTH, width);
864 switch (topspaceCO->currentIndex()) {
866 set(Tabular::SET_TOP_SPACE, "");
869 set(Tabular::SET_TOP_SPACE, "default");
872 set(Tabular::SET_TOP_SPACE,
873 widgetsToLength(topspaceED, topspaceUnit));
877 switch (bottomspaceCO->currentIndex()) {
879 set(Tabular::SET_BOTTOM_SPACE, "");
882 set(Tabular::SET_BOTTOM_SPACE, "default");
885 set(Tabular::SET_BOTTOM_SPACE,
886 widgetsToLength(bottomspaceED, bottomspaceUnit));
890 switch (interlinespaceCO->currentIndex()) {
892 set(Tabular::SET_INTERLINE_SPACE, "");
895 set(Tabular::SET_INTERLINE_SPACE, "default");
898 set(Tabular::SET_INTERLINE_SPACE,
899 widgetsToLength(interlinespaceED, interlinespaceUnit));
906 bool GuiTabular::initialiseParams(string const & data)
908 // try to get the current cell
909 BufferView const * const bv = bufferview();
910 InsetTabular const * current_inset = 0;
912 Cursor const & cur = bv->cursor();
913 // get the innermost tabular inset;
914 // assume that it is "ours"
915 for (int i = cur.depth() - 1; i >= 0; --i)
916 if (cur[i].inset().lyxCode() == TABULAR_CODE) {
917 current_inset = static_cast<InsetTabular const *>(&cur[i].inset());
918 active_cell_ = cur[i].idx();
923 if (current_inset && data.empty()) {
924 tabular_ = Tabular(current_inset->tabular);
928 InsetTabular tmp(buffer());
929 InsetTabularMailer::string2params(data, tmp);
930 tabular_ = Tabular(tmp.tabular);
935 void GuiTabular::clearParams()
937 InsetTabular tmp(buffer());
938 tabular_ = tmp.tabular;
939 active_cell_ = Tabular::npos;
943 Tabular::idx_type GuiTabular::getActiveCell() const
949 void GuiTabular::set(Tabular::Feature f, string const & arg)
951 string const data = featureAsString(f) + ' ' + arg;
952 dispatch(FuncRequest(getLfun(), data));
956 bool GuiTabular::useMetricUnits() const
958 return lyxrc.default_papersize > PAPER_USEXECUTIVE;
962 void GuiTabular::setSpecial(string const & special)
964 if (tabular_.isMultiColumn(getActiveCell()))
965 set(Tabular::SET_SPECIAL_MULTI, special);
967 set(Tabular::SET_SPECIAL_COLUMN, special);
971 void GuiTabular::setWidth(string const & width)
973 if (tabular_.isMultiColumn(getActiveCell()))
974 set(Tabular::SET_MPWIDTH, width);
976 set(Tabular::SET_PWIDTH, width);
982 void GuiTabular::toggleMultiColumn()
984 set(Tabular::MULTICOLUMN);
989 void GuiTabular::rotateTabular(bool yes)
992 set(Tabular::SET_ROTATE_TABULAR);
994 set(Tabular::UNSET_ROTATE_TABULAR);
998 void GuiTabular::rotateCell(bool yes)
1001 set(Tabular::SET_ROTATE_CELL);
1003 set(Tabular::UNSET_ROTATE_CELL);
1007 void GuiTabular::halign(GuiTabular::HALIGN h)
1009 Tabular::Feature num = Tabular::ALIGN_LEFT;
1010 Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
1014 num = Tabular::ALIGN_LEFT;
1015 multi_num = Tabular::M_ALIGN_LEFT;
1018 num = Tabular::ALIGN_CENTER;
1019 multi_num = Tabular::M_ALIGN_CENTER;
1022 num = Tabular::ALIGN_RIGHT;
1023 multi_num = Tabular::M_ALIGN_RIGHT;
1026 num = Tabular::ALIGN_BLOCK;
1027 //multi_num: no equivalent
1031 if (tabular_.isMultiColumn(getActiveCell()))
1038 void GuiTabular::valign(GuiTabular::VALIGN v)
1040 Tabular::Feature num = Tabular::VALIGN_MIDDLE;
1041 Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
1045 num = Tabular::VALIGN_TOP;
1046 multi_num = Tabular::M_VALIGN_TOP;
1049 num = Tabular::VALIGN_MIDDLE;
1050 multi_num = Tabular::M_VALIGN_MIDDLE;
1053 num = Tabular::VALIGN_BOTTOM;
1054 multi_num = Tabular::M_VALIGN_BOTTOM;
1058 if (tabular_.isMultiColumn(getActiveCell()))
1065 void GuiTabular::booktabs(bool yes)
1068 set(Tabular::SET_BOOKTABS);
1070 set(Tabular::UNSET_BOOKTABS);
1074 void GuiTabular::longTabular(bool yes)
1077 set(Tabular::SET_LONGTABULAR);
1079 set(Tabular::UNSET_LONGTABULAR);
1083 Dialog * createGuiTabular(GuiView & lv) { return new GuiTabular(lv); }
1086 } // namespace frontend
1089 #include "GuiTabular_moc.cpp"