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;
32 typedef QController<ControlWrap, QView<QWrapDialog> > base_class;
34 QWrap::QWrap(Dialog & parent)
35 : base_class(parent, _("LyX: Text Wrap Settings"))
40 void QWrap::build_dialog()
42 dialog_.reset(new QWrapDialog(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);
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 InsetWrapParams & params = controller().params();
64 params.width = LyXLength(value, unit);
66 switch (dialog_->valignCO->currentItem()) {
68 params.placement.erase();
71 params.placement = "l";
74 params.placement = "r";
77 params.placement = "p";
85 string const numtostr(double val) {
95 void QWrap::update_contents()
97 InsetWrapParams & params = controller().params();
99 LyXLength len(params.width);
100 dialog_->widthED->setText(toqstr(numtostr(len.value())));
101 dialog_->unitsLC->setCurrentItem(len.unit());
104 if (params.placement == "l")
106 else if (params.placement == "r")
108 else if (params.placement == "p")
111 dialog_->valignCO->setCurrentItem(item);