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.
15 #include "LengthCombo.h"
16 #include "qt_helpers.h"
18 #include "insets/InsetWrap.h"
20 #include "support/convert.h"
21 #include "support/lstrings.h"
24 #include <QCloseEvent>
25 #include <QPushButton>
33 /////////////////////////////////////////////////////////////////////
37 /////////////////////////////////////////////////////////////////////
40 GuiWrapDialog::GuiWrapDialog(GuiWrap * form)
45 connect(restorePB, SIGNAL(clicked()), form, SLOT(slotRestore()));
46 connect(okPB, SIGNAL(clicked()), form, SLOT(slotOK()));
47 connect(applyPB, SIGNAL(clicked()), form, SLOT(slotApply()));
48 connect(closePB, SIGNAL(clicked()), form, SLOT(slotClose()));
50 connect(widthED, SIGNAL(textChanged(const QString &)),
51 this, SLOT(change_adaptor()));
52 connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
53 this, SLOT(change_adaptor()));
54 connect(valignCO, SIGNAL(highlighted(const QString &)),
55 this, SLOT(change_adaptor()));
59 void GuiWrapDialog::closeEvent(QCloseEvent * e)
66 void GuiWrapDialog::change_adaptor()
71 /////////////////////////////////////////////////////////////////////
75 /////////////////////////////////////////////////////////////////////
77 GuiWrap::GuiWrap(GuiDialog & parent)
78 : GuiView<GuiWrapDialog>(parent, _("Text Wrap Settings"))
83 void GuiWrap::build_dialog()
85 dialog_.reset(new GuiWrapDialog(this));
87 bc().setRestore(dialog_->restorePB);
88 bc().setOK(dialog_->okPB);
89 bc().setApply(dialog_->applyPB);
90 bc().setCancel(dialog_->closePB);
92 bc().addReadOnly(dialog_->widthED);
93 bc().addReadOnly(dialog_->unitsLC);
94 bc().addReadOnly(dialog_->valignCO);
100 double const value = convert<double>(fromqstr(dialog_->widthED->text()));
101 Length::UNIT unit = dialog_->unitsLC->currentLengthItem();
102 if (dialog_->widthED->text().isEmpty())
103 unit = Length::UNIT_NONE;
105 InsetWrapParams & params = controller().params();
107 params.width = Length(value, unit);
109 switch (dialog_->valignCO->currentIndex()) {
111 params.placement.erase();
114 params.placement = "l";
117 params.placement = "r";
120 params.placement = "p";
126 static string const numtostr(double val)
128 string a = convert<string>(val);
129 // FIXME: Will this test ever trigger? (Lgb)
136 void GuiWrap::update_contents()
138 InsetWrapParams & params = controller().params();
140 Length len(params.width);
141 dialog_->widthED->setText(toqstr(numtostr(len.value())));
142 dialog_->unitsLC->setCurrentItem(len.unit());
145 if (params.placement == "l")
147 else if (params.placement == "r")
149 else if (params.placement == "p")
152 dialog_->valignCO->setCurrentIndex(item);
155 } // namespace frontend
159 #include "GuiWrap_moc.cpp"