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.
14 #include "qt_helpers.h"
15 #include "support/tostr.h"
16 #include "support/lstrings.h"
17 #include "ControlWrap.h"
20 #include "QWrapDialog.h"
22 #include "lengthcombo.h"
24 #include "insets/insetwrap.h"
26 #include <qpushbutton.h>
27 #include <qlineedit.h>
29 using lyx::support::strToDbl;
34 typedef QController<ControlWrap, QView<QWrapDialog> > base_class;
36 QWrap::QWrap(Dialog & parent)
37 : base_class(parent, _("LyX: Text Wrap Settings"))
42 void QWrap::build_dialog()
44 dialog_.reset(new QWrapDialog(this));
46 bcview().setRestore(dialog_->restorePB);
47 bcview().setOK(dialog_->okPB);
48 bcview().setApply(dialog_->applyPB);
49 bcview().setCancel(dialog_->closePB);
51 bcview().addReadOnly(dialog_->widthED);
52 bcview().addReadOnly(dialog_->unitsLC);
53 bcview().addReadOnly(dialog_->valignCO);
59 double const value = strToDbl(fromqstr(dialog_->widthED->text()));
60 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
61 if (dialog_->widthED->text().isEmpty())
62 unit = LyXLength::UNIT_NONE;
64 InsetWrapParams & params = controller().params();
66 params.width = LyXLength(value, unit);
68 switch (dialog_->valignCO->currentItem()) {
70 params.placement.erase();
73 params.placement = "l";
76 params.placement = "r";
79 params.placement = "p";
87 string const numtostr(double val) {
97 void QWrap::update_contents()
99 InsetWrapParams & params = controller().params();
101 LyXLength len(params.width);
102 dialog_->widthED->setText(toqstr(numtostr(len.value())));
103 dialog_->unitsLC->setCurrentItem(len.unit());
106 if (params.placement == "l")
108 else if (params.placement == "r")
110 else if (params.placement == "p")
113 dialog_->valignCO->setCurrentItem(item);