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 "QWrapDialog.h"
17 #include "lengthcombo.h"
18 #include "qt_helpers.h"
20 #include "controllers/ControlWrap.h"
22 #include "insets/insetwrap.h"
24 #include "support/tostr.h"
25 #include "support/lstrings.h"
27 #include <qlineedit.h>
28 #include <qpushbutton.h>
30 using lyx::support::strToDbl;
37 typedef QController<ControlWrap, QView<QWrapDialog> > base_class;
39 QWrap::QWrap(Dialog & parent)
40 : base_class(parent, _("LyX: Text Wrap Settings"))
45 void QWrap::build_dialog()
47 dialog_.reset(new QWrapDialog(this));
49 bcview().setRestore(dialog_->restorePB);
50 bcview().setOK(dialog_->okPB);
51 bcview().setApply(dialog_->applyPB);
52 bcview().setCancel(dialog_->closePB);
54 bcview().addReadOnly(dialog_->widthED);
55 bcview().addReadOnly(dialog_->unitsLC);
56 bcview().addReadOnly(dialog_->valignCO);
62 double const value = strToDbl(fromqstr(dialog_->widthED->text()));
63 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
64 if (dialog_->widthED->text().isEmpty())
65 unit = LyXLength::UNIT_NONE;
67 InsetWrapParams & params = controller().params();
69 params.width = LyXLength(value, unit);
71 switch (dialog_->valignCO->currentItem()) {
73 params.placement.erase();
76 params.placement = "l";
79 params.placement = "r";
82 params.placement = "p";
90 string const numtostr(double val) {
100 void QWrap::update_contents()
102 InsetWrapParams & params = controller().params();
104 LyXLength len(params.width);
105 dialog_->widthED->setText(toqstr(numtostr(len.value())));
106 dialog_->unitsLC->setCurrentItem(len.unit());
109 if (params.placement == "l")
111 else if (params.placement == "r")
113 else if (params.placement == "p")
116 dialog_->valignCO->setCurrentItem(item);
119 } // namespace frontend