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/convert.h"
25 #include "support/lstrings.h"
28 #include <QPushButton>
36 typedef QController<ControlWrap, QView<QWrapDialog> > wrap_base_class;
38 QWrap::QWrap(Dialog & parent)
39 : wrap_base_class(parent, _("Text Wrap Settings"))
44 void QWrap::build_dialog()
46 dialog_.reset(new QWrapDialog(this));
48 bcview().setRestore(dialog_->restorePB);
49 bcview().setOK(dialog_->okPB);
50 bcview().setApply(dialog_->applyPB);
51 bcview().setCancel(dialog_->closePB);
53 bcview().addReadOnly(dialog_->widthED);
54 bcview().addReadOnly(dialog_->unitsLC);
55 bcview().addReadOnly(dialog_->valignCO);
61 double const value = convert<double>(fromqstr(dialog_->widthED->text()));
62 LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
63 if (dialog_->widthED->text().isEmpty())
64 unit = LyXLength::UNIT_NONE;
66 InsetWrapParams & params = controller().params();
68 params.width = LyXLength(value, unit);
70 switch (dialog_->valignCO->currentIndex()) {
72 params.placement.erase();
75 params.placement = "l";
78 params.placement = "r";
81 params.placement = "p";
89 string const numtostr(double val) {
90 string a(convert<string>(val));
92 #warning Will this test ever trigger? (Lgb)
102 void QWrap::update_contents()
104 InsetWrapParams & params = controller().params();
106 LyXLength len(params.width);
107 dialog_->widthED->setText(toqstr(numtostr(len.value())));
108 dialog_->unitsLC->setCurrentItem(len.unit());
111 if (params.placement == "l")
113 else if (params.placement == "r")
115 else if (params.placement == "p")
118 dialog_->valignCO->setCurrentIndex(item);
121 } // namespace frontend