3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
19 #include "support/lstrings.h"
21 #include "ControlMinipage.h"
23 #include "QMinipage.h"
24 #include "QMinipageDialog.h"
26 #include "lengthcombo.h"
28 #include <qpushbutton.h>
29 #include <qcombobox.h>
30 #include <qlineedit.h>
32 typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
34 QMinipage::QMinipage()
35 : base_class(_("Minipage"))
40 void QMinipage::build_dialog()
42 dialog_.reset(new QMinipageDialog(this));
44 bc().setRestore(dialog_->restorePB);
45 bc().setOK(dialog_->okPB);
46 bc().setApply(dialog_->applyPB);
47 bc().setCancel(dialog_->closePB);
49 bc().addReadOnly(dialog_->widthED);
50 bc().addReadOnly(dialog_->unitsLC);
51 bc().addReadOnly(dialog_->valignCO);
55 void QMinipage::apply()
57 double value = strToDbl(dialog_->widthED->text().latin1());
58 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
59 if (string(dialog_->widthED->text().latin1()).empty())
60 unit = LyXLength::UNIT_NONE;
62 controller().params().pageWidth = LyXLength(value, unit);
64 switch (dialog_->valignCO->currentItem()) {
66 controller().params().pos = InsetMinipage::top;
69 controller().params().pos = InsetMinipage::center;
72 controller().params().pos = InsetMinipage::bottom;
79 string const numtostr(double val) {
88 void QMinipage::update_contents()
90 LyXLength len(controller().params().pageWidth);
91 dialog_->widthED->setText(numtostr(len.value()).c_str());
92 dialog_->unitsLC->setCurrentItem(len.unit());
93 lyxerr << "width " << numtostr(len.value()).c_str() << " units " << len.unit() << std::endl;
96 switch (controller().params().pos) {
97 case InsetMinipage::center:
100 case InsetMinipage::bottom:
104 dialog_->valignCO->setCurrentItem(item);