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 using namespace lyx::support;
31 typedef QController<ControlMinipage, QView<QMinipageDialog> > base_class;
34 QMinipage::QMinipage(Dialog & parent)
35 : base_class(parent, _("LyX: Minipage Settings"))
40 void QMinipage::build_dialog()
42 dialog_.reset(new QMinipageDialog(this));
44 bcview().setRestore(dialog_->restorePB);
45 bcview().setOK(dialog_->okPB);
46 bcview().setApply(dialog_->applyPB);
47 bcview().setCancel(dialog_->closePB);
49 bcview().addReadOnly(dialog_->widthED);
50 bcview().addReadOnly(dialog_->unitsLC);
51 bcview().addReadOnly(dialog_->valignCO);
55 void QMinipage::apply()
57 double const value = strToDbl(fromqstr(dialog_->widthED->text()));
58 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
59 if (dialog_->widthED->text().isEmpty())
60 unit = LyXLength::UNIT_NONE;
62 InsetMinipage::Params & params = controller().params();
64 params.width = LyXLength(value, unit);
66 switch (dialog_->valignCO->currentItem()) {
68 params.pos = InsetMinipage::top;
71 params.pos = InsetMinipage::center;
74 params.pos = InsetMinipage::bottom;
82 string const numtostr(double val)
93 void QMinipage::update_contents()
95 InsetMinipage::Params const & params = controller().params();
97 LyXLength len(params.width);
98 dialog_->widthED->setText(toqstr(numtostr(len.value())));
99 dialog_->unitsLC->setCurrentItem(len.unit());
102 switch (params.pos) {
103 case InsetMinipage::top:
106 case InsetMinipage::center:
109 case InsetMinipage::bottom:
113 dialog_->valignCO->setCurrentItem(item);