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-09-24 13:43:58 +00:00
|
|
|
|
#include "Validator.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
|
#include "insets/InsetWrap.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
#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-09-24 13:43:58 +00:00
|
|
|
|
connect(widthUnitLC, 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-24 22:35:00 +00:00
|
|
|
|
connect(overhangCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-09-24 13:43:58 +00:00
|
|
|
|
connect(overhangED, SIGNAL(textChanged(const QString &)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(overhangUnitLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-09-24 22:35:00 +00:00
|
|
|
|
connect(linesCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-09-24 13:43:58 +00:00
|
|
|
|
connect(linesSB, SIGNAL(valueChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
|
2007-09-24 22:35:00 +00:00
|
|
|
|
connect(overhangCB, SIGNAL(stateChanged(int)), this, SLOT(overhangChecked(int)));
|
|
|
|
|
connect(linesCB, SIGNAL(stateChanged(int)), this, SLOT(linesChecked(int)));
|
|
|
|
|
|
2007-09-24 13:43:58 +00:00
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
|
|
|
|
// FIXME:
|
|
|
|
|
// overhang can be negative, but the unsignedLengthValidator allows this
|
|
|
|
|
overhangED->setValidator(unsignedLengthValidator(overhangED));
|
2007-04-24 14:59:51 +00:00
|
|
|
|
|
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);
|
2007-09-24 13:43:58 +00:00
|
|
|
|
bc().addReadOnly(widthUnitLC);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bc().addReadOnly(valignCO);
|
2007-09-24 22:35:00 +00:00
|
|
|
|
bc().addReadOnly(overhangCB);
|
|
|
|
|
bc().addReadOnly(linesCB);
|
2007-09-24 13:43:58 +00:00
|
|
|
|
|
|
|
|
|
// initialize the length validator
|
|
|
|
|
bc().addCheckedLineEdit(widthED, widthLA);
|
2007-09-24 22:35:00 +00:00
|
|
|
|
bc().addCheckedLineEdit(overhangED, overhangCB);
|
2007-04-24 14:59:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-11 18:33:42 +00:00
|
|
|
|
ControlWrap & GuiWrapDialog::controller()
|
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-24 22:35:00 +00:00
|
|
|
|
void GuiWrapDialog::overhangChecked(int checkState)
|
|
|
|
|
{
|
|
|
|
|
if (checkState == Qt::Checked) {
|
|
|
|
|
overhangED->setEnabled(true);
|
|
|
|
|
overhangUnitLC->setEnabled(true);
|
|
|
|
|
} else {
|
|
|
|
|
overhangED->setEnabled(false);
|
|
|
|
|
overhangUnitLC->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void GuiWrapDialog::linesChecked(int checkState)
|
|
|
|
|
{
|
|
|
|
|
if (checkState == Qt::Checked)
|
|
|
|
|
linesSB->setEnabled(true);
|
|
|
|
|
else
|
|
|
|
|
linesSB->setEnabled(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
void GuiWrapDialog::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2007-09-24 13:43:58 +00:00
|
|
|
|
double const width_value = widthED->text().toDouble();
|
|
|
|
|
Length::UNIT widthUnit = widthUnitLC->currentLengthItem();
|
2007-09-05 20:33:29 +00:00
|
|
|
|
if (widthED->text().isEmpty())
|
2007-09-24 13:43:58 +00:00
|
|
|
|
widthUnit = Length::UNIT_NONE;
|
|
|
|
|
double const overhang_value = overhangED->text().toDouble();
|
|
|
|
|
Length::UNIT overhangUnit = overhangUnitLC->currentLengthItem();
|
|
|
|
|
if (overhangED->text().isEmpty())
|
|
|
|
|
overhangUnit = Length::UNIT_NONE;
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-09-24 13:43:58 +00:00
|
|
|
|
params.width = Length(width_value, widthUnit);
|
2007-09-24 22:35:00 +00:00
|
|
|
|
|
|
|
|
|
if (overhangCB->checkState() == Qt::Checked)
|
|
|
|
|
params.overhang = Length(overhang_value, overhangUnit);
|
|
|
|
|
else
|
|
|
|
|
// when value is "0" the option is not set in the LaTeX-output
|
|
|
|
|
// in InsetWrap.cpp
|
|
|
|
|
params.overhang = Length("0in");
|
|
|
|
|
|
|
|
|
|
if (linesCB->checkState() == Qt::Checked)
|
|
|
|
|
params.lines = linesSB->value();
|
|
|
|
|
else
|
|
|
|
|
// when value is "0" the option is not set in the LaTeX-output
|
|
|
|
|
// in InsetWrap.cpp
|
|
|
|
|
params.lines = 0;
|
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-09-11 18:33:42 +00:00
|
|
|
|
void GuiWrapDialog::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
|
|
|
|
InsetWrapParams & params = controller().params();
|
|
|
|
|
|
2007-09-11 21:27:57 +00:00
|
|
|
|
//0pt is a legal width now, it yields a
|
|
|
|
|
//wrapfloat just wide enough for the contents.
|
2007-09-24 13:43:58 +00:00
|
|
|
|
Length len_w(params.width);
|
|
|
|
|
widthED->setText(QString::number(len_w.value()));
|
|
|
|
|
widthUnitLC->setCurrentItem(len_w.unit());
|
|
|
|
|
Length len_o(params.overhang);
|
|
|
|
|
overhangED->setText(QString::number(len_o.value()));
|
|
|
|
|
overhangUnitLC->setCurrentItem(len_o.unit());
|
|
|
|
|
linesSB->setValue(params.lines);
|
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"
|