2 * \file QTabularDialog.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
7 * \author Juergen Spitzmueller
10 * Full author contact details are available in file CREDITS
16 #pragma implementation
19 #include "ControlTabular.h"
22 #include "QTabularDialog.h"
24 #include "lengthcombo.h"
25 #include "qsetborder.h"
27 #include <qcheckbox.h>
28 #include <qpushbutton.h>
29 #include <qlineedit.h>
32 QTabularDialog::QTabularDialog(QTabular * form)
33 : QTabularDialogBase(0, 0, false, 0),
36 connect(closePB, SIGNAL(clicked()),
37 form, SLOT(slotClose()));
41 void QTabularDialog::change_adaptor()
47 void QTabularDialog::closeEvent(QCloseEvent * e)
53 void QTabularDialog::close_clicked()
58 void QTabularDialog::columnAppend_clicked()
60 form_->controller().set(LyXTabular::APPEND_COLUMN);
64 void QTabularDialog::rowAppend_clicked()
66 form_->controller().set(LyXTabular::APPEND_ROW);
70 void QTabularDialog::columnDelete_clicked()
72 form_->controller().set(LyXTabular::DELETE_COLUMN);
76 void QTabularDialog::rowDelete_clicked()
78 form_->controller().set(LyXTabular::DELETE_ROW);
82 void QTabularDialog::borderSet_clicked()
84 form_->controller().set(LyXTabular::SET_ALL_LINES);
85 form_->update_borders();
87 //FIXME: qsetborder widget not updated
90 void QTabularDialog::borderUnset_clicked()
92 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
93 form_->update_borders();
95 //FIXME: qsetborder widget not updated
99 void QTabularDialog::leftBorder_changed()
101 if (form_->controller().isMulticolumnCell())
102 form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
104 form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
109 void QTabularDialog::rightBorder_changed()
111 if (form_->controller().isMulticolumnCell())
112 form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
114 form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
119 void QTabularDialog::topBorder_changed()
121 if (form_->controller().isMulticolumnCell())
122 form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
124 form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
129 void QTabularDialog::bottomBorder_changed()
131 if (form_->controller().isMulticolumnCell())
132 form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
134 form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
139 void QTabularDialog::specialAlignment_changed()
141 string special = specialAlignmentED->text().latin1();
142 if (form_->controller().isMulticolumnCell())
143 form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
145 form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
149 void QTabularDialog::width_changed()
152 LyXLength(widthED->text().toDouble(),
153 widthUnit->currentLengthItem()).asString();
154 if (form_->controller().isMulticolumnCell())
155 form_->controller().set(LyXTabular::SET_MPWIDTH, width);
157 form_->controller().set(LyXTabular::SET_PWIDTH, width);
159 form_->update_contents();
163 void QTabularDialog::multicolumn_clicked()
165 form_->controller().set(LyXTabular::MULTICOLUMN);
167 form_->update_contents();
171 void QTabularDialog::rotateTabular_checked(int state)
175 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
178 // "no change state", should not happen
181 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
187 void QTabularDialog::rotateCell_checked(int state)
191 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
194 // "no change state", should not happen
197 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
203 void QTabularDialog::hAlign_changed(int align)
205 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
206 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
211 num = LyXTabular::ALIGN_LEFT;
212 multi_num = LyXTabular::M_ALIGN_LEFT;
217 num = LyXTabular::ALIGN_CENTER;
218 multi_num = LyXTabular::M_ALIGN_CENTER;
223 num = LyXTabular::ALIGN_RIGHT;
224 multi_num = LyXTabular::M_ALIGN_RIGHT;
228 num = LyXTabular::ALIGN_BLOCK;
229 //multi_num: no equivalent
234 if (form_->controller().isMulticolumnCell())
235 form_->controller().set(multi_num);
237 form_->controller().set(num);
241 void QTabularDialog::vAlign_changed(int align)
243 LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
244 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
249 num = LyXTabular::VALIGN_TOP;
250 multi_num = LyXTabular::M_VALIGN_TOP;
255 num = LyXTabular::VALIGN_CENTER;
256 multi_num = LyXTabular::M_VALIGN_CENTER;
261 num = LyXTabular::VALIGN_BOTTOM;
262 multi_num = LyXTabular::M_VALIGN_BOTTOM;
266 if (form_->controller().isMulticolumnCell())
267 form_->controller().set(multi_num);
269 form_->controller().set(num);
273 void QTabularDialog::longTabular_changed(int state)
277 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
280 // "no change state", should not happen
283 form_->controller().set(LyXTabular::SET_LONGTABULAR);
290 void QTabularDialog::ltNewpage_clicked()
292 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
297 void QTabularDialog::ltHeaderStatus_clicked()
299 bool enable(headerStatusCB->isChecked());
301 form_->controller().set(LyXTabular::SET_LTHEAD, "");
303 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
304 headerBorderAboveCB->setEnabled(enable);
305 headerBorderBelowCB->setEnabled(enable);
306 firstheaderNoContentsCB->setEnabled(enable);
311 void QTabularDialog::ltHeaderBorderAbove_clicked()
313 if (headerBorderAboveCB->isChecked())
314 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
316 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
321 void QTabularDialog::ltHeaderBorderBelow_clicked()
323 if (headerBorderBelowCB->isChecked())
324 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
326 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
331 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
333 if (firstheaderBorderAboveCB->isChecked())
334 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
336 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
341 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
343 if (firstheaderBorderBelowCB->isChecked())
344 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
346 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
351 void QTabularDialog::ltFirstHeaderStatus_clicked()
353 bool enable(firstheaderStatusCB->isChecked());
355 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
357 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
358 firstheaderBorderAboveCB->setEnabled(enable);
359 firstheaderBorderBelowCB->setEnabled(enable);
364 void QTabularDialog::ltFirstHeaderEmpty_clicked()
366 bool enable(firstheaderNoContentsCB->isChecked());
368 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
370 ltFirstHeaderBorderBelow_clicked();
371 ltFirstHeaderBorderAbove_clicked();
373 firstheaderStatusCB->setEnabled(!enable);
374 firstheaderBorderAboveCB->setEnabled(!enable);
375 firstheaderBorderBelowCB->setEnabled(!enable);
380 void QTabularDialog::ltFooterStatus_clicked()
382 bool enable(footerStatusCB->isChecked());
384 form_->controller().set(LyXTabular::SET_LTFOOT, "");
386 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
387 footerBorderAboveCB->setEnabled(enable);
388 footerBorderBelowCB->setEnabled(enable);
389 lastfooterNoContentsCB->setEnabled(enable);
394 void QTabularDialog::ltFooterBorderAbove_clicked()
396 if (footerBorderAboveCB->isChecked())
397 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
399 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
404 void QTabularDialog::ltFooterBorderBelow_clicked()
406 if (footerBorderBelowCB->isChecked())
407 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
409 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
414 void QTabularDialog::ltLastFooterStatus_clicked()
416 bool enable(lastfooterStatusCB->isChecked());
418 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
420 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
421 lastfooterBorderAboveCB->setEnabled(enable);
422 lastfooterBorderBelowCB->setEnabled(enable);
427 void QTabularDialog::ltLastFooterBorderAbove_clicked()
429 if (lastfooterBorderAboveCB->isChecked())
430 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
432 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
437 void QTabularDialog::ltLastFooterBorderBelow_clicked()
439 if (lastfooterBorderBelowCB->isChecked())
440 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
442 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
447 void QTabularDialog::ltLastFooterEmpty_clicked()
449 bool enable(lastfooterNoContentsCB->isChecked());
451 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
453 ltLastFooterBorderBelow_clicked();
454 ltLastFooterBorderAbove_clicked();
456 lastfooterStatusCB->setEnabled(!enable);
457 lastfooterBorderAboveCB->setEnabled(!enable);
458 lastfooterBorderBelowCB->setEnabled(!enable);