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);
81 void QTabularDialog::borderSet_clicked()
83 form_->controller().set(LyXTabular::SET_ALL_LINES);
84 form_->update_borders();
88 void QTabularDialog::borderUnset_clicked()
90 form_->controller().set(LyXTabular::UNSET_ALL_LINES);
91 form_->update_borders();
95 void QTabularDialog::leftBorder_changed()
97 if (form_->controller().isMulticolumnCell())
98 form_->controller().set(LyXTabular::M_TOGGLE_LINE_LEFT);
100 form_->controller().set(LyXTabular::TOGGLE_LINE_LEFT);
104 void QTabularDialog::rightBorder_changed()
106 if (form_->controller().isMulticolumnCell())
107 form_->controller().set(LyXTabular::M_TOGGLE_LINE_RIGHT);
109 form_->controller().set(LyXTabular::TOGGLE_LINE_RIGHT);
113 void QTabularDialog::topBorder_changed()
115 if (form_->controller().isMulticolumnCell())
116 form_->controller().set(LyXTabular::M_TOGGLE_LINE_TOP);
118 form_->controller().set(LyXTabular::TOGGLE_LINE_TOP);
122 void QTabularDialog::bottomBorder_changed()
124 if (form_->controller().isMulticolumnCell())
125 form_->controller().set(LyXTabular::M_TOGGLE_LINE_BOTTOM);
127 form_->controller().set(LyXTabular::TOGGLE_LINE_BOTTOM);
131 void QTabularDialog::specialAlignment_changed()
133 string special = specialAlignmentED->text().latin1();
134 if (form_->controller().isMulticolumnCell())
135 form_->controller().set(LyXTabular::SET_SPECIAL_MULTI, special);
137 form_->controller().set(LyXTabular::SET_SPECIAL_COLUMN, special);
140 void QTabularDialog::width_changed()
143 LyXLength(widthED->text().toDouble(),
144 widthUnit->currentLengthItem()).asString();
145 if (form_->controller().isMulticolumnCell())
146 form_->controller().set(LyXTabular::SET_MPWIDTH, width);
148 form_->controller().set(LyXTabular::SET_PWIDTH, width);
151 void QTabularDialog::multicolumn_clicked()
153 form_->controller().set(LyXTabular::MULTICOLUMN);
157 void QTabularDialog::rotateTabular_checked(int state)
161 form_->controller().set(LyXTabular::UNSET_ROTATE_TABULAR);
164 // "no change state", should not happen
167 form_->controller().set(LyXTabular::SET_ROTATE_TABULAR);
172 void QTabularDialog::rotateCell_checked(int state)
176 form_->controller().set(LyXTabular::UNSET_ROTATE_CELL);
179 // "no change state", should not happen
182 form_->controller().set(LyXTabular::SET_ROTATE_CELL);
187 void QTabularDialog::hAlign_changed(int align)
189 LyXTabular::Feature num;
190 LyXTabular::Feature multi_num;
195 num = LyXTabular::ALIGN_BLOCK;
196 //FIXME: multi_num no equivalent
201 num = LyXTabular::ALIGN_LEFT;
202 multi_num = LyXTabular::M_ALIGN_LEFT;
207 num = LyXTabular::ALIGN_CENTER;
208 multi_num = LyXTabular::M_ALIGN_CENTER;
213 num = LyXTabular::ALIGN_RIGHT;
214 multi_num = LyXTabular::M_ALIGN_RIGHT;
218 if (form_->controller().isMulticolumnCell())
219 form_->controller().set(multi_num);
221 form_->controller().set(num);
224 void QTabularDialog::vAlign_changed(int align)
226 LyXTabular::Feature num;
227 LyXTabular::Feature multi_num;
232 num = LyXTabular::VALIGN_TOP;
233 multi_num = LyXTabular::M_VALIGN_TOP;
238 num = LyXTabular::VALIGN_CENTER;
239 multi_num = LyXTabular::M_VALIGN_CENTER;
244 num = LyXTabular::VALIGN_BOTTOM;
245 multi_num = LyXTabular::M_VALIGN_BOTTOM;
249 if (form_->controller().isMulticolumnCell())
250 form_->controller().set(multi_num);
252 form_->controller().set(num);
255 void QTabularDialog::longTabular_changed(int state)
259 form_->controller().set(LyXTabular::UNSET_LONGTABULAR);
262 // "no change state", should not happen
265 form_->controller().set(LyXTabular::SET_LONGTABULAR);
271 void QTabularDialog::ltNewpage_clicked()
273 form_->controller().set(LyXTabular::SET_LTNEWPAGE);
277 void QTabularDialog::ltHeaderStatus_clicked()
279 bool enable(headerStatusCB->isChecked());
281 form_->controller().set(LyXTabular::SET_LTHEAD, "");
283 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
284 headerBorderAboveCB->setEnabled(enable);
285 headerBorderBelowCB->setEnabled(enable);
286 firstheaderNoContentsCB->setEnabled(enable);
291 void QTabularDialog::ltHeaderBorderAbove_clicked()
293 if (headerBorderAboveCB->isChecked())
294 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_above");
296 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
301 void QTabularDialog::ltHeaderBorderBelow_clicked()
303 if (headerBorderBelowCB->isChecked())
304 form_->controller().set(LyXTabular::SET_LTHEAD, "dl_below");
306 form_->controller().set(LyXTabular::UNSET_LTHEAD, "");
311 void QTabularDialog::ltFirstHeaderBorderAbove_clicked()
313 if (firstheaderBorderAboveCB->isChecked())
314 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_above");
316 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
321 void QTabularDialog::ltFirstHeaderBorderBelow_clicked()
323 if (firstheaderBorderBelowCB->isChecked())
324 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "dl_below");
326 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
331 void QTabularDialog::ltFirstHeaderStatus_clicked()
333 bool enable(firstheaderStatusCB->isChecked());
335 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "");
337 form_->controller().set(LyXTabular::UNSET_LTFIRSTHEAD, "");
338 firstheaderBorderAboveCB->setEnabled(enable);
339 firstheaderBorderBelowCB->setEnabled(enable);
344 void QTabularDialog::ltFirstHeaderEmpty_clicked()
346 bool enable(firstheaderNoContentsCB->isChecked());
348 form_->controller().set(LyXTabular::SET_LTFIRSTHEAD, "empty");
350 ltFirstHeaderBorderBelow_clicked();
351 ltFirstHeaderBorderAbove_clicked();
353 firstheaderStatusCB->setEnabled(!enable);
354 firstheaderBorderAboveCB->setEnabled(!enable);
355 firstheaderBorderBelowCB->setEnabled(!enable);
360 void QTabularDialog::ltFooterStatus_clicked()
362 bool enable(footerStatusCB->isChecked());
364 form_->controller().set(LyXTabular::SET_LTFOOT, "");
366 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
367 footerBorderAboveCB->setEnabled(enable);
368 footerBorderBelowCB->setEnabled(enable);
369 lastfooterNoContentsCB->setEnabled(enable);
374 void QTabularDialog::ltFooterBorderAbove_clicked()
376 if (footerBorderAboveCB->isChecked())
377 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_above");
379 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
384 void QTabularDialog::ltFooterBorderBelow_clicked()
386 if (footerBorderBelowCB->isChecked())
387 form_->controller().set(LyXTabular::SET_LTFOOT, "dl_below");
389 form_->controller().set(LyXTabular::UNSET_LTFOOT, "");
394 void QTabularDialog::ltLastFooterStatus_clicked()
396 bool enable(lastfooterStatusCB->isChecked());
398 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "");
400 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
401 lastfooterBorderAboveCB->setEnabled(enable);
402 lastfooterBorderBelowCB->setEnabled(enable);
407 void QTabularDialog::ltLastFooterBorderAbove_clicked()
409 if (lastfooterBorderAboveCB->isChecked())
410 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_above");
412 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
417 void QTabularDialog::ltLastFooterBorderBelow_clicked()
419 if (lastfooterBorderBelowCB->isChecked())
420 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "dl_below");
422 form_->controller().set(LyXTabular::UNSET_LTLASTFOOT, "");
427 void QTabularDialog::ltLastFooterEmpty_clicked()
429 bool enable(lastfooterNoContentsCB->isChecked());
431 form_->controller().set(LyXTabular::SET_LTLASTFOOT, "empty");
433 ltLastFooterBorderBelow_clicked();
434 ltLastFooterBorderAbove_clicked();
436 lastfooterStatusCB->setEnabled(!enable);
437 lastfooterBorderAboveCB->setEnabled(!enable);
438 lastfooterBorderBelowCB->setEnabled(!enable);