2006-03-05 17:24:44 +00:00
|
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
|
* \file GuiWrap.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiWrap.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
#include "ControlWrap.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
|
#include "LengthCombo.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include "qt_helpers.h"
|
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetWrap.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
#include "support/convert.h"
|
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
|
|
#include <QLineEdit>
|
2007-04-24 14:59:51 +00:00
|
|
|
|
#include <QCloseEvent>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
|
|
|
|
using std::string;
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
namespace frontend {
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
GuiWrapDialog::GuiWrapDialog(LyXView & lv)
|
|
|
|
|
: GuiDialog(lv, "wrap")
|
2007-04-24 14:59:51 +00:00
|
|
|
|
{
|
|
|
|
|
setupUi(this);
|
2007-09-09 23:47:22 +00:00
|
|
|
|
setViewTitle(_("Wrap Float Settings"));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
setController(new ControlWrap(*this));
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
|
|
|
|
connect(widthED, SIGNAL(textChanged(const QString &)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
connect(unitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-24 14:59:51 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(valignCO, SIGNAL(highlighted(const QString &)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bc().setPolicy(ButtonPolicy::NoRepeatedApplyReadOnlyPolicy);
|
|
|
|
|
bc().setRestore(restorePB);
|
|
|
|
|
bc().setOK(okPB);
|
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
|
bc().setCancel(closePB);
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bc().addReadOnly(widthED);
|
|
|
|
|
bc().addReadOnly(unitsLC);
|
|
|
|
|
bc().addReadOnly(valignCO);
|
2007-04-24 14:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
ControlWrap & GuiWrapDialog::controller() const
|
2007-04-24 14:59:51 +00:00
|
|
|
|
{
|
2007-09-10 22:32:59 +00:00
|
|
|
|
return static_cast<ControlWrap &>(GuiDialog::controller());
|
2007-04-24 14:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiWrapDialog::closeEvent(QCloseEvent * e)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-11 17:06:15 +00:00
|
|
|
|
slotClose();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
e->accept();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiWrapDialog::change_adaptor()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiWrapDialog::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
double const value = widthED->text().toDouble();
|
|
|
|
|
Length::UNIT unit = unitsLC->currentLengthItem();
|
|
|
|
|
if (widthED->text().isEmpty())
|
2007-04-28 12:58:49 +00:00
|
|
|
|
unit = Length::UNIT_NONE;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
params.width = Length(value, unit);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
switch (valignCO->currentIndex()) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
case 0:
|
2007-09-09 23:47:22 +00:00
|
|
|
|
params.placement = "o";
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2007-09-09 23:47:22 +00:00
|
|
|
|
params.placement = "i";
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2007-09-09 23:47:22 +00:00
|
|
|
|
params.placement = "l";
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2007-09-09 23:47:22 +00:00
|
|
|
|
params.placement = "r";
|
2006-03-05 17:24:44 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-24 14:59:51 +00:00
|
|
|
|
static string const numtostr(double val)
|
|
|
|
|
{
|
|
|
|
|
string a = convert<string>(val);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
return a;
|
2007-09-09 23:47:22 +00:00
|
|
|
|
//0pt is a legal width now, it yields a
|
|
|
|
|
//wrapfloat just wide enough for the contents.
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiWrapDialog::update_contents()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length len(params.width);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
widthED->setText(toqstr(numtostr(len.value())));
|
|
|
|
|
unitsLC->setCurrentItem(len.unit());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
int item = 0;
|
2007-09-09 23:47:22 +00:00
|
|
|
|
if (params.placement == "i")
|
2006-03-05 17:24:44 +00:00
|
|
|
|
item = 1;
|
2007-09-09 23:47:22 +00:00
|
|
|
|
else if (params.placement == "l")
|
2006-03-05 17:24:44 +00:00
|
|
|
|
item = 2;
|
2007-09-09 23:47:22 +00:00
|
|
|
|
else if (params.placement == "r")
|
2006-03-05 17:24:44 +00:00
|
|
|
|
item = 3;
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
valignCO->setCurrentIndex(item);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
|
} // namespace lyx
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiWrap_moc.cpp"
|