3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Jürgen Spitzmüller
8 * Full author contact details are available in file CREDITS.
13 #include "QBoxDialog.h"
15 #include "lengthcombo.h"
16 #include "lengthvalidator.h"
18 #include "qt_helpers.h"
20 #include <qcombobox.h>
21 #include <qlineedit.h>
22 #include <qpushbutton.h>
29 LengthValidator * unsignedLengthValidator(QLineEdit * ed)
31 LengthValidator * v = new LengthValidator(ed);
32 v->setBottom(LyXLength());
39 QBoxDialog::QBoxDialog(QBox * form)
40 : QBoxDialogBase(0, 0, false, 0),
43 connect(restorePB, SIGNAL(clicked()),
44 form, SLOT(slotRestore()));
45 connect(okPB, SIGNAL(clicked()),
46 form, SLOT(slotOK()));
47 connect(applyPB, SIGNAL(clicked()),
48 form, SLOT(slotApply()));
49 connect(closePB, SIGNAL(clicked()),
50 form, SLOT(slotClose()));
52 heightED->setValidator(unsignedLengthValidator(heightED));
53 widthED->setValidator(unsignedLengthValidator(widthED));
57 void QBoxDialog::closeEvent(QCloseEvent * e)
64 void QBoxDialog::change_adaptor()
70 void QBoxDialog::innerBoxChanged(const QString & str)
72 bool ibox = (str != qt_("None"));
73 valignCO->setEnabled(ibox);
74 ialignCO->setEnabled(ibox);
75 halignCO->setEnabled(!ibox);
76 heightED->setEnabled(ibox);
77 heightUnitsLC->setEnabled(ibox);
78 form_->setSpecial(ibox);
82 void QBoxDialog::typeChanged(int index)
84 bool frameless = (index == 0);
86 valignCO->setEnabled(true);
87 ialignCO->setEnabled(true);
88 halignCO->setEnabled(false);
89 heightED->setEnabled(true);
90 heightUnitsLC->setEnabled(true);
91 form_->setSpecial(true);
93 int itype = innerBoxCO->currentItem();
94 form_->setInnerType(frameless, itype);
98 void QBoxDialog::restoreClicked()
100 form_->setInnerType(true, 2);
101 widthED->setText("100");
102 widthUnitsLC->setCurrentItem(LyXLength::PCW);
103 heightED->setText("1");
104 for (int j = 0; j < heightUnitsLC->count(); j++) {
105 if (heightUnitsLC->text(j) == qt_("Total Height"))
106 heightUnitsLC->setCurrentItem(j);
110 } // namespace frontend