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"
18 #include "LengthCombo.h"
19 #include "Validator.h"
20 #include "qt_helpers.h"
22 #include "support/convert.h"
24 #include <QCloseEvent>
26 #include <QPushButton>
27 #include <QRadioButton>
35 /////////////////////////////////////////////////////////////////////
39 /////////////////////////////////////////////////////////////////////
41 GuiTabularDialog::GuiTabularDialog(GuiTabular * form)
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()));
104 void GuiTabularDialog::change_adaptor()
110 void GuiTabularDialog::closeEvent(QCloseEvent * e)
117 void GuiTabularDialog::booktabsChanged(bool)
120 form_->controller().booktabs(booktabsRB->isChecked());
121 form_->update_borders();
125 void GuiTabularDialog::topspace_changed()
127 switch(topspaceCO->currentIndex()) {
129 form_->controller().set(Tabular::SET_TOP_SPACE, "");
130 topspaceED->setEnabled(false);
131 topspaceUnit->setEnabled(false);
135 form_->controller().set(Tabular::SET_TOP_SPACE, "default");
136 topspaceED->setEnabled(false);
137 topspaceUnit->setEnabled(false);
141 if (!topspaceED->text().isEmpty())
142 form_->controller().set(Tabular::SET_TOP_SPACE,
143 widgetsToLength(topspaceED, topspaceUnit));
144 if (!form_->bc().policy().isReadOnly()) {
145 topspaceED->setEnabled(true);
146 topspaceUnit->setEnabled(true);
155 void GuiTabularDialog::bottomspace_changed()
157 switch(bottomspaceCO->currentIndex()) {
159 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "");
160 bottomspaceED->setEnabled(false);
161 bottomspaceUnit->setEnabled(false);
165 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "default");
166 bottomspaceED->setEnabled(false);
167 bottomspaceUnit->setEnabled(false);
171 if (!bottomspaceED->text().isEmpty())
172 form_->controller().set(Tabular::SET_BOTTOM_SPACE,
173 widgetsToLength(bottomspaceED, bottomspaceUnit));
174 if (!form_->bc().policy().isReadOnly()) {
175 bottomspaceED->setEnabled(true);
176 bottomspaceUnit->setEnabled(true);
185 void GuiTabularDialog::interlinespace_changed()
187 switch(interlinespaceCO->currentIndex()) {
189 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "");
190 interlinespaceED->setEnabled(false);
191 interlinespaceUnit->setEnabled(false);
195 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "default");
196 interlinespaceED->setEnabled(false);
197 interlinespaceUnit->setEnabled(false);
201 if (!interlinespaceED->text().isEmpty())
202 form_->controller().set(Tabular::SET_INTERLINE_SPACE,
203 widgetsToLength(interlinespaceED, interlinespaceUnit));
204 if (!form_->bc().policy().isReadOnly()) {
205 interlinespaceED->setEnabled(true);
206 interlinespaceUnit->setEnabled(true);
215 void GuiTabularDialog::close_clicked()
222 void GuiTabularDialog::borderSet_clicked()
224 form_->controller().set(Tabular::SET_ALL_LINES);
225 form_->update_borders();
230 void GuiTabularDialog::borderUnset_clicked()
232 form_->controller().set(Tabular::UNSET_ALL_LINES);
233 form_->update_borders();
238 void GuiTabularDialog::leftBorder_changed()
240 form_->controller().toggleLeftLine();
245 void GuiTabularDialog::rightBorder_changed()
247 form_->controller().toggleRightLine();
252 void GuiTabularDialog::topBorder_changed()
254 form_->controller().toggleTopLine();
259 void GuiTabularDialog::bottomBorder_changed()
261 form_->controller().toggleBottomLine();
266 void GuiTabularDialog::specialAlignment_changed()
268 string special = fromqstr(specialAlignmentED->text());
269 form_->controller().setSpecial(special);
274 void GuiTabularDialog::width_changed()
277 string const width = widgetsToLength(widthED, widthUnit);
278 form_->controller().setWidth(width);
282 void GuiTabularDialog::multicolumn_clicked()
284 form_->controller().toggleMultiColumn();
289 void GuiTabularDialog::rotateTabular()
291 form_->controller().rotateTabular(rotateTabularCB->isChecked());
296 void GuiTabularDialog::rotateCell()
298 form_->controller().rotateCell(rotateCellCB->isChecked());
303 void GuiTabularDialog::hAlign_changed(int align)
305 ControlTabular::HALIGN h = ControlTabular::LEFT;
308 case 0: h = ControlTabular::LEFT; break;
309 case 1: h = ControlTabular::CENTER; break;
310 case 2: h = ControlTabular::RIGHT; break;
311 case 3: h = ControlTabular::BLOCK; break;
314 form_->controller().halign(h);
318 void GuiTabularDialog::vAlign_changed(int align)
320 ControlTabular::VALIGN v = ControlTabular::TOP;
323 case 0: v = ControlTabular::TOP; break;
324 case 1: v = ControlTabular::MIDDLE; break;
325 case 2: v = ControlTabular::BOTTOM; break;
328 form_->controller().valign(v);
332 void GuiTabularDialog::longTabular()
334 form_->controller().longTabular(longTabularCB->isChecked());
339 void GuiTabularDialog::ltNewpage_clicked()
341 form_->controller().set(Tabular::SET_LTNEWPAGE);
346 void GuiTabularDialog::ltHeaderStatus_clicked()
348 bool enable(headerStatusCB->isChecked());
350 form_->controller().set(Tabular::SET_LTHEAD, "");
352 form_->controller().set(Tabular::UNSET_LTHEAD, "");
353 headerBorderAboveCB->setEnabled(enable);
354 headerBorderBelowCB->setEnabled(enable);
355 firstheaderNoContentsCB->setEnabled(enable);
360 void GuiTabularDialog::ltHeaderBorderAbove_clicked()
362 if (headerBorderAboveCB->isChecked())
363 form_->controller().set(Tabular::SET_LTHEAD, "dl_above");
365 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_above");
370 void GuiTabularDialog::ltHeaderBorderBelow_clicked()
372 if (headerBorderBelowCB->isChecked())
373 form_->controller().set(Tabular::SET_LTHEAD, "dl_below");
375 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_below");
380 void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
382 if (firstheaderBorderAboveCB->isChecked())
383 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
385 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
390 void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
392 if (firstheaderBorderBelowCB->isChecked())
393 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
395 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
400 void GuiTabularDialog::ltFirstHeaderStatus_clicked()
402 bool enable(firstheaderStatusCB->isChecked());
404 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "");
406 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
407 firstheaderBorderAboveCB->setEnabled(enable);
408 firstheaderBorderBelowCB->setEnabled(enable);
413 void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
415 bool enable(firstheaderNoContentsCB->isChecked());
417 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
419 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
420 firstheaderStatusCB->setEnabled(!enable);
421 firstheaderBorderAboveCB->setEnabled(!enable);
422 firstheaderBorderBelowCB->setEnabled(!enable);
427 void GuiTabularDialog::ltFooterStatus_clicked()
429 bool enable(footerStatusCB->isChecked());
431 form_->controller().set(Tabular::SET_LTFOOT, "");
433 form_->controller().set(Tabular::UNSET_LTFOOT, "");
434 footerBorderAboveCB->setEnabled(enable);
435 footerBorderBelowCB->setEnabled(enable);
436 lastfooterNoContentsCB->setEnabled(enable);
441 void GuiTabularDialog::ltFooterBorderAbove_clicked()
443 if (footerBorderAboveCB->isChecked())
444 form_->controller().set(Tabular::SET_LTFOOT, "dl_above");
446 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_above");
451 void GuiTabularDialog::ltFooterBorderBelow_clicked()
453 if (footerBorderBelowCB->isChecked())
454 form_->controller().set(Tabular::SET_LTFOOT, "dl_below");
456 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_below");
461 void GuiTabularDialog::ltLastFooterStatus_clicked()
463 bool enable(lastfooterStatusCB->isChecked());
465 form_->controller().set(Tabular::SET_LTLASTFOOT, "");
467 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "");
468 lastfooterBorderAboveCB->setEnabled(enable);
469 lastfooterBorderBelowCB->setEnabled(enable);
474 void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
476 if (lastfooterBorderAboveCB->isChecked())
477 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
479 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
484 void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
486 if (lastfooterBorderBelowCB->isChecked())
487 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
489 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
494 void GuiTabularDialog::ltLastFooterEmpty_clicked()
496 bool enable(lastfooterNoContentsCB->isChecked());
498 form_->controller().set(Tabular::SET_LTLASTFOOT, "empty");
500 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
501 lastfooterStatusCB->setEnabled(!enable);
502 lastfooterBorderAboveCB->setEnabled(!enable);
503 lastfooterBorderBelowCB->setEnabled(!enable);
508 /////////////////////////////////////////////////////////////////////
512 /////////////////////////////////////////////////////////////////////
515 GuiTabular::GuiTabular(GuiDialog & parent)
516 : GuiView<GuiTabularDialog>(parent, _("Table Settings"))
521 void GuiTabular::build_dialog()
523 dialog_.reset(new GuiTabularDialog(this));
525 bc().setCancel(dialog_->closePB);
527 bc().addReadOnly(dialog_->topspaceED);
528 bc().addReadOnly(dialog_->topspaceUnit);
529 bc().addReadOnly(dialog_->topspaceCO);
530 bc().addReadOnly(dialog_->bottomspaceED);
531 bc().addReadOnly(dialog_->bottomspaceUnit);
532 bc().addReadOnly(dialog_->bottomspaceCO);
533 bc().addReadOnly(dialog_->interlinespaceED);
534 bc().addReadOnly(dialog_->interlinespaceUnit);
535 bc().addReadOnly(dialog_->interlinespaceCO);
536 bc().addReadOnly(dialog_->borderDefaultRB);
537 bc().addReadOnly(dialog_->booktabsRB);
539 bc().addReadOnly(dialog_->multicolumnCB);
540 bc().addReadOnly(dialog_->rotateCellCB);
541 bc().addReadOnly(dialog_->rotateTabularCB);
542 bc().addReadOnly(dialog_->specialAlignmentED);
543 bc().addReadOnly(dialog_->widthED);
544 bc().addReadOnly(dialog_->widthUnit);
545 bc().addReadOnly(dialog_->hAlignCB);
546 bc().addReadOnly(dialog_->vAlignCB);
547 bc().addReadOnly(dialog_->borderSetPB);
548 bc().addReadOnly(dialog_->borderUnsetPB);
549 bc().addReadOnly(dialog_->borders);
550 bc().addReadOnly(dialog_->longTabularCB);
551 bc().addReadOnly(dialog_->headerStatusCB);
552 bc().addReadOnly(dialog_->headerBorderAboveCB);
553 bc().addReadOnly(dialog_->headerBorderBelowCB);
554 bc().addReadOnly(dialog_->firstheaderStatusCB);
555 bc().addReadOnly(dialog_->firstheaderBorderAboveCB);
556 bc().addReadOnly(dialog_->firstheaderBorderBelowCB);
557 bc().addReadOnly(dialog_->firstheaderNoContentsCB);
558 bc().addReadOnly(dialog_->footerStatusCB);
559 bc().addReadOnly(dialog_->footerBorderAboveCB);
560 bc().addReadOnly(dialog_->footerBorderBelowCB);
561 bc().addReadOnly(dialog_->lastfooterStatusCB);
562 bc().addReadOnly(dialog_->lastfooterBorderAboveCB);
563 bc().addReadOnly(dialog_->lastfooterBorderBelowCB);
564 bc().addReadOnly(dialog_->lastfooterNoContentsCB);
565 bc().addReadOnly(dialog_->newpageCB);
567 // initialize the length validator
568 bc().addCheckedLineEdit(dialog_->widthED, dialog_->fixedWidthColLA);
569 bc().addCheckedLineEdit(dialog_->topspaceED, dialog_->topspaceLA);
570 bc().addCheckedLineEdit(dialog_->bottomspaceED, dialog_->bottomspaceLA);
571 bc().addCheckedLineEdit(dialog_->interlinespaceED, dialog_->interlinespaceLA);
575 bool GuiTabular::isValid()
581 void GuiTabular::update_borders()
583 Tabular const & tabular = controller().tabular();
584 Tabular::idx_type const cell = controller().getActiveCell();
585 bool const isMulticolumnCell = tabular.isMultiColumn(cell);
587 if (!isMulticolumnCell) {
588 dialog_->borders->setLeftEnabled(true);
589 dialog_->borders->setRightEnabled(true);
590 dialog_->borders->setTop(tabular.topLine(cell, true));
591 dialog_->borders->setBottom(tabular.bottomLine(cell, true));
592 dialog_->borders->setLeft(tabular.leftLine(cell, true));
593 dialog_->borders->setRight(tabular.rightLine(cell, true));
594 // repaint the setborder widget
595 dialog_->borders->update();
599 dialog_->borders->setTop(tabular.topLine(cell));
600 dialog_->borders->setBottom(tabular.bottomLine(cell));
601 // pay attention to left/right lines: they are only allowed
602 // to set if we are in first/last cell of row or if the left/right
603 // cell is also a multicolumn.
604 if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
605 dialog_->borders->setLeftEnabled(true);
606 dialog_->borders->setLeft(tabular.leftLine(cell));
608 dialog_->borders->setLeft(false);
609 dialog_->borders->setLeftEnabled(false);
611 if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
612 dialog_->borders->setRightEnabled(true);
613 dialog_->borders->setRight(tabular.rightLine(cell));
615 dialog_->borders->setRight(false);
616 dialog_->borders->setRightEnabled(false);
618 // repaint the setborder widget
619 dialog_->borders->update();
623 void GuiTabular::update_contents()
625 controller().initialiseParams(string());
627 Tabular const & tabular(controller().tabular());
628 Tabular::idx_type const cell = controller().getActiveCell();
630 Tabular::row_type const row = tabular.cellRow(cell);
631 Tabular::col_type const col = tabular.cellColumn(cell);
633 dialog_->tabularRowED->setText(toqstr(convert<string>(row + 1)));
634 dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
636 bool const multicol(tabular.isMultiColumn(cell));
638 dialog_->multicolumnCB->setChecked(multicol);
640 dialog_->rotateCellCB->setChecked(tabular.getRotateCell(cell));
641 dialog_->rotateTabularCB->setChecked(tabular.getRotateTabular());
643 dialog_->longTabularCB->setChecked(tabular.isLongTabular());
651 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
652 pwidth = tabular.getMColumnPWidth(cell);
654 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
655 pwidth = tabular.getColumnPWidth(cell);
658 dialog_->specialAlignmentED->setText(toqstr(special));
660 bool const isReadonly = bc().policy().isReadOnly();
661 dialog_->specialAlignmentED->setEnabled(!isReadonly);
663 Length::UNIT default_unit =
664 controller().useMetricUnits() ? Length::CM : Length::IN;
666 dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
667 dialog_->booktabsRB->setChecked(tabular.useBookTabs());
669 if (tabular.row_info[row].top_space.empty()
670 && !tabular.row_info[row].top_space_default) {
671 dialog_->topspaceCO->setCurrentIndex(0);
672 } else if (tabular.row_info[row].top_space_default) {
673 dialog_->topspaceCO->setCurrentIndex(1);
675 dialog_->topspaceCO->setCurrentIndex(2);
676 lengthToWidgets(dialog_->topspaceED,
677 dialog_->topspaceUnit,
678 tabular.row_info[row].top_space.asString(),
681 dialog_->topspaceED->setEnabled(!isReadonly
682 && (dialog_->topspaceCO->currentIndex() == 2));
683 dialog_->topspaceUnit->setEnabled(!isReadonly
684 && (dialog_->topspaceCO->currentIndex() == 2));
685 dialog_->topspaceCO->setEnabled(!isReadonly);
687 if (tabular.row_info[row].bottom_space.empty()
688 && !tabular.row_info[row].bottom_space_default) {
689 dialog_->bottomspaceCO->setCurrentIndex(0);
690 } else if (tabular.row_info[row].bottom_space_default) {
691 dialog_->bottomspaceCO->setCurrentIndex(1);
693 dialog_->bottomspaceCO->setCurrentIndex(2);
694 lengthToWidgets(dialog_->bottomspaceED,
695 dialog_->bottomspaceUnit,
696 tabular.row_info[row].bottom_space.asString(),
699 dialog_->bottomspaceED->setEnabled(!isReadonly
700 && (dialog_->bottomspaceCO->currentIndex() == 2));
701 dialog_->bottomspaceUnit->setEnabled(!isReadonly
702 && (dialog_->bottomspaceCO->currentIndex() == 2));
703 dialog_->bottomspaceCO->setEnabled(!isReadonly);
705 if (tabular.row_info[row].interline_space.empty()
706 && !tabular.row_info[row].interline_space_default) {
707 dialog_->interlinespaceCO->setCurrentIndex(0);
708 } else if (tabular.row_info[row].interline_space_default) {
709 dialog_->interlinespaceCO->setCurrentIndex(1);
711 dialog_->interlinespaceCO->setCurrentIndex(2);
712 lengthToWidgets(dialog_->interlinespaceED,
713 dialog_->interlinespaceUnit,
714 tabular.row_info[row].interline_space.asString(),
717 dialog_->interlinespaceED->setEnabled(!isReadonly
718 && (dialog_->interlinespaceCO->currentIndex() == 2));
719 dialog_->interlinespaceUnit->setEnabled(!isReadonly
720 && (dialog_->interlinespaceCO->currentIndex() == 2));
721 dialog_->interlinespaceCO->setEnabled(!isReadonly);
725 colwidth = pwidth.asString();
726 lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
727 colwidth, default_unit);
729 dialog_->widthED->setEnabled(!isReadonly);
730 dialog_->widthUnit->setEnabled(!isReadonly);
732 dialog_->hAlignCB->clear();
733 dialog_->hAlignCB->addItem(qt_("Left"));
734 dialog_->hAlignCB->addItem(qt_("Center"));
735 dialog_->hAlignCB->addItem(qt_("Right"));
736 if (!multicol && !pwidth.zero())
737 dialog_->hAlignCB->addItem(qt_("Justified"));
740 switch (tabular.getAlignment(cell)) {
744 case LYX_ALIGN_CENTER:
747 case LYX_ALIGN_RIGHT:
750 case LYX_ALIGN_BLOCK:
752 if (!multicol && !pwidth.zero())
760 dialog_->hAlignCB->setCurrentIndex(align);
763 switch (tabular.getVAlignment(cell)) {
764 case Tabular::LYX_VALIGN_TOP:
767 case Tabular::LYX_VALIGN_MIDDLE:
770 case Tabular::LYX_VALIGN_BOTTOM:
779 dialog_->vAlignCB->setCurrentIndex(valign);
781 dialog_->hAlignCB->setEnabled(true);
782 dialog_->vAlignCB->setEnabled(!pwidth.zero());
784 if (!tabular.isLongTabular()) {
785 dialog_->headerStatusCB->setChecked(false);
786 dialog_->headerBorderAboveCB->setChecked(false);
787 dialog_->headerBorderBelowCB->setChecked(false);
788 dialog_->firstheaderStatusCB->setChecked(false);
789 dialog_->firstheaderBorderAboveCB->setChecked(false);
790 dialog_->firstheaderBorderBelowCB->setChecked(false);
791 dialog_->firstheaderNoContentsCB->setChecked(false);
792 dialog_->footerStatusCB->setChecked(false);
793 dialog_->footerBorderAboveCB->setChecked(false);
794 dialog_->footerBorderBelowCB->setChecked(false);
795 dialog_->lastfooterStatusCB->setChecked(false);
796 dialog_->lastfooterBorderAboveCB->setChecked(false);
797 dialog_->lastfooterBorderBelowCB->setChecked(false);
798 dialog_->lastfooterNoContentsCB->setChecked(false);
799 dialog_->newpageCB->setChecked(false);
800 dialog_->newpageCB->setEnabled(false);
806 bool row_set = tabular.getRowOfLTHead(row, ltt);
807 dialog_->headerStatusCB->setChecked(row_set);
809 dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
810 dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
813 dialog_->headerBorderAboveCB->setChecked(false);
814 dialog_->headerBorderBelowCB->setChecked(false);
815 dialog_->headerBorderAboveCB->setEnabled(false);
816 dialog_->headerBorderBelowCB->setEnabled(false);
817 dialog_->firstheaderNoContentsCB->setChecked(false);
818 dialog_->firstheaderNoContentsCB->setEnabled(false);
822 row_set = tabular.getRowOfLTFirstHead(row, ltt);
823 dialog_->firstheaderStatusCB->setChecked(row_set);
824 if (ltt.set && (!ltt.empty || !use_empty)) {
825 dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
826 dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
828 dialog_->firstheaderBorderAboveCB->setEnabled(false);
829 dialog_->firstheaderBorderBelowCB->setEnabled(false);
830 dialog_->firstheaderBorderAboveCB->setChecked(false);
831 dialog_->firstheaderBorderBelowCB->setChecked(false);
833 dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
835 dialog_->firstheaderStatusCB->setEnabled(false);
839 row_set = tabular.getRowOfLTFoot(row, ltt);
840 dialog_->footerStatusCB->setChecked(row_set);
842 dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
843 dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
846 dialog_->footerBorderAboveCB->setChecked(false);
847 dialog_->footerBorderBelowCB->setChecked(false);
848 dialog_->footerBorderAboveCB->setEnabled(false);
849 dialog_->footerBorderBelowCB->setEnabled(false);
850 dialog_->lastfooterNoContentsCB->setChecked(false);
851 dialog_->lastfooterNoContentsCB->setEnabled(false);
855 row_set = tabular.getRowOfLTLastFoot(row, ltt);
856 dialog_->lastfooterStatusCB->setChecked(row_set);
857 if (ltt.set && (!ltt.empty || !use_empty)) {
858 dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
859 dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
861 dialog_->lastfooterBorderAboveCB->setEnabled(false);
862 dialog_->lastfooterBorderBelowCB->setEnabled(false);
863 dialog_->lastfooterBorderAboveCB->setChecked(false);
864 dialog_->lastfooterBorderBelowCB->setChecked(false);
866 dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
868 dialog_->lastfooterStatusCB->setEnabled(false);
871 dialog_->newpageCB->setChecked(tabular.getLTNewPage(row));
875 void GuiTabular::closeGUI()
877 // ugly hack to auto-apply the stuff that hasn't been
878 // yet. don't let this continue to exist ...
880 // Subtle here, we must /not/ apply any changes and
881 // then refer to tabular, as it will have been freed
882 // since the changes update the actual controller().tabular()
883 Tabular const & tabular(controller().tabular());
885 // apply the fixed width values
886 Tabular::idx_type const cell = controller().getActiveCell();
887 bool const multicol = tabular.isMultiColumn(cell);
888 string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
891 Length llen = tabular.getColumnPWidth(cell);
892 Length llenMulti = tabular.getMColumnPWidth(cell);
894 if (multicol && !llenMulti.zero())
895 width2 = llenMulti.asString();
896 else if (!multicol && !llen.zero())
897 width2 = llen.asString();
899 // apply the special alignment
900 docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
904 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
906 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
910 controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
912 controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
915 if (width != width2) {
917 controller().set(Tabular::SET_MPWIDTH, width);
919 controller().set(Tabular::SET_PWIDTH, width);
923 switch (dialog_->topspaceCO->currentIndex()) {
925 controller().set(Tabular::SET_TOP_SPACE, "");
928 controller().set(Tabular::SET_TOP_SPACE, "default");
931 controller().set(Tabular::SET_TOP_SPACE,
932 widgetsToLength(dialog_->topspaceED,
933 dialog_->topspaceUnit));
937 switch (dialog_->bottomspaceCO->currentIndex()) {
939 controller().set(Tabular::SET_BOTTOM_SPACE, "");
942 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
945 controller().set(Tabular::SET_BOTTOM_SPACE,
946 widgetsToLength(dialog_->bottomspaceED,
947 dialog_->bottomspaceUnit));
951 switch (dialog_->interlinespaceCO->currentIndex()) {
953 controller().set(Tabular::SET_INTERLINE_SPACE, "");
956 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
959 controller().set(Tabular::SET_INTERLINE_SPACE,
960 widgetsToLength(dialog_->interlinespaceED,
961 dialog_->interlinespaceUnit));
967 } // namespace frontend
970 #include "GuiTabular_moc.cpp"