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();
89 void QTabularDialog::borderUnset_clicked()
91 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
92 form_->update_borders();
97 void QTabularDialog::leftBorder_changed()
99 if (form_->controller().isMulticolumnCell())
100 form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
102 form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
107 void QTabularDialog::rightBorder_changed()
109 if (form_->controller().isMulticolumnCell())
110 form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
112 form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
117 void QTabularDialog::topBorder_changed()
119 if (form_->controller().isMulticolumnCell())
120 form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
122 form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
127 void QTabularDialog::bottomBorder_changed()
129 if (form_->controller().isMulticolumnCell())
130 form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
132 form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
137 void QTabularDialog::specialAlignment_changed()
139 string special = specialAlignmentED->text().latin1();
140 if (form_->controller().isMulticolumnCell())
141 form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
143 form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
147 void QTabularDialog::width_changed()
150 LyXLength(widthED->text().toDouble(),
151 widthUnit->currentLengthItem()).asString();
152 if (form_->controller().isMulticolumnCell())
153 form_->controller().set(LyXTabular::SET_MPWIDTH, width);
155 form_->controller().set(LyXTabular::SET_PWIDTH, width);
157 form_->update_contents();
161 void QTabularDialog::multicolumn_clicked()
163 form_->controller().set(LyXTabular::MULTICOLUMN);
165 form_->update_contents();
169 void QTabularDialog::rotateTabular_checked(int state)
173 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
176 // "no change state", should not happen
179 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
185 void QTabularDialog::rotateCell_checked(int state)
189 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
192 // "no change state", should not happen
195 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
201 void QTabularDialog::hAlign_changed(int align)
203 LyXTabular::Feature num = LyXTabular::ALIGN_LEFT;
204 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
209 num = LyXTabular::ALIGN_LEFT;
210 multi_num = LyXTabular::M_ALIGN_LEFT;
215 num = LyXTabular::ALIGN_CENTER;
216 multi_num = LyXTabular::M_ALIGN_CENTER;
221 num = LyXTabular::ALIGN_RIGHT;
222 multi_num = LyXTabular::M_ALIGN_RIGHT;
226 num = LyXTabular::ALIGN_BLOCK;
227 //multi_num: no equivalent
232 if (form_->controller().isMulticolumnCell())
233 form_->controller().set(multi_num);
235 form_->controller().set(num);
239 void QTabularDialog::vAlign_changed(int align)
241 LyXTabular::Feature num = LyXTabular::VALIGN_CENTER;
242 LyXTabular::Feature multi_num = LyXTabular::M_VALIGN_CENTER;
247 num = LyXTabular::VALIGN_TOP;
248 multi_num = LyXTabular::M_VALIGN_TOP;
253 num = LyXTabular::VALIGN_CENTER;
254 multi_num = LyXTabular::M_VALIGN_CENTER;
259 num = LyXTabular::VALIGN_BOTTOM;
260 multi_num = LyXTabular::M_VALIGN_BOTTOM;
264 if (form_->controller().isMulticolumnCell())
265 form_->controller().set(multi_num);
267 form_->controller().set(num);
271 void QTabularDialog::longTabular_changed(int state)
275 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
278 // "no change state", should not happen
281 form_->controller().set(LyXTabular::SET_LONGTABULAR);
288 void QTabularDialog::ltNewpage_clicked()
290 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
295 void QTabularDialog::ltHeaderStatus_clicked()
297 bool enable(headerStatusCB->isChecked());
299 form_->controller().set(LyXTabular::SET_LTHEAD, "");
301 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
302 headerBorderAboveCB->setEnabled(enable);
303 headerBorderBelowCB->setEnabled(enable);
304 firstheaderNoContentsCB->setEnabled(enable);
309 void QTabularDialog::ltHeaderBorderAbove_clicked()
311 if (headerBorderAboveCB->isChecked())
312 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
314 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
319 void QTabularDialog::ltHeaderBorderBelow_clicked()
321 if (headerBorderBelowCB->isChecked())
322 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
324 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
329 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
331 if (firstheaderBorderAboveCB->isChecked())
332 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
334 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
339 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
341 if (firstheaderBorderBelowCB->isChecked())
342 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
344 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
349 void QTabularDialog::ltFirstHeaderStatus_clicked()
351 bool enable(firstheaderStatusCB->isChecked());
353 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
355 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
356 firstheaderBorderAboveCB->setEnabled(enable);
357 firstheaderBorderBelowCB->setEnabled(enable);
362 void QTabularDialog::ltFirstHeaderEmpty_clicked()
364 bool enable(firstheaderNoContentsCB->isChecked());
366 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
368 ltFirstHeaderBorderBelow_clicked();
369 ltFirstHeaderBorderAbove_clicked();
371 firstheaderStatusCB->setEnabled(!enable);
372 firstheaderBorderAboveCB->setEnabled(!enable);
373 firstheaderBorderBelowCB->setEnabled(!enable);
378 void QTabularDialog::ltFooterStatus_clicked()
380 bool enable(footerStatusCB->isChecked());
382 form_->controller().set(LyXTabular::SET_LTFOOT, "");
384 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
385 footerBorderAboveCB->setEnabled(enable);
386 footerBorderBelowCB->setEnabled(enable);
387 lastfooterNoContentsCB->setEnabled(enable);
392 void QTabularDialog::ltFooterBorderAbove_clicked()
394 if (footerBorderAboveCB->isChecked())
395 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
397 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
402 void QTabularDialog::ltFooterBorderBelow_clicked()
404 if (footerBorderBelowCB->isChecked())
405 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
407 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
412 void QTabularDialog::ltLastFooterStatus_clicked()
414 bool enable(lastfooterStatusCB->isChecked());
416 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
418 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
419 lastfooterBorderAboveCB->setEnabled(enable);
420 lastfooterBorderBelowCB->setEnabled(enable);
425 void QTabularDialog::ltLastFooterBorderAbove_clicked()
427 if (lastfooterBorderAboveCB->isChecked())
428 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
430 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
435 void QTabularDialog::ltLastFooterBorderBelow_clicked()
437 if (lastfooterBorderBelowCB->isChecked())
438 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
440 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
445 void QTabularDialog::ltLastFooterEmpty_clicked()
447 bool enable(lastfooterNoContentsCB->isChecked());
449 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
451 ltLastFooterBorderBelow_clicked();
452 ltLastFooterBorderAbove_clicked();
454 lastfooterStatusCB->setEnabled(!enable);
455 lastfooterBorderAboveCB->setEnabled(!enable);
456 lastfooterBorderBelowCB->setEnabled(!enable);