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 "ControlWrap.h"
16 #include "LengthCombo.h"
17 #include "qt_helpers.h"
19 #include "insets/InsetWrap.h"
21 #include "support/lstrings.h"
24 #include <QCloseEvent>
25 #include <QPushButton>
33 GuiWrapDialog::GuiWrapDialog(LyXView & lv)
34 : GuiDialog(lv, "wrap")
37 setViewTitle(_("Wrap Float Settings"));
38 setController(new ControlWrap(*this));
40 connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
41 connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
42 connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
43 connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
45 connect(widthED, SIGNAL(textChanged(const QString &)),
46 this, SLOT(change_adaptor()));
47 connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
48 this, SLOT(change_adaptor()));
49 connect(valignCO, SIGNAL(highlighted(const QString &)),
50 this, SLOT(change_adaptor()));
52 bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
53 bc().setRestore(restorePB);
55 bc().setApply(applyPB);
56 bc().setCancel(closePB);
58 bc().addReadOnly(widthED);
59 bc().addReadOnly(unitsLC);
60 bc().addReadOnly(valignCO);
64 ControlWrap & GuiWrapDialog::controller()
66 return static_cast<ControlWrap &>(GuiDialog::controller());
70 void GuiWrapDialog::closeEvent(QCloseEvent * e)
77 void GuiWrapDialog::change_adaptor()
83 void GuiWrapDialog::applyView()
85 double const value = widthED->text().toDouble();
86 Length::UNIT unit = unitsLC->currentLengthItem();
87 if (widthED->text().isEmpty())
88 unit = Length::UNIT_NONE;
90 InsetWrapParams & params = controller().params();
92 params.width = Length(value, unit);
94 switch (valignCO->currentIndex()) {
96 params.placement = "o";
99 params.placement = "i";
102 params.placement = "l";
105 params.placement = "r";
111 void GuiWrapDialog::updateContents()
113 InsetWrapParams & params = controller().params();
115 Length len(params.width);
116 //0pt is a legal width now, it yields a
117 //wrapfloat just wide enough for the contents.
118 widthED->setText(QString::number(len.value()));
119 unitsLC->setCurrentItem(len.unit());
122 if (params.placement == "i")
124 else if (params.placement == "l")
126 else if (params.placement == "r")
129 valignCO->setCurrentIndex(item);
132 } // namespace frontend
136 #include "GuiWrap_moc.cpp"