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 #include "qt_helpers.h"
15 #include "support/tostr.h"
16 #include "support/lstrings.h"
18 #include "ControlMinipage.h"
20 #include "QMinipage.h"
21 #include "QMinipageDialog.h"
23 #include "lengthcombo.h"
25 #include <qpushbutton.h>
26 #include <qcombobox.h>
27 #include <qlineedit.h>
29 typedef QController<ControlMinipage, QView<QMinipageDialog> > base_class;
32 QMinipage::QMinipage(Dialog & parent)
33 : base_class(parent, _("LyX: Minipage Settings"))
38 void QMinipage::build_dialog()
40 dialog_.reset(new QMinipageDialog(this));
42 bcview().setRestore(dialog_->restorePB);
43 bcview().setOK(dialog_->okPB);
44 bcview().setApply(dialog_->applyPB);
45 bcview().setCancel(dialog_->closePB);
47 bcview().addReadOnly(dialog_->widthED);
48 bcview().addReadOnly(dialog_->unitsLC);
49 bcview().addReadOnly(dialog_->valignCO);
53 void QMinipage::apply()
55 double const value = strToDbl(fromqstr(dialog_->widthED->text()));
56 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
57 if (dialog_->widthED->text().isEmpty())
58 unit = LyXLength::UNIT_NONE;
60 InsetMinipage::Params & params = controller().params();
62 params.width = LyXLength(value, unit);
64 switch (dialog_->valignCO->currentItem()) {
66 params.pos = InsetMinipage::top;
69 params.pos = InsetMinipage::center;
72 params.pos = InsetMinipage::bottom;
80 string const numtostr(double val)
91 void QMinipage::update_contents()
93 InsetMinipage::Params const & params = controller().params();
95 LyXLength len(params.width);
96 dialog_->widthED->setText(toqstr(numtostr(len.value())));
97 dialog_->unitsLC->setCurrentItem(len.unit());
100 switch (params.pos) {
101 case InsetMinipage::top:
104 case InsetMinipage::center:
107 case InsetMinipage::bottom:
111 dialog_->valignCO->setCurrentItem(item);