2002-10-07 16:41:10 +00:00
|
|
|
/**
|
|
|
|
* \file QWrap.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Juergen Spitzmueller
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "debug.h"
|
2002-12-17 20:37:13 +00:00
|
|
|
#include "qt_helpers.h"
|
2002-10-07 16:41:10 +00:00
|
|
|
#include "support/lstrings.h"
|
|
|
|
#include "LyXView.h"
|
|
|
|
#include "ControlWrap.h"
|
|
|
|
|
|
|
|
#include "QWrap.h"
|
|
|
|
#include "QWrapDialog.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "lengthcombo.h"
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-10-07 16:41:10 +00:00
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qcombobox.h>
|
|
|
|
#include <qlineedit.h>
|
|
|
|
|
|
|
|
typedef Qt2CB<ControlWrap, Qt2DB<QWrapDialog> > base_class;
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
|
2002-10-07 16:41:10 +00:00
|
|
|
QWrap::QWrap()
|
2002-12-17 20:37:13 +00:00
|
|
|
: base_class(qt_("Wrap Options"))
|
2002-10-07 16:41:10 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QWrapDialog(this));
|
|
|
|
|
|
|
|
bc().setRestore(dialog_->restorePB);
|
|
|
|
bc().setOK(dialog_->okPB);
|
|
|
|
bc().setApply(dialog_->applyPB);
|
|
|
|
bc().setCancel(dialog_->closePB);
|
|
|
|
|
|
|
|
bc().addReadOnly(dialog_->widthED);
|
|
|
|
bc().addReadOnly(dialog_->unitsLC);
|
|
|
|
bc().addReadOnly(dialog_->valignCO);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::apply()
|
|
|
|
{
|
2002-12-17 20:37:13 +00:00
|
|
|
double const value = strToDbl(fromqstr(dialog_->widthED->text()));
|
2002-10-07 16:41:10 +00:00
|
|
|
LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
|
2002-12-17 20:37:13 +00:00
|
|
|
if (dialog_->widthED->text().isEmpty())
|
2002-10-07 16:41:10 +00:00
|
|
|
unit = LyXLength::UNIT_NONE;
|
|
|
|
|
2002-10-20 01:48:28 +00:00
|
|
|
WrapParams & params = controller().params();
|
|
|
|
|
|
|
|
params.pageWidth = LyXLength(value, unit);
|
2002-10-07 16:41:10 +00:00
|
|
|
|
|
|
|
switch (dialog_->valignCO->currentItem()) {
|
|
|
|
case 0:
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement.erase();
|
2002-10-07 16:41:10 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement = "l";
|
2002-10-07 16:41:10 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement = "r";
|
2002-10-07 16:41:10 +00:00
|
|
|
break;
|
|
|
|
case 3:
|
2002-10-20 01:48:28 +00:00
|
|
|
params.placement = "p";
|
2002-10-07 16:41:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
2002-10-20 01:48:28 +00:00
|
|
|
|
|
|
|
string const numtostr(double val) {
|
|
|
|
string a(tostr(val));
|
|
|
|
if (a == "0")
|
|
|
|
a.erase();
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2002-10-07 16:41:10 +00:00
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
|
void QWrap::update_contents()
|
|
|
|
{
|
2002-10-20 01:48:28 +00:00
|
|
|
WrapParams & params = controller().params();
|
|
|
|
|
|
|
|
LyXLength len(params.pageWidth);
|
2002-12-17 20:37:13 +00:00
|
|
|
dialog_->widthED->setText(toqstr(numtostr(len.value())));
|
2002-10-07 16:41:10 +00:00
|
|
|
dialog_->unitsLC->setCurrentItem(len.unit());
|
|
|
|
|
|
|
|
int item = 0;
|
2002-10-20 01:48:28 +00:00
|
|
|
if (params.placement == "l")
|
2002-10-07 16:41:10 +00:00
|
|
|
item = 1;
|
2002-10-20 01:48:28 +00:00
|
|
|
else if (params.placement == "r")
|
2002-10-07 16:41:10 +00:00
|
|
|
item = 2;
|
2002-10-20 01:48:28 +00:00
|
|
|
else if (params.placement == "p")
|
2002-10-07 16:41:10 +00:00
|
|
|
item = 3;
|
|
|
|
|
|
|
|
dialog_->valignCO->setCurrentItem(item);
|
|
|
|
}
|