]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiTabular.cpp
63cd3836c0c67d19b8c8a7f1129e9b55acec691c
[lyx.git] / src / frontends / qt4 / GuiTabular.cpp
1 /**
2  * \file GuiTabular.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author John Levon
7  * \author Jürgen Spitzmüller
8  * \author Herbert Voß
9  * \author Uwe Stöhr
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #include <config.h>
15
16 #include "GuiTabular.h"
17
18 #include "GuiApplication.h"
19 #include "GuiSetBorder.h"
20 #include "GuiView.h"
21 #include "LengthCombo.h"
22 #include "qt_helpers.h"
23 #include "Validator.h"
24
25 #include "BufferView.h"
26 #include "Cursor.h"
27 #include "FuncRequest.h"
28 #include "FuncStatus.h"
29 #include "LyX.h"
30 #include "LyXRC.h"
31
32 #include "insets/InsetTabular.h"
33
34 #include "support/convert.h"
35 #include "support/debug.h"
36 #include "support/lstrings.h"
37
38 #include <QCheckBox>
39 #include <QPushButton>
40 #include <QRadioButton>
41 #include <QLineEdit>
42
43 using namespace std;
44
45 namespace lyx {
46 namespace frontend {
47
48 GuiTabular::GuiTabular(QWidget * parent)
49         : InsetParamsWidget(parent), firstheader_suppressable_(false),
50           lastfooter_suppressable_(false)
51
52 {
53         setupUi(this);
54
55         tabularWidthED->setValidator(unsignedLengthValidator(tabularWidthED));
56         columnWidthED->setValidator(unsignedLengthValidator(columnWidthED));
57         multirowOffsetED->setValidator(new LengthValidator(multirowOffsetED));
58         topspaceED->setValidator(new LengthValidator(topspaceED));
59         bottomspaceED->setValidator(new LengthValidator(bottomspaceED));
60         interlinespaceED->setValidator(new LengthValidator(interlinespaceED));
61
62         tabularWidthUnitLC->setCurrentItem(Length::defaultUnit());
63         columnWidthUnitLC->setCurrentItem(Length::defaultUnit());
64         multirowOffsetUnitLC->setCurrentItem(Length::defaultUnit());
65         topspaceUnitLC->setCurrentItem(Length::defaultUnit());
66         bottomspaceUnitLC->setCurrentItem(Length::defaultUnit());
67         interlinespaceUnitLC->setCurrentItem(Length::defaultUnit());
68
69         connect(topspaceED, SIGNAL(textEdited(const QString &)),
70                 this, SLOT(checkEnabled()));
71         connect(topspaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
72                 this, SLOT(checkEnabled()));
73         connect(bottomspaceED, SIGNAL(textEdited(const QString &)),
74                 this, SLOT(checkEnabled()));
75         connect(bottomspaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
76                 this, SLOT(checkEnabled()));
77         connect(interlinespaceED, SIGNAL(textEdited(const QString &)),
78                 this, SLOT(checkEnabled()));
79         connect(interlinespaceUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
80                 this, SLOT(checkEnabled()));
81         connect(booktabsRB, SIGNAL(clicked(bool)),
82                 this, SLOT(checkEnabled()));
83         connect(borderDefaultRB, SIGNAL(clicked(bool)),
84                 this, SLOT(checkEnabled()));
85         connect(borderSetPB, SIGNAL(clicked()),
86                 this, SLOT(borderSet_clicked()));
87         connect(borderUnsetPB, SIGNAL(clicked()),
88                 this, SLOT(borderUnset_clicked()));
89         connect(hAlignCO, SIGNAL(activated(int)),
90                 this, SLOT(checkEnabled()));
91         connect(vAlignCO, SIGNAL(activated(int)),
92                 this, SLOT(checkEnabled()));
93         connect(multicolumnCB, SIGNAL(clicked()),
94                 this, SLOT(checkEnabled()));
95         connect(multirowCB, SIGNAL(clicked()),
96                 this, SLOT(checkEnabled()));
97         connect(multirowOffsetED, SIGNAL(textEdited(const QString &)),
98                 this, SLOT(checkEnabled()));
99         connect(multirowOffsetUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
100                 this, SLOT(checkEnabled()));
101         connect(newpageCB, SIGNAL(clicked()),
102                 this, SLOT(checkEnabled()));
103         connect(headerStatusCB, SIGNAL(clicked()),
104                 this, SLOT(checkEnabled()));
105         connect(headerBorderAboveCB, SIGNAL(clicked()),
106                 this, SLOT(checkEnabled()));
107         connect(headerBorderBelowCB, SIGNAL(clicked()),
108                 this, SLOT(checkEnabled()));
109         connect(firstheaderStatusCB, SIGNAL(clicked()),
110                 this, SLOT(checkEnabled()));
111         connect(firstheaderBorderAboveCB, SIGNAL(clicked()),
112                 this, SLOT(checkEnabled()));
113         connect(firstheaderBorderBelowCB, SIGNAL(clicked()),
114                 this, SLOT(checkEnabled()));
115         connect(firstheaderNoContentsCB, SIGNAL(clicked()),
116                 this, SLOT(checkEnabled()));
117         connect(footerStatusCB, SIGNAL(clicked()),
118                 this, SLOT(checkEnabled()));
119         connect(footerBorderAboveCB, SIGNAL(clicked()),
120                 this, SLOT(checkEnabled()));
121         connect(footerBorderBelowCB, SIGNAL(clicked()),
122                 this, SLOT(checkEnabled()));
123         connect(lastfooterStatusCB, SIGNAL(clicked()),
124                 this, SLOT(checkEnabled()));
125         connect(lastfooterBorderAboveCB, SIGNAL(clicked()),
126                 this, SLOT(checkEnabled()));
127         connect(lastfooterBorderBelowCB, SIGNAL(clicked()),
128                 this, SLOT(checkEnabled()));
129         connect(lastfooterNoContentsCB, SIGNAL(clicked()),
130                 this, SLOT(checkEnabled()));
131         connect(captionStatusCB, SIGNAL(clicked()),
132                 this, SLOT(checkEnabled()));
133         connect(specialAlignmentED, SIGNAL(textEdited(const QString &)),
134                 this, SLOT(checkEnabled()));
135         connect(columnWidthED, SIGNAL(textEdited(const QString &)),
136                 this, SLOT(checkEnabled()));
137         connect(columnWidthUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
138                 this, SLOT(checkEnabled()));
139         connect(borders, SIGNAL(topSet()),
140                 this, SLOT(checkEnabled()));
141         connect(borders, SIGNAL(bottomSet()),
142                 this, SLOT(checkEnabled()));
143         connect(borders, SIGNAL(rightSet()),
144                 this, SLOT(checkEnabled()));
145         connect(borders, SIGNAL(leftSet()),
146                 this, SLOT(checkEnabled()));
147         connect(rotateTabularCB, SIGNAL(clicked()),
148                 this, SLOT(checkEnabled()));
149         connect(rotateTabularAngleSB, SIGNAL(valueChanged(int)),
150                 this, SLOT(checkEnabled()));
151         connect(rotateCellCB, SIGNAL(clicked()),
152                 this, SLOT(checkEnabled()));
153         connect(rotateCellAngleSB, SIGNAL(valueChanged(int)),
154                 this, SLOT(checkEnabled()));
155         connect(TableAlignCO, SIGNAL(activated(int)),
156                 this, SLOT(checkEnabled()));
157         connect(longTabularCB, SIGNAL(clicked()),
158                 this, SLOT(checkEnabled()));
159         connect(leftRB, SIGNAL(clicked()),
160                 this, SLOT(checkEnabled()));
161         connect(centerRB, SIGNAL(clicked()),
162                 this, SLOT(checkEnabled()));
163         connect(rightRB, SIGNAL(clicked()),
164                 this, SLOT(checkEnabled()));
165         connect(tabularWidthED, SIGNAL(textEdited(const QString &)),
166                 this, SLOT(checkEnabled()));
167
168         decimalPointED->setInputMask("X; ");
169         decimalPointED->setMaxLength(1);
170
171         // initialize the length validator
172         addCheckedWidget(columnWidthED, columnWidthLA);
173         addCheckedWidget(multirowOffsetED, multirowOffsetLA);
174         addCheckedWidget(topspaceED, topspaceLA);
175         addCheckedWidget(bottomspaceED, bottomspaceLA);
176         addCheckedWidget(interlinespaceED, interlinespaceLA);
177         addCheckedWidget(tabularWidthED, tabularWidthLA);
178 }
179
180
181 void GuiTabular::on_topspaceCO_activated(int index)
182 {
183         bool const enable = (index == 2);
184         topspaceED->setEnabled(enable);
185         topspaceUnitLC->setEnabled(enable);
186 }
187
188
189 void GuiTabular::on_bottomspaceCO_activated(int index)
190 {
191         bool const enable = (index == 2);
192         bottomspaceED->setEnabled(enable);
193         bottomspaceUnitLC->setEnabled(enable);
194 }
195
196
197 void GuiTabular::on_interlinespaceCO_activated(int index)
198 {
199         bool const enable = (index == 2);
200         interlinespaceED->setEnabled(enable);
201         interlinespaceUnitLC->setEnabled(enable);
202 }
203
204
205 void GuiTabular::enableWidgets() const
206 {
207         // if there is a LaTeX argument, the width and alignment will be overwritten
208         // therefore disable them in this case
209         columnWidthED->setEnabled(specialAlignmentED->text().isEmpty());
210         columnWidthUnitLC->setEnabled(specialAlignmentED->text().isEmpty());
211         // if the column has a width, multirows are always left-aligned
212         // therefore disable hAlignCB in this case
213         hAlignCO->setEnabled(!(multirowCB->isChecked()
214                 && !widgetsToLength(columnWidthED, columnWidthUnitLC).empty())
215                 && specialAlignmentED->text().isEmpty());
216         // decimal alignment is only possible for non-multicol and non-multirow cells
217         if ((multicolumnCB->isChecked() || multirowCB->isChecked())
218                 && hAlignCO->findData(toqstr("decimal")))
219                 hAlignCO->removeItem(hAlignCO->findData(toqstr("decimal")));
220         else if (!multicolumnCB->isChecked() && !multirowCB->isChecked()
221                 && hAlignCO->findData(toqstr("decimal")) == -1)
222                 hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
223         bool const dalign =
224                 hAlignCO->itemData(hAlignCO->currentIndex()).toString() == QString("decimal");
225         decimalPointED->setEnabled(dalign);
226         decimalLA->setEnabled(dalign);
227
228         bool const setwidth = TableAlignCO->currentText() == qt_("Middle")
229                 && !longTabularCB->isChecked();
230         tabularWidthLA->setEnabled(setwidth);
231         tabularWidthED->setEnabled(setwidth);
232         tabularWidthUnitLC->setEnabled(setwidth);
233
234         rotateTabularAngleSB->setEnabled(rotateTabularCB->isChecked()
235                                          && !longTabularCB->isChecked());
236         rotateCellAngleSB->setEnabled(rotateCellCB->isChecked());
237
238         bool const enable_valign =
239                 !multirowCB->isChecked()
240                 && !widgetsToLength(columnWidthED, columnWidthUnitLC).empty()
241                 && specialAlignmentED->text().isEmpty();
242         vAlignCO->setEnabled(enable_valign);
243         vAlignLA->setEnabled(enable_valign);
244
245         topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
246         topspaceED->setEnabled(topspaceCO->currentIndex() == 2);
247         topspaceUnitLC->setEnabled(topspaceCO->currentIndex() == 2);
248         bottomspaceED->setEnabled(bottomspaceCO->currentIndex() == 2);
249         bottomspaceUnitLC->setEnabled(bottomspaceCO->currentIndex() == 2);
250         interlinespaceED->setEnabled(interlinespaceCO->currentIndex() == 2);
251         interlinespaceUnitLC->setEnabled(interlinespaceCO->currentIndex() == 2);
252
253         // setting as longtable is not allowed when table is inside a float
254         bool const is_tabular_star = !tabularWidthED->text().isEmpty();
255         longTabularCB->setEnabled(!is_tabular_star && funcEnabled(Tabular::SET_LONGTABULAR));
256         bool const longtabular = longTabularCB->isChecked();
257         longtableGB->setEnabled(true);
258         newpageCB->setEnabled(longtabular);
259         alignmentGB->setEnabled(longtabular);
260         // longtables and tabular* cannot have a vertical alignment
261         TableAlignLA->setDisabled(is_tabular_star || longtabular);
262         TableAlignCO->setDisabled(is_tabular_star || longtabular);
263         // longtable cannot be rotated with rotating package, only
264         // with [pdf]lscape, which only supports 90 deg.
265         rotateTabularAngleSB->setDisabled(longtabular);
266
267         // FIXME: This Dialog is really horrible, disabling/enabling a checkbox
268         // depending on the cursor position is very very unintuitive...
269         // We need some edit boxes to show which rows are header/footer/etc
270         // without having to move the cursor first.
271         headerStatusCB->setEnabled(longtabular
272                 && (headerStatusCB->isChecked() ?
273                     funcEnabled(Tabular::UNSET_LTHEAD) :
274                     funcEnabled(Tabular::SET_LTHEAD)));
275         headerBorderAboveCB->setEnabled(longtabular
276                 && headerStatusCB->isChecked());
277         headerBorderBelowCB->setEnabled(longtabular
278                 && headerStatusCB->isChecked());
279
280         // first header can only be suppressed when there is a header
281         // firstheader_suppressable_ is set in paramsToDialog
282         firstheaderNoContentsCB->setEnabled(longtabular && firstheader_suppressable_);
283         // check if setting a first header is allowed
284         // additionally check firstheaderNoContentsCB because when this is
285         // the case a first header makes no sense
286         firstheaderStatusCB->setEnabled((firstheaderStatusCB->isChecked() ?
287                    funcEnabled(Tabular::UNSET_LTFIRSTHEAD) :
288                    funcEnabled(Tabular::SET_LTFIRSTHEAD))
289                 && longtabular && !firstheaderNoContentsCB->isChecked());
290         firstheaderBorderAboveCB->setEnabled(longtabular
291                 && firstheaderStatusCB->isChecked());
292         firstheaderBorderBelowCB->setEnabled(longtabular
293                 && firstheaderStatusCB->isChecked());
294
295         footerStatusCB->setEnabled(longtabular
296                 && (footerStatusCB->isChecked() ?
297                     funcEnabled(Tabular::UNSET_LTFOOT) :
298                     funcEnabled(Tabular::SET_LTFOOT)));
299         footerBorderAboveCB->setEnabled(longtabular
300                 && footerBorderAboveCB->isChecked());
301         footerBorderBelowCB->setEnabled(longtabular
302                 && footerBorderAboveCB->isChecked());
303
304         // last footer can only be suppressed when there is a footer
305         // lastfooter_suppressable_ is set in paramsToDialog
306         lastfooterNoContentsCB->setEnabled(longtabular && lastfooter_suppressable_);
307         // check if setting a last footer is allowed
308         // additionally check lastfooterNoContentsCB because when this is
309         // the case a last footer makes no sense
310         lastfooterStatusCB->setEnabled((lastfooterStatusCB->isChecked() ?
311                    funcEnabled(Tabular::UNSET_LTLASTFOOT) :
312                    funcEnabled(Tabular::SET_LTLASTFOOT))
313                 && longtabular && !lastfooterNoContentsCB->isChecked());
314         lastfooterBorderAboveCB->setEnabled(longtabular
315                 && lastfooterBorderAboveCB->isChecked());
316         lastfooterBorderBelowCB->setEnabled(longtabular
317                 && lastfooterBorderAboveCB->isChecked());
318
319         captionStatusCB->setEnabled(funcEnabled(Tabular::TOGGLE_LTCAPTION)
320                 && longtabular);
321
322         multicolumnCB->setEnabled(funcEnabled(Tabular::MULTICOLUMN)
323                 && !dalign && !multirowCB->isChecked());
324         multirowCB->setEnabled(funcEnabled(Tabular::MULTIROW)
325                 && !dalign && !multicolumnCB->isChecked());
326         bool const enable_mr = multirowCB->isChecked();
327         multirowOffsetLA->setEnabled(enable_mr);
328         multirowOffsetED->setEnabled(enable_mr);
329         multirowOffsetUnitLC->setEnabled(enable_mr);
330
331         // Vertical lines cannot be set in formal tables
332         borders->setLeftEnabled(!booktabsRB->isChecked());
333         borders->setRightEnabled(!booktabsRB->isChecked());
334 }
335
336
337 void GuiTabular::checkEnabled()
338 {
339         enableWidgets();
340         changed();
341 }
342
343
344 void GuiTabular::borderSet_clicked()
345 {
346         borders->setTop(GuiSetBorder::LINE_SET);
347         borders->setBottom(GuiSetBorder::LINE_SET);
348         borders->setLeft(GuiSetBorder::LINE_SET);
349         borders->setRight(GuiSetBorder::LINE_SET);
350         // repaint the setborder widget
351         borders->update();
352         checkEnabled();
353 }
354
355
356 void GuiTabular::borderUnset_clicked()
357 {
358         borders->setTop(GuiSetBorder::LINE_UNSET);
359         borders->setBottom(GuiSetBorder::LINE_UNSET);
360         borders->setLeft(GuiSetBorder::LINE_UNSET);
361         borders->setRight(GuiSetBorder::LINE_UNSET);
362         // repaint the setborder widget
363         borders->update();
364         checkEnabled();
365 }
366
367
368 static void setParam(string & param_str, Tabular::Feature f, string const & arg = string())
369 {
370         param_str += ' ';
371         param_str += featureAsString(f) + ' ' + arg;
372 }
373
374
375 void GuiTabular::setHAlign(string & param_str) const
376 {
377         Tabular::Feature num = Tabular::ALIGN_LEFT;
378         Tabular::Feature multi_num = Tabular::M_ALIGN_LEFT;
379         string const align =
380                 fromqstr(hAlignCO->itemData(hAlignCO->currentIndex()).toString());
381         if (align == "left") {
382                 num = Tabular::ALIGN_LEFT;
383                 multi_num = Tabular::M_ALIGN_LEFT;
384         } else if (align == "center") {
385                 num = Tabular::ALIGN_CENTER;
386                 multi_num = Tabular::M_ALIGN_CENTER;
387         } else if (align == "right") {
388                 num = Tabular::ALIGN_RIGHT;
389                 multi_num = Tabular::M_ALIGN_RIGHT;
390         } else if (align == "justified") {
391                 num = Tabular::ALIGN_BLOCK;
392                 //multi_num: no equivalent
393         } else if (align == "decimal") {
394                 num = Tabular::ALIGN_DECIMAL;
395                 //multi_num: no equivalent
396         }
397
398         if (multicolumnCB->isChecked())
399                 setParam(param_str, multi_num);
400         else
401                 setParam(param_str, num);
402 }
403
404
405 void GuiTabular::setVAlign(string & param_str) const
406 {
407         int const align = vAlignCO->currentIndex();
408         enum VALIGN { TOP, MIDDLE, BOTTOM };
409         VALIGN v = TOP;
410
411         switch (align) {
412                 case 0: v = TOP; break;
413                 case 1: v = MIDDLE; break;
414                 case 2: v = BOTTOM; break;
415         }
416
417         Tabular::Feature num = Tabular::VALIGN_MIDDLE;
418         Tabular::Feature multi_num = Tabular::M_VALIGN_MIDDLE;
419
420         switch (v) {
421                 case TOP:
422                         num = Tabular::VALIGN_TOP;
423                         multi_num = Tabular::M_VALIGN_TOP;
424                         break;
425                 case MIDDLE:
426                         num = Tabular::VALIGN_MIDDLE;
427                         multi_num = Tabular::M_VALIGN_MIDDLE;
428                         break;
429                 case BOTTOM:
430                         num = Tabular::VALIGN_BOTTOM;
431                         multi_num = Tabular::M_VALIGN_BOTTOM;
432                         break;
433         }
434         if (multicolumnCB->isChecked() || multirowCB->isChecked())
435                 setParam(param_str, multi_num);
436         else
437                 setParam(param_str, num);
438 }
439
440
441 void GuiTabular::setTableAlignment(string & param_str) const
442 {
443         int const align = TableAlignCO->currentIndex();
444         switch (align) {
445                 case 0: setParam(param_str, Tabular::TABULAR_VALIGN_TOP);
446                         break;
447                 case 1: setParam(param_str, Tabular::TABULAR_VALIGN_MIDDLE);
448                         break;
449                 case 2: setParam(param_str, Tabular::TABULAR_VALIGN_BOTTOM);
450                         break;
451         }
452 }
453
454
455 docstring GuiTabular::dialogToParams() const
456 {
457         string param_str = "tabular";
458
459         // table width
460         string tabwidth = widgetsToLength(tabularWidthED, tabularWidthUnitLC);
461         if (tabwidth.empty())
462                 tabwidth = "0pt";
463         setParam(param_str, Tabular::SET_TABULAR_WIDTH, tabwidth);
464
465         // apply the fixed width values
466         // this must be done before applying the column alignment
467         // because its value influences the alignment of multirow cells
468         string width = widgetsToLength(columnWidthED, columnWidthUnitLC);
469         if (width.empty())
470                 width = "0pt";
471         if (multicolumnCB->isChecked())
472                 setParam(param_str, Tabular::SET_MPWIDTH, width);
473         else
474                 setParam(param_str, Tabular::SET_PWIDTH, width);
475
476         // apply the column alignment
477         // multirows inherit the alignment from the column; if a column width
478         // is set, multirows are always left-aligned so that in this case
479         // its alignment must not be applied (see bug #8084)
480         if (!(multirowCB->isChecked() && width != "0pt"))
481                 setHAlign(param_str);
482
483         // SET_DECIMAL_POINT must come after setHAlign() (ALIGN_DECIMAL)
484         string decimal_point = fromqstr(decimalPointED->text());
485         if (decimal_point.empty())
486                 decimal_point = lyxrc.default_decimal_point;
487         setParam(param_str, Tabular::SET_DECIMAL_POINT, decimal_point);
488
489         setVAlign(param_str);
490         setTableAlignment(param_str);
491         //
492         if (booktabsRB->isChecked())
493                 setParam(param_str, Tabular::SET_BOOKTABS);
494         else
495                 setParam(param_str, Tabular::UNSET_BOOKTABS);
496
497         //
498         switch (topspaceCO->currentIndex()) {
499                 case 0:
500                         setParam(param_str, Tabular::SET_TOP_SPACE, "none");
501                         break;
502                 case 1:
503                         setParam(param_str, Tabular::SET_TOP_SPACE, "default");
504                         break;
505                 case 2:
506                         if (!topspaceED->text().isEmpty())
507                                 setParam(param_str, Tabular::SET_TOP_SPACE,
508                                          widgetsToLength(topspaceED, topspaceUnitLC));
509                         break;
510         }
511
512         //
513         switch (bottomspaceCO->currentIndex()) {
514                 case 0:
515                         setParam(param_str, Tabular::SET_BOTTOM_SPACE, "none");
516                         break;
517                 case 1:
518                         setParam(param_str, Tabular::SET_BOTTOM_SPACE, "default");
519                         break;
520                 case 2:
521                         if (!bottomspaceED->text().isEmpty())
522                                 setParam(param_str, Tabular::SET_BOTTOM_SPACE,
523                                         widgetsToLength(bottomspaceED,
524                                                         bottomspaceUnitLC));
525                         break;
526         }
527
528         //
529         switch (interlinespaceCO->currentIndex()) {
530                 case 0:
531                         setParam(param_str, Tabular::SET_INTERLINE_SPACE, "none");
532                         break;
533                 case 1:
534                         setParam(param_str, Tabular::SET_INTERLINE_SPACE, "default");
535                         break;
536                 case 2:
537                         if (!interlinespaceED->text().isEmpty())
538                                 setParam(param_str, Tabular::SET_INTERLINE_SPACE,
539                                         widgetsToLength(interlinespaceED,
540                                                         interlinespaceUnitLC));
541                         break;
542         }
543
544         //
545         if (borders->topLineSet() && borders->bottomLineSet() && borders->leftLineSet()
546                 && borders->rightLineSet())
547                 setParam(param_str, Tabular::SET_ALL_LINES);
548         else if (borders->topLineUnset() && borders->bottomLineUnset() && borders->leftLineUnset()
549                 && borders->rightLineUnset())
550                 setParam(param_str, Tabular::UNSET_ALL_LINES);
551         else {
552                 if (borders->getLeft() != GuiSetBorder::LINE_UNDECIDED)
553                         setParam(param_str, Tabular::SET_LINE_LEFT,
554                                  borders->leftLineSet() ? "true" : "false");
555                 if (borders->getRight() != GuiSetBorder::LINE_UNDECIDED)
556                         setParam(param_str, Tabular::SET_LINE_RIGHT,
557                                  borders->rightLineSet() ? "true" : "false");
558                 if (borders->getTop() != GuiSetBorder::LINE_UNDECIDED)
559                         setParam(param_str, Tabular::SET_LINE_TOP,
560                                  borders->topLineSet() ? "true" : "false");
561                 if (borders->getBottom() != GuiSetBorder::LINE_UNDECIDED)
562                         setParam(param_str, Tabular::SET_LINE_BOTTOM,
563                                  borders->bottomLineSet() ? "true" : "false");
564         }
565
566         // apply the special alignment
567         string special = fromqstr(specialAlignmentED->text());
568         if (support::trim(special).empty())
569                 special = "none";
570         if (multicolumnCB->isChecked())
571                 setParam(param_str, Tabular::SET_SPECIAL_MULTICOLUMN, special);
572         else
573                 setParam(param_str, Tabular::SET_SPECIAL_COLUMN, special);
574
575         //
576         if (multicolumnCB->isChecked())
577                 setParam(param_str, Tabular::SET_MULTICOLUMN);
578         else
579                 setParam(param_str, Tabular::UNSET_MULTICOLUMN);
580
581         // apply the multirow offset
582         string mroffset = widgetsToLength(multirowOffsetED, multirowOffsetUnitLC);
583         if (mroffset.empty())
584                 mroffset = "0pt";
585         if (multirowCB->isChecked())
586                 setParam(param_str, Tabular::SET_MROFFSET, mroffset);
587         //
588         if (multirowCB->isChecked())
589                 setParam(param_str, Tabular::SET_MULTIROW);
590         else
591                 setParam(param_str, Tabular::UNSET_MULTIROW);
592         // store the table rotation angle
593         string const tabular_angle = convert<string>(rotateTabularAngleSB->value());
594         if (rotateTabularCB->isChecked())
595                 setParam(param_str, Tabular::SET_ROTATE_TABULAR, tabular_angle);
596         else
597                 setParam(param_str, Tabular::UNSET_ROTATE_TABULAR, tabular_angle);
598         // store the cell rotation angle
599         string const cell_angle = convert<string>(rotateCellAngleSB->value());
600         if (rotateCellCB->isChecked())
601                 setParam(param_str, Tabular::SET_ROTATE_CELL, cell_angle);
602         else
603                 setParam(param_str, Tabular::UNSET_ROTATE_CELL, cell_angle);
604         //
605         if (longTabularCB->isChecked())
606                 setParam(param_str, Tabular::SET_LONGTABULAR);
607         else
608                 setParam(param_str, Tabular::UNSET_LONGTABULAR);
609         //
610         if (newpageCB->isChecked())
611                 setParam(param_str, Tabular::SET_LTNEWPAGE);
612     else
613                 setParam(param_str, Tabular::UNSET_LTNEWPAGE);
614         //
615         if (captionStatusCB->isChecked())
616                 setParam(param_str, Tabular::SET_LTCAPTION);
617         else
618                 setParam(param_str, Tabular::UNSET_LTCAPTION);
619         //
620         if (headerStatusCB->isChecked())
621                 setParam(param_str, Tabular::SET_LTHEAD, "none");
622         else
623                 setParam(param_str, Tabular::UNSET_LTHEAD, "none");
624         //
625         if (headerBorderAboveCB->isChecked())
626                 setParam(param_str, Tabular::SET_LTHEAD, "dl_above");
627         else
628                 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_above");
629         //
630         if (headerBorderBelowCB->isChecked())
631                 setParam(param_str, Tabular::SET_LTHEAD, "dl_below");
632         else
633                 setParam(param_str, Tabular::UNSET_LTHEAD, "dl_below");
634         if (firstheaderBorderAboveCB->isChecked())
635                 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_above");
636         else
637                 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_above");
638         if (firstheaderBorderBelowCB->isChecked())
639                 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "dl_below");
640         else
641                 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "dl_below");
642         if (firstheaderStatusCB->isChecked())
643                 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "none");
644         else
645                 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "none");
646         if (firstheaderNoContentsCB->isChecked())
647                 setParam(param_str, Tabular::SET_LTFIRSTHEAD, "empty");
648         else
649                 setParam(param_str, Tabular::UNSET_LTFIRSTHEAD, "empty");
650         if (footerStatusCB->isChecked())
651                 setParam(param_str, Tabular::SET_LTFOOT, "none");
652         else
653                 setParam(param_str, Tabular::UNSET_LTFOOT, "none");
654         if (footerBorderAboveCB->isChecked())
655                 setParam(param_str, Tabular::SET_LTFOOT, "dl_above");
656         else
657                 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_above");
658         if (footerBorderBelowCB->isChecked())
659                 setParam(param_str, Tabular::SET_LTFOOT, "dl_below");
660         else
661                 setParam(param_str, Tabular::UNSET_LTFOOT, "dl_below");
662         if (lastfooterStatusCB->isChecked())
663                 setParam(param_str, Tabular::SET_LTLASTFOOT, "none");
664         else
665                 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "none");
666         if (lastfooterBorderAboveCB->isChecked())
667                 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_above");
668         else
669                 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_above");
670         if (lastfooterBorderBelowCB->isChecked())
671                 setParam(param_str, Tabular::SET_LTLASTFOOT, "dl_below");
672         else
673                 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "dl_below");
674         if (lastfooterNoContentsCB->isChecked())
675                 setParam(param_str, Tabular::SET_LTLASTFOOT, "empty");
676         else
677                 setParam(param_str, Tabular::UNSET_LTLASTFOOT, "empty");
678
679         if (leftRB->isChecked())
680                 setParam(param_str, Tabular::LONGTABULAR_ALIGN_LEFT);
681         else if (centerRB->isChecked())
682                 setParam(param_str, Tabular::LONGTABULAR_ALIGN_CENTER);
683         else if (rightRB->isChecked())
684                 setParam(param_str, Tabular::LONGTABULAR_ALIGN_RIGHT);
685
686         return from_utf8(param_str);
687 }
688
689
690 static Length getColumnPWidth(Tabular const & t, size_t cell)
691 {
692         return t.column_info[t.cellColumn(cell)].p_width;
693 }
694
695
696 static Length getMColumnPWidth(Tabular const & t, size_t cell)
697 {
698         if (t.isMultiColumn(cell) || t.isMultiRow(cell))
699                 return t.cellInfo(cell).p_width;
700         return Length();
701 }
702
703
704 static Length getMROffset(Tabular const & t, size_t cell)
705 {
706         if (t.isMultiRow(cell))
707                 return t.cellInfo(cell).mroffset;
708         return Length();
709 }
710
711
712 static docstring getAlignSpecial(Tabular const & t, size_t cell, int what)
713 {
714         if (what == Tabular::SET_SPECIAL_MULTICOLUMN)
715                 return t.cellInfo(cell).align_special;
716         return t.column_info[t.cellColumn(cell)].align_special;
717 }
718
719
720 GuiSetBorder::BorderState GuiTabular::borderState(GuiSetBorder::BorderState bs,
721                                                   bool const line)
722 {
723         if (bs == GuiSetBorder::LINE_UNDEF)
724                 bs = line ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
725         else if ((bs == GuiSetBorder::LINE_SET && !line)
726                  || (bs == GuiSetBorder::LINE_UNSET && line))
727                 bs = GuiSetBorder::LINE_UNDECIDED;
728         return bs;
729 }
730
731
732 void GuiTabular::paramsToDialog(Inset const * inset)
733 {
734         InsetTabular const * itab = static_cast<InsetTabular const *>(inset);
735         // Copy Tabular of current inset.
736         Tabular const & tabular = itab->tabular;
737
738         BufferView const * bv = guiApp->currentView()->currentBufferView();
739         size_t const cell = bv->cursor().idx();
740
741         Tabular::row_type const row = tabular.cellRow(cell);
742         Tabular::col_type const col = tabular.cellColumn(cell);
743
744         tabularRowED->setText(QString::number(row + 1));
745         tabularColumnED->setText(QString::number(col + 1));
746
747         bool const multicol = tabular.isMultiColumn(cell);
748         multicolumnCB->setChecked(multicol);
749
750         bool const multirow = tabular.isMultiRow(cell);
751         multirowCB->setChecked(multirow);
752
753         rotateCellCB->setChecked(tabular.getRotateCell(cell) != 0);
754         if (rotateCellCB->isChecked()) {
755                 if (tabular.getRotateCell(cell) != 0)
756                         rotateCellAngleSB->setValue(tabular.getRotateCell(cell));
757                 else
758                         rotateCellAngleSB->setValue(90);
759         }
760
761         longTabularCB->setChecked(tabular.is_long_tabular);
762
763         rotateTabularCB->setChecked(tabular.rotate != 0);
764         if (rotateTabularCB->isChecked()) {
765                 if (longTabularCB->isChecked())
766                         rotateTabularAngleSB->setValue(90);
767                 else
768                         rotateTabularAngleSB->setValue(tabular.rotate != 0 ? tabular.rotate : 90);
769         }
770
771         // In what follows, we check the borders of all selected cells,
772         // and if there are diverging settings, we use the LINE_UNDECIDED
773         // border status.
774         GuiSetBorder::BorderState lt = GuiSetBorder::LINE_UNDEF;
775         GuiSetBorder::BorderState lb = GuiSetBorder::LINE_UNDEF;
776         GuiSetBorder::BorderState ll = GuiSetBorder::LINE_UNDEF;
777         GuiSetBorder::BorderState lr = GuiSetBorder::LINE_UNDEF;
778         CursorSlice const & beg = bv->cursor().selBegin();
779         CursorSlice const & end = bv->cursor().selEnd();
780         if (beg != end) {
781                 Tabular::col_type cs = tabular.cellColumn(beg.idx());
782                 Tabular::col_type ce = tabular.cellColumn(end.idx());
783                 if (cs > ce)
784                         swap(cs, ce);
785                 Tabular::row_type rs = tabular.cellRow(beg.idx());
786                 Tabular::row_type re = tabular.cellRow(end.idx());
787                 if (rs > re)
788                         swap(rs, re);
789                 for (Tabular::row_type r = rs; r <= re; ++r)
790                         for (Tabular::col_type c = cs; c <= ce; ++c) {
791                                 idx_type const cc = tabular.cellIndex(r, c);
792                                 lt = borderState(lt, tabular.topLine(cc));
793                                 lb = borderState(lb, tabular.bottomLine(cc));
794                                 ll = borderState(ll, tabular.leftLine(cc));
795                                 lr = borderState(lr, tabular.rightLine(cc));
796                         }
797         } else {
798                 lt = tabular.topLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
799                 lb = tabular.bottomLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
800                 ll = tabular.leftLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
801                 lr = tabular.rightLine(cell) ? GuiSetBorder::LINE_SET : GuiSetBorder::LINE_UNSET;
802         }
803         borders->setTop(lt);
804         borders->setBottom(lb);
805         borders->setLeft(ll);
806         borders->setRight(lr);
807         // repaint the setborder widget
808         borders->update();
809
810         Length::UNIT const default_unit = Length::defaultUnit();
811
812         ///////////////////////////////////
813         // Set width and alignment
814
815         Length const tabwidth = tabular.tabularWidth();
816         if (tabwidth.zero()
817             && !(tabularWidthED->hasFocus() && tabularWidthED->text() == "0"))
818                 tabularWidthED->clear();
819         else
820                 lengthToWidgets(tabularWidthED, tabularWidthUnitLC,
821                         tabwidth.asString(), default_unit);
822
823         Length pwidth;
824         docstring special;
825         if (multicol) {
826                 special = getAlignSpecial(tabular, cell,
827                         Tabular::SET_SPECIAL_MULTICOLUMN);
828                 pwidth = getMColumnPWidth(tabular, cell);
829         } else {
830                 special = getAlignSpecial(tabular, cell,
831                         Tabular::SET_SPECIAL_COLUMN);
832                 pwidth = getColumnPWidth(tabular, cell);
833         }
834         string colwidth;
835         if (pwidth.zero()
836             && !(columnWidthED->hasFocus() && columnWidthED->text() == "0"))
837                 columnWidthED->clear();
838         else {
839                 colwidth = pwidth.asString();
840                 lengthToWidgets(columnWidthED, columnWidthUnitLC,
841                         colwidth, default_unit);
842         }
843         Length mroffset;
844         if (multirow)
845                 mroffset = getMROffset(tabular, cell);
846         string offset;
847         if (mroffset.zero()
848             && !(multirowOffsetED->hasFocus() && multirowOffsetED->text() == "0"))
849                 multirowOffsetED->clear();
850         else {
851                 offset = mroffset.asString();
852                 lengthToWidgets(multirowOffsetED, multirowOffsetUnitLC,
853                         offset, default_unit);
854         }
855         specialAlignmentED->setText(toqstr(special));
856         ///////////////////////////////////
857
858
859         borderDefaultRB->setChecked(!tabular.use_booktabs);
860         booktabsRB->setChecked(tabular.use_booktabs);
861
862         if (tabular.row_info[row].top_space.empty()
863             && !tabular.row_info[row].top_space_default) {
864                 topspaceCO->setCurrentIndex(0);
865         } else if (tabular.row_info[row].top_space_default) {
866                 topspaceCO->setCurrentIndex(1);
867         } else {
868                 topspaceCO->setCurrentIndex(2);
869                 lengthToWidgets(topspaceED,
870                                 topspaceUnitLC,
871                                 tabular.row_info[row].top_space.asString(),
872                                 default_unit);
873         }
874
875         if (tabular.row_info[row].bottom_space.empty()
876             && !tabular.row_info[row].bottom_space_default) {
877                 bottomspaceCO->setCurrentIndex(0);
878         } else if (tabular.row_info[row].bottom_space_default) {
879                 bottomspaceCO->setCurrentIndex(1);
880         } else {
881                 bottomspaceCO->setCurrentIndex(2);
882                 lengthToWidgets(bottomspaceED,
883                                 bottomspaceUnitLC,
884                                 tabular.row_info[row].bottom_space.asString(),
885                                 default_unit);
886         }
887
888         if (tabular.row_info[row].interline_space.empty()
889             && !tabular.row_info[row].interline_space_default) {
890                 interlinespaceCO->setCurrentIndex(0);
891         } else if (tabular.row_info[row].interline_space_default) {
892                 interlinespaceCO->setCurrentIndex(1);
893         } else {
894                 interlinespaceCO->setCurrentIndex(2);
895                 lengthToWidgets(interlinespaceED,
896                                 interlinespaceUnitLC,
897                                 tabular.row_info[row].interline_space.asString(),
898                                 default_unit);
899         }
900
901         hAlignCO->clear();
902         hAlignCO->addItem(qt_("Left"), toqstr("left"));
903         hAlignCO->addItem(qt_("Center"), toqstr("center"));
904         hAlignCO->addItem(qt_("Right"), toqstr("right"));
905         if (!multicol && !pwidth.zero())
906                 hAlignCO->addItem(qt_("Justified"), toqstr("justified"));
907         if (!multicol && !multirow)
908                 hAlignCO->addItem(qt_("At Decimal Separator"), toqstr("decimal"));
909
910         string align;
911         switch (tabular.getAlignment(cell)) {
912                 case LYX_ALIGN_LEFT:
913                         align = "left";
914                         break;
915                 case LYX_ALIGN_CENTER:
916                         align = "center";
917                         break;
918                 case LYX_ALIGN_RIGHT:
919                         align = "right";
920                         break;
921                 case LYX_ALIGN_BLOCK:
922                 {
923                         if (!multicol && !pwidth.zero())
924                                 align = "justified";
925                         break;
926                 }
927                 case LYX_ALIGN_DECIMAL:
928                 {
929                         if (!multicol && !multirow)
930                                 align = "decimal";
931                         break;
932                 }
933                 default:
934                         // we should never end up here
935                         break;
936         }
937         hAlignCO->setCurrentIndex(hAlignCO->findData(toqstr(align)));
938
939         //
940         QString decimal_point = toqstr(tabular.column_info[col].decimal_point);
941         if (decimal_point.isEmpty())
942                 decimal_point = toqstr(from_utf8(lyxrc.default_decimal_point));
943         decimalPointED->setText(decimal_point);
944
945         int valign = 0;
946         switch (tabular.getVAlignment(cell)) {
947         case Tabular::LYX_VALIGN_TOP:
948                 valign = 0;
949                 break;
950         case Tabular::LYX_VALIGN_MIDDLE:
951                 valign = 1;
952                 break;
953         case Tabular::LYX_VALIGN_BOTTOM:
954                 valign = 2;
955                 break;
956         default:
957                 valign = 0;
958                 break;
959         }
960         if (pwidth.zero())
961                 valign = 0;
962         vAlignCO->setCurrentIndex(valign);
963
964         int tableValign = 1;
965         switch (tabular.tabular_valignment) {
966         case Tabular::LYX_VALIGN_TOP:
967                 tableValign = 0;
968                 break;
969         case Tabular::LYX_VALIGN_MIDDLE:
970                 tableValign = 1;
971                 break;
972         case Tabular::LYX_VALIGN_BOTTOM:
973                 tableValign = 2;
974                 break;
975         default:
976                 tableValign = 0;
977                 break;
978         }
979         TableAlignCO->setCurrentIndex(tableValign);
980
981         if (!tabular.is_long_tabular) {
982                 headerStatusCB->setChecked(false);
983                 headerBorderAboveCB->setChecked(false);
984                 headerBorderBelowCB->setChecked(false);
985                 firstheaderStatusCB->setChecked(false);
986                 firstheaderBorderAboveCB->setChecked(false);
987                 firstheaderBorderBelowCB->setChecked(false);
988                 firstheaderNoContentsCB->setChecked(false);
989                 footerStatusCB->setChecked(false);
990                 footerBorderAboveCB->setChecked(false);
991                 footerBorderBelowCB->setChecked(false);
992                 lastfooterStatusCB->setChecked(false);
993                 lastfooterBorderAboveCB->setChecked(false);
994                 lastfooterBorderBelowCB->setChecked(false);
995                 lastfooterNoContentsCB->setChecked(false);
996                 newpageCB->setChecked(false);
997                 captionStatusCB->blockSignals(true);
998                 captionStatusCB->setChecked(false);
999                 captionStatusCB->blockSignals(false);
1000                 checkEnabled();
1001                 return;
1002         } else {
1003                 // longtables cannot have a vertical alignment
1004                 TableAlignCO->setCurrentIndex(Tabular::LYX_VALIGN_MIDDLE);
1005         }
1006         switch (tabular.longtabular_alignment) {
1007         case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
1008                 leftRB->setChecked(true);
1009                 break;
1010         case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
1011                 centerRB->setChecked(true);
1012                 break;
1013         case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
1014                 rightRB->setChecked(true);
1015                 break;
1016         default:
1017                 centerRB->setChecked(true);
1018                 break;
1019         }
1020         captionStatusCB->blockSignals(true);
1021         captionStatusCB->setChecked(tabular.ltCaption(row));
1022         captionStatusCB->blockSignals(false);
1023
1024         Tabular::ltType ltt;
1025         bool use_empty;
1026         bool row_set = tabular.getRowOfLTHead(row, ltt);
1027         headerStatusCB->setChecked(row_set);
1028         if (ltt.set) {
1029                 headerBorderAboveCB->setChecked(ltt.topDL);
1030                 headerBorderBelowCB->setChecked(ltt.bottomDL);
1031                 use_empty = true;
1032         } else {
1033                 headerBorderAboveCB->setChecked(false);
1034                 headerBorderBelowCB->setChecked(false);
1035                 firstheaderNoContentsCB->setChecked(false);
1036                 use_empty = false;
1037         }
1038
1039         row_set = tabular.getRowOfLTFirstHead(row, ltt);
1040         firstheaderStatusCB->setChecked(row_set);
1041         if (ltt.set && (!ltt.empty || !use_empty)) {
1042                 firstheaderBorderAboveCB->setChecked(ltt.topDL);
1043                 firstheaderBorderBelowCB->setChecked(ltt.bottomDL);
1044         } else {
1045                 firstheaderBorderAboveCB->setChecked(false);
1046                 firstheaderBorderBelowCB->setChecked(false);
1047         }
1048
1049         row_set = tabular.getRowOfLTFoot(row, ltt);
1050         footerStatusCB->setChecked(row_set);
1051         if (ltt.set) {
1052                 footerBorderAboveCB->setChecked(ltt.topDL);
1053                 footerBorderBelowCB->setChecked(ltt.bottomDL);
1054                 use_empty = true;
1055         } else {
1056                 footerBorderAboveCB->setChecked(false);
1057                 footerBorderBelowCB->setChecked(false);
1058                 lastfooterNoContentsCB->setChecked(false);
1059                 use_empty = false;
1060         }
1061
1062         row_set = tabular.getRowOfLTLastFoot(row, ltt);
1063         lastfooterStatusCB->setChecked(row_set);
1064         if (ltt.set && (!ltt.empty || !use_empty)) {
1065                 lastfooterBorderAboveCB->setChecked(ltt.topDL);
1066                 lastfooterBorderBelowCB->setChecked(ltt.bottomDL);
1067         } else {
1068                 lastfooterBorderAboveCB->setChecked(false);
1069                 lastfooterBorderBelowCB->setChecked(false);
1070         }
1071         newpageCB->setChecked(tabular.getLTNewPage(row));
1072
1073         // first header can only be suppressed when there is a header
1074         firstheader_suppressable_ = tabular.haveLTHead()
1075                         && !tabular.haveLTFirstHead();
1076         // last footer can only be suppressed when there is a footer
1077         lastfooter_suppressable_ = tabular.haveLTFoot()
1078                         && !tabular.haveLTLastFoot();
1079
1080         // after setting the features, check if they are enabled
1081         checkEnabled();
1082 }
1083
1084
1085 bool GuiTabular::checkWidgets(bool readonly) const
1086 {
1087         tabularRowED->setReadOnly(readonly);
1088         tabularColumnED->setReadOnly(readonly);
1089         tabularWidthED->setReadOnly(readonly);
1090         specialAlignmentED->setReadOnly(readonly);
1091         columnWidthED->setReadOnly(readonly);
1092         multirowOffsetED->setReadOnly(readonly);
1093         decimalPointED->setReadOnly(readonly);
1094
1095         if (readonly) {
1096                 multicolumnCB->setEnabled(false);
1097                 multirowCB->setEnabled(false);
1098                 rotateCellCB->setEnabled(false);
1099                 rotateCellAngleSB->setEnabled(false);
1100                 rotateTabularCB->setEnabled(false);
1101                 rotateTabularAngleSB->setEnabled(false);
1102                 longTabularCB->setEnabled(false);
1103                 borders->setEnabled(false);
1104                 tabularWidthUnitLC->setEnabled(false);
1105                 columnWidthUnitLC->setEnabled(false);
1106                 multirowOffsetUnitLC->setEnabled(false);
1107                 setBordersGB->setEnabled(false);
1108                 allBordersGB->setEnabled(false);
1109                 borderStyleGB->setEnabled(false);
1110                 booktabsRB->setEnabled(false);
1111                 topspaceCO->setEnabled(false);
1112                 topspaceUnitLC->setEnabled(false);
1113                 bottomspaceCO->setEnabled(false);
1114                 bottomspaceUnitLC->setEnabled(false);
1115                 interlinespaceCO->setEnabled(false);
1116                 interlinespaceUnitLC->setEnabled(false);
1117                 hAlignCO->setEnabled(false);
1118                 vAlignCO->setEnabled(false);
1119                 TableAlignCO->setEnabled(false);
1120                 longtableGB->setEnabled(false);
1121                 alignmentGB->setEnabled(false);
1122         } else
1123                 enableWidgets();
1124
1125         return InsetParamsWidget::checkWidgets();
1126 }
1127
1128
1129 bool GuiTabular::funcEnabled(Tabular::Feature f) const
1130 {
1131         FuncRequest r(LFUN_INSET_MODIFY, "tabular for-dialog" + featureAsString(f));
1132         return getStatus(r).enabled();
1133 }
1134
1135
1136 } // namespace frontend
1137 } // namespace lyx
1138
1139 #include "moc_GuiTabular.cpp"