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"
20 #include "LengthCombo.h"
21 #include "Validator.h"
22 #include "qt_helpers.h"
24 #include "controllers/ButtonController.h"
26 #include "support/convert.h"
28 #include <QCloseEvent>
30 #include <QPushButton>
31 #include <QRadioButton>
39 /////////////////////////////////////////////////////////////////////
43 /////////////////////////////////////////////////////////////////////
45 GuiTabularDialog::GuiTabularDialog(GuiTabular * form)
50 widthED->setValidator(unsignedLengthValidator(widthED));
51 topspaceED->setValidator(new LengthValidator(topspaceED));
52 bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
53 interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
55 connect(topspaceED, SIGNAL(returnPressed()),
56 this, SLOT(topspace_changed()));
57 connect(topspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
58 this, SLOT(topspace_changed()));
59 connect(topspaceCO, SIGNAL(activated(int)), this, SLOT(topspace_changed()));
60 connect(bottomspaceED, SIGNAL(returnPressed()),
61 this, SLOT(bottomspace_changed()));
62 connect(bottomspaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
63 this, SLOT(bottomspace_changed()));
64 connect(bottomspaceCO, SIGNAL(activated(int)), this, SLOT(bottomspace_changed()));
65 connect(interlinespaceED, SIGNAL(returnPressed()),
66 this, SLOT(interlinespace_changed()));
67 connect(interlinespaceUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)),
68 this, SLOT(interlinespace_changed()));
69 connect(interlinespaceCO, SIGNAL(activated(int)), this, SLOT(interlinespace_changed()));
70 connect(booktabsRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
71 connect(borderDefaultRB, SIGNAL(clicked(bool)), this, SLOT(booktabsChanged(bool)));
72 connect(borderSetPB, SIGNAL(clicked()), this, SLOT(borderSet_clicked()));
73 connect(borderUnsetPB, SIGNAL(clicked()), this, SLOT(borderUnset_clicked()));
74 connect(longTabularCB, SIGNAL(toggled(bool)), longtableGB, SLOT(setEnabled(bool)));
75 connect(longTabularCB, SIGNAL(toggled(bool)), newpageCB, SLOT(setEnabled(bool)));
76 connect(hAlignCB, SIGNAL(activated(int)), this, SLOT(hAlign_changed(int)));
77 connect(vAlignCB, SIGNAL(activated(int)), this, SLOT(vAlign_changed(int)));
78 connect(multicolumnCB, SIGNAL(clicked()), this, SLOT(multicolumn_clicked()));
79 connect(newpageCB, SIGNAL(clicked()), this, SLOT(ltNewpage_clicked()));
80 connect(headerStatusCB, SIGNAL(clicked()), this, SLOT(ltHeaderStatus_clicked()));
81 connect(headerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderAbove_clicked()));
82 connect(headerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltHeaderBorderBelow_clicked()));
83 connect(firstheaderStatusCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderStatus_clicked()));
84 connect(firstheaderBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderAbove_clicked()));
85 connect(firstheaderBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderBorderBelow_clicked()));
86 connect(firstheaderNoContentsCB, SIGNAL(clicked()), this, SLOT(ltFirstHeaderEmpty_clicked()));
87 connect(footerStatusCB, SIGNAL(clicked()), this, SLOT(ltFooterStatus_clicked()));
88 connect(footerBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderAbove_clicked()));
89 connect(footerBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltFooterBorderBelow_clicked()));
90 connect(lastfooterStatusCB, SIGNAL(clicked()), this, SLOT(ltLastFooterStatus_clicked()));
91 connect(lastfooterBorderAboveCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderAbove_clicked()));
92 connect(lastfooterBorderBelowCB, SIGNAL(clicked()), this, SLOT(ltLastFooterBorderBelow_clicked()));
93 connect(lastfooterNoContentsCB, SIGNAL(clicked()), this, SLOT(ltLastFooterEmpty_clicked()));
94 connect(specialAlignmentED, SIGNAL(returnPressed()), this, SLOT(specialAlignment_changed()));
95 connect(widthED, SIGNAL(returnPressed()), this, SLOT(width_changed()));
96 connect(widthUnit, SIGNAL(selectionChanged(lyx::Length::UNIT)), this, SLOT(width_changed()));
97 connect(closePB, SIGNAL(clicked()), this, SLOT(close_clicked()));
98 connect(borders, SIGNAL(topSet(bool)), this, SLOT(topBorder_changed()));
99 connect(borders, SIGNAL(bottomSet(bool)), this, SLOT(bottomBorder_changed()));
100 connect(borders, SIGNAL(rightSet(bool)), this, SLOT(rightBorder_changed()));
101 connect(borders, SIGNAL(leftSet(bool)), this, SLOT(leftBorder_changed()));
102 connect(rotateTabularCB, SIGNAL(clicked()), this, SLOT(rotateTabular()));
103 connect(rotateCellCB, SIGNAL(clicked()), this, SLOT(rotateCell()));
104 connect(longTabularCB, SIGNAL(clicked()), this, SLOT(longTabular()));
108 void GuiTabularDialog::change_adaptor()
114 void GuiTabularDialog::closeEvent(QCloseEvent * e)
121 void GuiTabularDialog::booktabsChanged(bool)
124 form_->controller().booktabs(booktabsRB->isChecked());
125 form_->update_borders();
129 void GuiTabularDialog::topspace_changed()
131 switch(topspaceCO->currentIndex()) {
133 form_->controller().set(Tabular::SET_TOP_SPACE, "");
134 topspaceED->setEnabled(false);
135 topspaceUnit->setEnabled(false);
139 form_->controller().set(Tabular::SET_TOP_SPACE, "default");
140 topspaceED->setEnabled(false);
141 topspaceUnit->setEnabled(false);
145 if (!topspaceED->text().isEmpty())
146 form_->controller().set(Tabular::SET_TOP_SPACE,
147 widgetsToLength(topspaceED, topspaceUnit));
148 if (!form_->bc().policy().isReadOnly()) {
149 topspaceED->setEnabled(true);
150 topspaceUnit->setEnabled(true);
159 void GuiTabularDialog::bottomspace_changed()
161 switch(bottomspaceCO->currentIndex()) {
163 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "");
164 bottomspaceED->setEnabled(false);
165 bottomspaceUnit->setEnabled(false);
169 form_->controller().set(Tabular::SET_BOTTOM_SPACE, "default");
170 bottomspaceED->setEnabled(false);
171 bottomspaceUnit->setEnabled(false);
175 if (!bottomspaceED->text().isEmpty())
176 form_->controller().set(Tabular::SET_BOTTOM_SPACE,
177 widgetsToLength(bottomspaceED, bottomspaceUnit));
178 if (!form_->bc().policy().isReadOnly()) {
179 bottomspaceED->setEnabled(true);
180 bottomspaceUnit->setEnabled(true);
189 void GuiTabularDialog::interlinespace_changed()
191 switch(interlinespaceCO->currentIndex()) {
193 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "");
194 interlinespaceED->setEnabled(false);
195 interlinespaceUnit->setEnabled(false);
199 form_->controller().set(Tabular::SET_INTERLINE_SPACE, "default");
200 interlinespaceED->setEnabled(false);
201 interlinespaceUnit->setEnabled(false);
205 if (!interlinespaceED->text().isEmpty())
206 form_->controller().set(Tabular::SET_INTERLINE_SPACE,
207 widgetsToLength(interlinespaceED, interlinespaceUnit));
208 if (!form_->bc().policy().isReadOnly()) {
209 interlinespaceED->setEnabled(true);
210 interlinespaceUnit->setEnabled(true);
219 void GuiTabularDialog::close_clicked()
226 void GuiTabularDialog::borderSet_clicked()
228 form_->controller().set(Tabular::SET_ALL_LINES);
229 form_->update_borders();
234 void GuiTabularDialog::borderUnset_clicked()
236 form_->controller().set(Tabular::UNSET_ALL_LINES);
237 form_->update_borders();
242 void GuiTabularDialog::leftBorder_changed()
244 form_->controller().toggleLeftLine();
249 void GuiTabularDialog::rightBorder_changed()
251 form_->controller().toggleRightLine();
256 void GuiTabularDialog::topBorder_changed()
258 form_->controller().toggleTopLine();
263 void GuiTabularDialog::bottomBorder_changed()
265 form_->controller().toggleBottomLine();
270 void GuiTabularDialog::specialAlignment_changed()
272 string special = fromqstr(specialAlignmentED->text());
273 form_->controller().setSpecial(special);
278 void GuiTabularDialog::width_changed()
281 string const width = widgetsToLength(widthED, widthUnit);
282 form_->controller().setWidth(width);
286 void GuiTabularDialog::multicolumn_clicked()
288 form_->controller().toggleMultiColumn();
293 void GuiTabularDialog::rotateTabular()
295 form_->controller().rotateTabular(rotateTabularCB->isChecked());
300 void GuiTabularDialog::rotateCell()
302 form_->controller().rotateCell(rotateCellCB->isChecked());
307 void GuiTabularDialog::hAlign_changed(int align)
309 ControlTabular::HALIGN h = ControlTabular::LEFT;
312 case 0: h = ControlTabular::LEFT; break;
313 case 1: h = ControlTabular::CENTER; break;
314 case 2: h = ControlTabular::RIGHT; break;
315 case 3: h = ControlTabular::BLOCK; break;
318 form_->controller().halign(h);
322 void GuiTabularDialog::vAlign_changed(int align)
324 ControlTabular::VALIGN v = ControlTabular::TOP;
327 case 0: v = ControlTabular::TOP; break;
328 case 1: v = ControlTabular::MIDDLE; break;
329 case 2: v = ControlTabular::BOTTOM; break;
332 form_->controller().valign(v);
336 void GuiTabularDialog::longTabular()
338 form_->controller().longTabular(longTabularCB->isChecked());
343 void GuiTabularDialog::ltNewpage_clicked()
345 form_->controller().set(Tabular::SET_LTNEWPAGE);
350 void GuiTabularDialog::ltHeaderStatus_clicked()
352 bool enable(headerStatusCB->isChecked());
354 form_->controller().set(Tabular::SET_LTHEAD, "");
356 form_->controller().set(Tabular::UNSET_LTHEAD, "");
357 headerBorderAboveCB->setEnabled(enable);
358 headerBorderBelowCB->setEnabled(enable);
359 firstheaderNoContentsCB->setEnabled(enable);
364 void GuiTabularDialog::ltHeaderBorderAbove_clicked()
366 if (headerBorderAboveCB->isChecked())
367 form_->controller().set(Tabular::SET_LTHEAD, "dl_above");
369 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_above");
374 void GuiTabularDialog::ltHeaderBorderBelow_clicked()
376 if (headerBorderBelowCB->isChecked())
377 form_->controller().set(Tabular::SET_LTHEAD, "dl_below");
379 form_->controller().set(Tabular::UNSET_LTHEAD, "dl_below");
384 void GuiTabularDialog::ltFirstHeaderBorderAbove_clicked()
386 if (firstheaderBorderAboveCB->isChecked())
387 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_above");
389 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_above");
394 void GuiTabularDialog::ltFirstHeaderBorderBelow_clicked()
396 if (firstheaderBorderBelowCB->isChecked())
397 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "dl_below");
399 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "dl_below");
404 void GuiTabularDialog::ltFirstHeaderStatus_clicked()
406 bool enable(firstheaderStatusCB->isChecked());
408 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "");
410 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "");
411 firstheaderBorderAboveCB->setEnabled(enable);
412 firstheaderBorderBelowCB->setEnabled(enable);
417 void GuiTabularDialog::ltFirstHeaderEmpty_clicked()
419 bool enable(firstheaderNoContentsCB->isChecked());
421 form_->controller().set(Tabular::SET_LTFIRSTHEAD, "empty");
423 form_->controller().set(Tabular::UNSET_LTFIRSTHEAD, "empty");
424 firstheaderStatusCB->setEnabled(!enable);
425 firstheaderBorderAboveCB->setEnabled(!enable);
426 firstheaderBorderBelowCB->setEnabled(!enable);
431 void GuiTabularDialog::ltFooterStatus_clicked()
433 bool enable(footerStatusCB->isChecked());
435 form_->controller().set(Tabular::SET_LTFOOT, "");
437 form_->controller().set(Tabular::UNSET_LTFOOT, "");
438 footerBorderAboveCB->setEnabled(enable);
439 footerBorderBelowCB->setEnabled(enable);
440 lastfooterNoContentsCB->setEnabled(enable);
445 void GuiTabularDialog::ltFooterBorderAbove_clicked()
447 if (footerBorderAboveCB->isChecked())
448 form_->controller().set(Tabular::SET_LTFOOT, "dl_above");
450 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_above");
455 void GuiTabularDialog::ltFooterBorderBelow_clicked()
457 if (footerBorderBelowCB->isChecked())
458 form_->controller().set(Tabular::SET_LTFOOT, "dl_below");
460 form_->controller().set(Tabular::UNSET_LTFOOT, "dl_below");
465 void GuiTabularDialog::ltLastFooterStatus_clicked()
467 bool enable(lastfooterStatusCB->isChecked());
469 form_->controller().set(Tabular::SET_LTLASTFOOT, "");
471 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "");
472 lastfooterBorderAboveCB->setEnabled(enable);
473 lastfooterBorderBelowCB->setEnabled(enable);
478 void GuiTabularDialog::ltLastFooterBorderAbove_clicked()
480 if (lastfooterBorderAboveCB->isChecked())
481 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_above");
483 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_above");
488 void GuiTabularDialog::ltLastFooterBorderBelow_clicked()
490 if (lastfooterBorderBelowCB->isChecked())
491 form_->controller().set(Tabular::SET_LTLASTFOOT, "dl_below");
493 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "dl_below");
498 void GuiTabularDialog::ltLastFooterEmpty_clicked()
500 bool enable(lastfooterNoContentsCB->isChecked());
502 form_->controller().set(Tabular::SET_LTLASTFOOT, "empty");
504 form_->controller().set(Tabular::UNSET_LTLASTFOOT, "empty");
505 lastfooterStatusCB->setEnabled(!enable);
506 lastfooterBorderAboveCB->setEnabled(!enable);
507 lastfooterBorderBelowCB->setEnabled(!enable);
512 /////////////////////////////////////////////////////////////////////
516 /////////////////////////////////////////////////////////////////////
519 GuiTabular::GuiTabular(Dialog & parent)
520 : GuiView<GuiTabularDialog>(parent, _("Table Settings"))
525 void GuiTabular::build_dialog()
527 dialog_.reset(new GuiTabularDialog(this));
529 bcview().setCancel(dialog_->closePB);
531 bcview().addReadOnly(dialog_->topspaceED);
532 bcview().addReadOnly(dialog_->topspaceUnit);
533 bcview().addReadOnly(dialog_->topspaceCO);
534 bcview().addReadOnly(dialog_->bottomspaceED);
535 bcview().addReadOnly(dialog_->bottomspaceUnit);
536 bcview().addReadOnly(dialog_->bottomspaceCO);
537 bcview().addReadOnly(dialog_->interlinespaceED);
538 bcview().addReadOnly(dialog_->interlinespaceUnit);
539 bcview().addReadOnly(dialog_->interlinespaceCO);
540 bcview().addReadOnly(dialog_->borderDefaultRB);
541 bcview().addReadOnly(dialog_->booktabsRB);
543 bcview().addReadOnly(dialog_->multicolumnCB);
544 bcview().addReadOnly(dialog_->rotateCellCB);
545 bcview().addReadOnly(dialog_->rotateTabularCB);
546 bcview().addReadOnly(dialog_->specialAlignmentED);
547 bcview().addReadOnly(dialog_->widthED);
548 bcview().addReadOnly(dialog_->widthUnit);
549 bcview().addReadOnly(dialog_->hAlignCB);
550 bcview().addReadOnly(dialog_->vAlignCB);
551 bcview().addReadOnly(dialog_->borderSetPB);
552 bcview().addReadOnly(dialog_->borderUnsetPB);
553 bcview().addReadOnly(dialog_->borders);
554 bcview().addReadOnly(dialog_->longTabularCB);
555 bcview().addReadOnly(dialog_->headerStatusCB);
556 bcview().addReadOnly(dialog_->headerBorderAboveCB);
557 bcview().addReadOnly(dialog_->headerBorderBelowCB);
558 bcview().addReadOnly(dialog_->firstheaderStatusCB);
559 bcview().addReadOnly(dialog_->firstheaderBorderAboveCB);
560 bcview().addReadOnly(dialog_->firstheaderBorderBelowCB);
561 bcview().addReadOnly(dialog_->firstheaderNoContentsCB);
562 bcview().addReadOnly(dialog_->footerStatusCB);
563 bcview().addReadOnly(dialog_->footerBorderAboveCB);
564 bcview().addReadOnly(dialog_->footerBorderBelowCB);
565 bcview().addReadOnly(dialog_->lastfooterStatusCB);
566 bcview().addReadOnly(dialog_->lastfooterBorderAboveCB);
567 bcview().addReadOnly(dialog_->lastfooterBorderBelowCB);
568 bcview().addReadOnly(dialog_->lastfooterNoContentsCB);
569 bcview().addReadOnly(dialog_->newpageCB);
571 // initialize the length validator
572 addCheckedLineEdit(bcview(), dialog_->widthED,
573 dialog_->fixedWidthColLA);
574 addCheckedLineEdit(bcview(), dialog_->topspaceED,
575 dialog_->topspaceLA);
576 addCheckedLineEdit(bcview(), dialog_->bottomspaceED,
577 dialog_->bottomspaceLA);
578 addCheckedLineEdit(bcview(), dialog_->interlinespaceED,
579 dialog_->interlinespaceLA);
583 bool GuiTabular::isValid()
589 void GuiTabular::update_borders()
591 Tabular const & tabular = controller().tabular();
592 Tabular::idx_type const cell = controller().getActiveCell();
593 bool const isMulticolumnCell = tabular.isMultiColumn(cell);
595 if (!isMulticolumnCell) {
596 dialog_->borders->setLeftEnabled(true);
597 dialog_->borders->setRightEnabled(true);
598 dialog_->borders->setTop(tabular.topLine(cell, true));
599 dialog_->borders->setBottom(tabular.bottomLine(cell, true));
600 dialog_->borders->setLeft(tabular.leftLine(cell, true));
601 dialog_->borders->setRight(tabular.rightLine(cell, true));
602 // repaint the setborder widget
603 dialog_->borders->update();
607 dialog_->borders->setTop(tabular.topLine(cell));
608 dialog_->borders->setBottom(tabular.bottomLine(cell));
609 // pay attention to left/right lines: they are only allowed
610 // to set if we are in first/last cell of row or if the left/right
611 // cell is also a multicolumn.
612 if (tabular.isFirstCellInRow(cell) || tabular.isMultiColumn(cell - 1)) {
613 dialog_->borders->setLeftEnabled(true);
614 dialog_->borders->setLeft(tabular.leftLine(cell));
616 dialog_->borders->setLeft(false);
617 dialog_->borders->setLeftEnabled(false);
619 if (tabular.isLastCellInRow(cell) || tabular.isMultiColumn(cell + 1)) {
620 dialog_->borders->setRightEnabled(true);
621 dialog_->borders->setRight(tabular.rightLine(cell));
623 dialog_->borders->setRight(false);
624 dialog_->borders->setRightEnabled(false);
626 // repaint the setborder widget
627 dialog_->borders->update();
631 void GuiTabular::update_contents()
633 controller().initialiseParams(string());
635 Tabular const & tabular(controller().tabular());
636 Tabular::idx_type const cell = controller().getActiveCell();
638 Tabular::row_type const row(tabular.row_of_cell(cell));
639 Tabular::col_type const col(tabular.column_of_cell(cell));
641 dialog_->tabularRowED->setText(toqstr(convert<string>(row + 1)));
642 dialog_->tabularColumnED->setText(toqstr(convert<string>(col + 1)));
644 bool const multicol(tabular.isMultiColumn(cell));
646 dialog_->multicolumnCB->setChecked(multicol);
648 dialog_->rotateCellCB->setChecked(tabular.getRotateCell(cell));
649 dialog_->rotateTabularCB->setChecked(tabular.getRotateTabular());
651 dialog_->longTabularCB->setChecked(tabular.isLongTabular());
659 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
660 pwidth = tabular.getMColumnPWidth(cell);
662 special = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
663 pwidth = tabular.getColumnPWidth(cell);
666 dialog_->specialAlignmentED->setText(toqstr(special));
668 bool const isReadonly = bc().policy().isReadOnly();
669 dialog_->specialAlignmentED->setEnabled(!isReadonly);
671 Length::UNIT default_unit = controller().useMetricUnits() ? Length::CM : Length::IN;
673 dialog_->borderDefaultRB->setChecked(!tabular.useBookTabs());
674 dialog_->booktabsRB->setChecked(tabular.useBookTabs());
676 if (tabular.row_info[row].top_space.empty()
677 && !tabular.row_info[row].top_space_default) {
678 dialog_->topspaceCO->setCurrentIndex(0);
679 } else if (tabular.row_info[row].top_space_default) {
680 dialog_->topspaceCO->setCurrentIndex(1);
682 dialog_->topspaceCO->setCurrentIndex(2);
683 lengthToWidgets(dialog_->topspaceED,
684 dialog_->topspaceUnit,
685 tabular.row_info[row].top_space.asString(),
688 dialog_->topspaceED->setEnabled(!isReadonly
689 && (dialog_->topspaceCO->currentIndex() == 2));
690 dialog_->topspaceUnit->setEnabled(!isReadonly
691 && (dialog_->topspaceCO->currentIndex() == 2));
692 dialog_->topspaceCO->setEnabled(!isReadonly);
694 if (tabular.row_info[row].bottom_space.empty()
695 && !tabular.row_info[row].bottom_space_default) {
696 dialog_->bottomspaceCO->setCurrentIndex(0);
697 } else if (tabular.row_info[row].bottom_space_default) {
698 dialog_->bottomspaceCO->setCurrentIndex(1);
700 dialog_->bottomspaceCO->setCurrentIndex(2);
701 lengthToWidgets(dialog_->bottomspaceED,
702 dialog_->bottomspaceUnit,
703 tabular.row_info[row].bottom_space.asString(),
706 dialog_->bottomspaceED->setEnabled(!isReadonly
707 && (dialog_->bottomspaceCO->currentIndex() == 2));
708 dialog_->bottomspaceUnit->setEnabled(!isReadonly
709 && (dialog_->bottomspaceCO->currentIndex() == 2));
710 dialog_->bottomspaceCO->setEnabled(!isReadonly);
712 if (tabular.row_info[row].interline_space.empty()
713 && !tabular.row_info[row].interline_space_default) {
714 dialog_->interlinespaceCO->setCurrentIndex(0);
715 } else if (tabular.row_info[row].interline_space_default) {
716 dialog_->interlinespaceCO->setCurrentIndex(1);
718 dialog_->interlinespaceCO->setCurrentIndex(2);
719 lengthToWidgets(dialog_->interlinespaceED,
720 dialog_->interlinespaceUnit,
721 tabular.row_info[row].interline_space.asString(),
724 dialog_->interlinespaceED->setEnabled(!isReadonly
725 && (dialog_->interlinespaceCO->currentIndex() == 2));
726 dialog_->interlinespaceUnit->setEnabled(!isReadonly
727 && (dialog_->interlinespaceCO->currentIndex() == 2));
728 dialog_->interlinespaceCO->setEnabled(!isReadonly);
732 colwidth = pwidth.asString();
733 lengthToWidgets(dialog_->widthED, dialog_->widthUnit,
734 colwidth, default_unit);
736 dialog_->widthED->setEnabled(!isReadonly);
737 dialog_->widthUnit->setEnabled(!isReadonly);
739 dialog_->hAlignCB->clear();
740 dialog_->hAlignCB->addItem(qt_("Left"));
741 dialog_->hAlignCB->addItem(qt_("Center"));
742 dialog_->hAlignCB->addItem(qt_("Right"));
743 if (!multicol && !pwidth.zero())
744 dialog_->hAlignCB->addItem(qt_("Justified"));
747 switch (tabular.getAlignment(cell)) {
751 case LYX_ALIGN_CENTER:
754 case LYX_ALIGN_RIGHT:
757 case LYX_ALIGN_BLOCK:
759 if (!multicol && !pwidth.zero())
767 dialog_->hAlignCB->setCurrentIndex(align);
770 switch (tabular.getVAlignment(cell)) {
771 case Tabular::LYX_VALIGN_TOP:
774 case Tabular::LYX_VALIGN_MIDDLE:
777 case Tabular::LYX_VALIGN_BOTTOM:
786 dialog_->vAlignCB->setCurrentIndex(valign);
788 dialog_->hAlignCB->setEnabled(true);
789 dialog_->vAlignCB->setEnabled(!pwidth.zero());
791 if (!tabular.isLongTabular()) {
792 dialog_->headerStatusCB->setChecked(false);
793 dialog_->headerBorderAboveCB->setChecked(false);
794 dialog_->headerBorderBelowCB->setChecked(false);
795 dialog_->firstheaderStatusCB->setChecked(false);
796 dialog_->firstheaderBorderAboveCB->setChecked(false);
797 dialog_->firstheaderBorderBelowCB->setChecked(false);
798 dialog_->firstheaderNoContentsCB->setChecked(false);
799 dialog_->footerStatusCB->setChecked(false);
800 dialog_->footerBorderAboveCB->setChecked(false);
801 dialog_->footerBorderBelowCB->setChecked(false);
802 dialog_->lastfooterStatusCB->setChecked(false);
803 dialog_->lastfooterBorderAboveCB->setChecked(false);
804 dialog_->lastfooterBorderBelowCB->setChecked(false);
805 dialog_->lastfooterNoContentsCB->setChecked(false);
806 dialog_->newpageCB->setChecked(false);
807 dialog_->newpageCB->setEnabled(false);
813 bool row_set = tabular.getRowOfLTHead(row, ltt);
814 dialog_->headerStatusCB->setChecked(row_set);
816 dialog_->headerBorderAboveCB->setChecked(ltt.topDL);
817 dialog_->headerBorderBelowCB->setChecked(ltt.bottomDL);
820 dialog_->headerBorderAboveCB->setChecked(false);
821 dialog_->headerBorderBelowCB->setChecked(false);
822 dialog_->headerBorderAboveCB->setEnabled(false);
823 dialog_->headerBorderBelowCB->setEnabled(false);
824 dialog_->firstheaderNoContentsCB->setChecked(false);
825 dialog_->firstheaderNoContentsCB->setEnabled(false);
829 row_set = tabular.getRowOfLTFirstHead(row, ltt);
830 dialog_->firstheaderStatusCB->setChecked(row_set);
831 if (ltt.set && (!ltt.empty || !use_empty)) {
832 dialog_->firstheaderBorderAboveCB->setChecked(ltt.topDL);
833 dialog_->firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
835 dialog_->firstheaderBorderAboveCB->setEnabled(false);
836 dialog_->firstheaderBorderBelowCB->setEnabled(false);
837 dialog_->firstheaderBorderAboveCB->setChecked(false);
838 dialog_->firstheaderBorderBelowCB->setChecked(false);
840 dialog_->firstheaderNoContentsCB->setChecked(ltt.empty);
842 dialog_->firstheaderStatusCB->setEnabled(false);
846 row_set = tabular.getRowOfLTFoot(row, ltt);
847 dialog_->footerStatusCB->setChecked(row_set);
849 dialog_->footerBorderAboveCB->setChecked(ltt.topDL);
850 dialog_->footerBorderBelowCB->setChecked(ltt.bottomDL);
853 dialog_->footerBorderAboveCB->setChecked(false);
854 dialog_->footerBorderBelowCB->setChecked(false);
855 dialog_->footerBorderAboveCB->setEnabled(false);
856 dialog_->footerBorderBelowCB->setEnabled(false);
857 dialog_->lastfooterNoContentsCB->setChecked(false);
858 dialog_->lastfooterNoContentsCB->setEnabled(false);
862 row_set = tabular.getRowOfLTLastFoot(row, ltt);
863 dialog_->lastfooterStatusCB->setChecked(row_set);
864 if (ltt.set && (!ltt.empty || !use_empty)) {
865 dialog_->lastfooterBorderAboveCB->setChecked(ltt.topDL);
866 dialog_->lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
868 dialog_->lastfooterBorderAboveCB->setEnabled(false);
869 dialog_->lastfooterBorderBelowCB->setEnabled(false);
870 dialog_->lastfooterBorderAboveCB->setChecked(false);
871 dialog_->lastfooterBorderBelowCB->setChecked(false);
873 dialog_->lastfooterNoContentsCB->setChecked(ltt.empty);
875 dialog_->lastfooterStatusCB->setEnabled(false);
878 dialog_->newpageCB->setChecked(tabular.getLTNewPage(row));
882 void GuiTabular::closeGUI()
884 // ugly hack to auto-apply the stuff that hasn't been
885 // yet. don't let this continue to exist ...
887 // Subtle here, we must /not/ apply any changes and
888 // then refer to tabular, as it will have been freed
889 // since the changes update the actual controller().tabular()
890 Tabular const & tabular(controller().tabular());
892 // apply the fixed width values
893 Tabular::idx_type const cell = controller().getActiveCell();
894 bool const multicol = tabular.isMultiColumn(cell);
895 string width = widgetsToLength(dialog_->widthED, dialog_->widthUnit);
898 Length llen = tabular.getColumnPWidth(cell);
899 Length llenMulti = tabular.getMColumnPWidth(cell);
901 if (multicol && !llenMulti.zero())
902 width2 = llenMulti.asString();
903 else if (!multicol && !llen.zero())
904 width2 = llen.asString();
906 // apply the special alignment
907 docstring const sa1 = qstring_to_ucs4(dialog_->specialAlignmentED->text());
911 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_MULTI);
913 sa2 = tabular.getAlignSpecial(cell, Tabular::SET_SPECIAL_COLUMN);
917 controller().set(Tabular::SET_SPECIAL_MULTI, to_utf8(sa1));
919 controller().set(Tabular::SET_SPECIAL_COLUMN, to_utf8(sa1));
922 if (width != width2) {
924 controller().set(Tabular::SET_MPWIDTH, width);
926 controller().set(Tabular::SET_PWIDTH, width);
930 switch (dialog_->topspaceCO->currentIndex()) {
932 controller().set(Tabular::SET_TOP_SPACE, "");
935 controller().set(Tabular::SET_TOP_SPACE, "default");
938 controller().set(Tabular::SET_TOP_SPACE,
939 widgetsToLength(dialog_->topspaceED,
940 dialog_->topspaceUnit));
944 switch (dialog_->bottomspaceCO->currentIndex()) {
946 controller().set(Tabular::SET_BOTTOM_SPACE, "");
949 controller().set(Tabular::SET_BOTTOM_SPACE, "default");
952 controller().set(Tabular::SET_BOTTOM_SPACE,
953 widgetsToLength(dialog_->bottomspaceED,
954 dialog_->bottomspaceUnit));
958 switch (dialog_->interlinespaceCO->currentIndex()) {
960 controller().set(Tabular::SET_INTERLINE_SPACE, "");
963 controller().set(Tabular::SET_INTERLINE_SPACE, "default");
966 controller().set(Tabular::SET_INTERLINE_SPACE,
967 widgetsToLength(dialog_->interlinespaceED,
968 dialog_->interlinespaceUnit));
974 } // namespace frontend
977 #include "GuiTabular_moc.cpp"