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);
159 void QTabularDialog::multicolumn_clicked()
161 form_->controller().set(LyXTabular::MULTICOLUMN);
166 void QTabularDialog::rotateTabular_checked(int state)
170 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
173 // "no change state", should not happen
176 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
182 void QTabularDialog::rotateCell_checked(int state)
186 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
189 // "no change state", should not happen
192 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
198 void QTabularDialog::hAlign_changed(int align)
200 LyXTabular::Feature num = LyXTabular::ALIGN_BLOCK;
201 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
206 num = LyXTabular::ALIGN_BLOCK;
207 //FIXME: multi_num no equivalent
212 num = LyXTabular::ALIGN_LEFT;
213 multi_num = LyXTabular::M_ALIGN_LEFT;
218 num = LyXTabular::ALIGN_CENTER;
219 multi_num = LyXTabular::M_ALIGN_CENTER;
224 num = LyXTabular::ALIGN_RIGHT;
225 multi_num = LyXTabular::M_ALIGN_RIGHT;
229 if (form_->controller().isMulticolumnCell())
230 form_->controller().set(multi_num);
232 form_->controller().set(num);
236 void QTabularDialog::vAlign_changed(int align)
238 LyXTabular::Feature num = LyXTabular::ALIGN_BLOCK;
239 LyXTabular::Feature multi_num = LyXTabular::M_ALIGN_LEFT;
244 num = LyXTabular::VALIGN_TOP;
245 multi_num = LyXTabular::M_VALIGN_TOP;
250 num = LyXTabular::VALIGN_CENTER;
251 multi_num = LyXTabular::M_VALIGN_CENTER;
256 num = LyXTabular::VALIGN_BOTTOM;
257 multi_num = LyXTabular::M_VALIGN_BOTTOM;
261 if (form_->controller().isMulticolumnCell())
262 form_->controller().set(multi_num);
264 form_->controller().set(num);
268 void QTabularDialog::longTabular_changed(int state)
272 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
275 // "no change state", should not happen
278 form_->controller().set(LyXTabular::SET_LONGTABULAR);
285 void QTabularDialog::ltNewpage_clicked()
287 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
292 void QTabularDialog::ltHeaderStatus_clicked()
294 bool enable(headerStatusCB->isChecked());
296 form_->controller().set(LyXTabular::SET_LTHEAD, "");
298 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
299 headerBorderAboveCB->setEnabled(enable);
300 headerBorderBelowCB->setEnabled(enable);
301 firstheaderNoContentsCB->setEnabled(enable);
306 void QTabularDialog::ltHeaderBorderAbove_clicked()
308 if (headerBorderAboveCB->isChecked())
309 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
311 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
316 void QTabularDialog::ltHeaderBorderBelow_clicked()
318 if (headerBorderBelowCB->isChecked())
319 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
321 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
326 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
328 if (firstheaderBorderAboveCB->isChecked())
329 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
331 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
336 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
338 if (firstheaderBorderBelowCB->isChecked())
339 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
341 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
346 void QTabularDialog::ltFirstHeaderStatus_clicked()
348 bool enable(firstheaderStatusCB->isChecked());
350 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
352 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
353 firstheaderBorderAboveCB->setEnabled(enable);
354 firstheaderBorderBelowCB->setEnabled(enable);
359 void QTabularDialog::ltFirstHeaderEmpty_clicked()
361 bool enable(firstheaderNoContentsCB->isChecked());
363 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
365 ltFirstHeaderBorderBelow_clicked();
366 ltFirstHeaderBorderAbove_clicked();
368 firstheaderStatusCB->setEnabled(!enable);
369 firstheaderBorderAboveCB->setEnabled(!enable);
370 firstheaderBorderBelowCB->setEnabled(!enable);
375 void QTabularDialog::ltFooterStatus_clicked()
377 bool enable(footerStatusCB->isChecked());
379 form_->controller().set(LyXTabular::SET_LTFOOT, "");
381 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
382 footerBorderAboveCB->setEnabled(enable);
383 footerBorderBelowCB->setEnabled(enable);
384 lastfooterNoContentsCB->setEnabled(enable);
389 void QTabularDialog::ltFooterBorderAbove_clicked()
391 if (footerBorderAboveCB->isChecked())
392 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
394 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
399 void QTabularDialog::ltFooterBorderBelow_clicked()
401 if (footerBorderBelowCB->isChecked())
402 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
404 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
409 void QTabularDialog::ltLastFooterStatus_clicked()
411 bool enable(lastfooterStatusCB->isChecked());
413 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
415 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
416 lastfooterBorderAboveCB->setEnabled(enable);
417 lastfooterBorderBelowCB->setEnabled(enable);
422 void QTabularDialog::ltLastFooterBorderAbove_clicked()
424 if (lastfooterBorderAboveCB->isChecked())
425 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
427 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
432 void QTabularDialog::ltLastFooterBorderBelow_clicked()
434 if (lastfooterBorderBelowCB->isChecked())
435 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
437 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
442 void QTabularDialog::ltLastFooterEmpty_clicked()
444 bool enable(lastfooterNoContentsCB->isChecked());
446 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
448 ltLastFooterBorderBelow_clicked();
449 ltLastFooterBorderAbove_clicked();
451 lastfooterStatusCB->setEnabled(!enable);
452 lastfooterBorderAboveCB->setEnabled(!enable);
453 lastfooterBorderBelowCB->setEnabled(!enable);