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.
16 #include "LengthCombo.h"
17 #include "qt_helpers.h"
19 #include "insets/InsetWrap.h"
21 #include "support/convert.h"
22 #include "support/lstrings.h"
25 #include <QCloseEvent>
26 #include <QPushButton>
34 /////////////////////////////////////////////////////////////////////
38 /////////////////////////////////////////////////////////////////////
41 GuiWrapDialog::GuiWrapDialog(GuiWrap * form)
46 connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
47 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
48 connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
49 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
51 connect(widthED, SIGNAL(textChanged(const QString &)),
52 this, SLOT(change_adaptor()));
53 connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
54 this, SLOT(change_adaptor()));
55 connect(valignCO, SIGNAL(highlighted(const QString &)),
56 this, SLOT(change_adaptor()));
60 void GuiWrapDialog::closeEvent(QCloseEvent * e)
67 void GuiWrapDialog::change_adaptor()
72 /////////////////////////////////////////////////////////////////////
76 /////////////////////////////////////////////////////////////////////
78 GuiWrap::GuiWrap(Dialog & parent)
79 : GuiView<GuiWrapDialog>(parent, _("Text Wrap Settings"))
84 void GuiWrap::build_dialog()
86 dialog_.reset(new GuiWrapDialog(this));
88 bcview().setRestore(dialog_->restorePB);
89 bcview().setOK(dialog_->okPB);
90 bcview().setApply(dialog_->applyPB);
91 bcview().setCancel(dialog_->closePB);
93 bcview().addReadOnly(dialog_->widthED);
94 bcview().addReadOnly(dialog_->unitsLC);
95 bcview().addReadOnly(dialog_->valignCO);
101 double const value = convert<double>(fromqstr(dialog_->widthED->text()));
102 Length::UNIT unit = dialog_->unitsLC->currentLengthItem();
103 if (dialog_->widthED->text().isEmpty())
104 unit = Length::UNIT_NONE;
106 InsetWrapParams & params = controller().params();
108 params.width = Length(value, unit);
110 switch (dialog_->valignCO->currentIndex()) {
112 params.placement.erase();
115 params.placement = "l";
118 params.placement = "r";
121 params.placement = "p";
127 static string const numtostr(double val)
129 string a = convert<string>(val);
130 // FIXME: Will this test ever trigger? (Lgb)
137 void GuiWrap::update_contents()
139 InsetWrapParams & params = controller().params();
141 Length len(params.width);
142 dialog_->widthED->setText(toqstr(numtostr(len.value())));
143 dialog_->unitsLC->setCurrentItem(len.unit());
146 if (params.placement == "l")
148 else if (params.placement == "r")
150 else if (params.placement == "p")
153 dialog_->valignCO->setCurrentIndex(item);
156 } // namespace frontend
160 #include "GuiWrap_moc.cpp"