3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author John Levon <moz@compsoc.man.ac.uk>
12 #pragma implementation
15 #include <qpushbutton.h>
16 #include <qcombobox.h>
17 #include <qlineedit.h>
18 #include "lengthcombo.h"
20 #include "QMinipageDialog.h"
21 #include "QMinipage.h"
24 #include "support/lstrings.h"
26 #include "QtLyXView.h"
27 #include "ControlMinipage.h"
30 typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
32 QMinipage::QMinipage(ControlMinipage & c)
33 : base_class(c, _("Minipage"))
38 void QMinipage::build_dialog()
40 dialog_.reset(new QMinipageDialog(this));
42 bc().setRestore(dialog_->restorePB);
43 bc().setOK(dialog_->okPB);
44 bc().setApply(dialog_->applyPB);
45 bc().setCancel(dialog_->closePB);
47 bc().addReadOnly(dialog_->widthED);
48 bc().addReadOnly(dialog_->unitsLC);
49 bc().addReadOnly(dialog_->valignCO);
53 void QMinipage::apply()
55 double value = strToDbl(dialog_->widthED->text().latin1());
56 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
57 if (string(dialog_->widthED->text().latin1()).empty())
58 unit = LyXLength::UNIT_NONE;
60 controller().params().pageWidth = LyXLength(value, unit);
62 switch (dialog_->valignCO->currentItem()) {
64 controller().params().pos = InsetMinipage::top;
67 controller().params().pos = InsetMinipage::center;
70 controller().params().pos = InsetMinipage::bottom;
77 string const numtostr(double val) {
86 void QMinipage::update_contents()
88 LyXLength len(controller().params().pageWidth);
89 dialog_->widthED->setText(numtostr(len.value()).c_str());
90 dialog_->unitsLC->setCurrentItem(len.unit());
91 lyxerr << "width " << numtostr(len.value()).c_str() << " units " << len.unit() << std::endl;
94 switch (controller().params().pos) {
95 case InsetMinipage::center:
98 case InsetMinipage::bottom:
102 dialog_->valignCO->setCurrentItem(item);