2001-08-29 02:08:04 +00:00
|
|
|
/**
|
|
|
|
* \file QMinipage.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <qpushbutton.h>
|
2001-09-02 18:10:50 +00:00
|
|
|
#include <qcombobox.h>
|
2001-08-29 02:08:04 +00:00
|
|
|
#include <qlineedit.h>
|
|
|
|
#include "lengthcombo.h"
|
|
|
|
|
|
|
|
#include "QMinipageDialog.h"
|
|
|
|
#include "QMinipage.h"
|
|
|
|
#include "Qt2BC.h"
|
|
|
|
#include "gettext.h"
|
|
|
|
#include "support/lstrings.h"
|
|
|
|
|
|
|
|
#include "QtLyXView.h"
|
|
|
|
#include "ControlMinipage.h"
|
|
|
|
|
2001-09-02 18:10:50 +00:00
|
|
|
#include "debug.h"
|
2001-08-29 02:08:04 +00:00
|
|
|
typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
|
|
|
|
|
|
|
|
QMinipage::QMinipage(ControlMinipage & c)
|
|
|
|
: base_class(c, _("Minipage"))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QMinipage::build_dialog()
|
|
|
|
{
|
|
|
|
dialog_.reset(new QMinipageDialog(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);
|
2001-09-02 18:10:50 +00:00
|
|
|
bc().addReadOnly(dialog_->valignCO);
|
2001-08-29 02:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void QMinipage::apply()
|
|
|
|
{
|
|
|
|
double value = strToDbl(dialog_->widthED->text().latin1());
|
|
|
|
LyXLength::UNIT unit = dialog_->unitsLC->currentLengthItem();
|
|
|
|
if (string(dialog_->widthED->text().latin1()).empty())
|
|
|
|
unit = LyXLength::UNIT_NONE;
|
|
|
|
|
|
|
|
LyXLength len(value, unit);
|
|
|
|
|
2002-01-14 16:10:29 +00:00
|
|
|
controller().params().pageWidth = len.asString();
|
2001-08-29 02:08:04 +00:00
|
|
|
|
2001-09-02 18:10:50 +00:00
|
|
|
switch (dialog_->valignCO->currentItem()) {
|
|
|
|
case 0:
|
2001-08-29 02:08:04 +00:00
|
|
|
controller().params().pos = InsetMinipage::top;
|
2001-09-02 18:10:50 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2001-08-29 02:08:04 +00:00
|
|
|
controller().params().pos = InsetMinipage::center;
|
2001-09-02 18:10:50 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2001-08-29 02:08:04 +00:00
|
|
|
controller().params().pos = InsetMinipage::bottom;
|
2001-09-02 18:10:50 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-08-29 02:08:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
string const numtostr(double val) {
|
|
|
|
string a(tostr(val));
|
|
|
|
if (a == "0")
|
|
|
|
a = "";
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
} // namespace anon
|
|
|
|
|
|
|
|
|
|
|
|
void QMinipage::update_contents()
|
|
|
|
{
|
2002-01-14 16:10:29 +00:00
|
|
|
LyXLength len(controller().params().pageWidth.c_str());
|
2001-08-29 02:08:04 +00:00
|
|
|
dialog_->widthED->setText(numtostr(len.value()).c_str());
|
|
|
|
dialog_->unitsLC->setCurrentItem(len.unit());
|
2001-09-02 18:10:50 +00:00
|
|
|
lyxerr << "width " << numtostr(len.value()).c_str() << " units " << len.unit() << std::endl;
|
2001-08-29 02:08:04 +00:00
|
|
|
|
2001-09-02 18:10:50 +00:00
|
|
|
int item = 0;
|
2001-08-29 02:08:04 +00:00
|
|
|
switch (controller().params().pos) {
|
|
|
|
case InsetMinipage::center:
|
2001-09-02 18:10:50 +00:00
|
|
|
item = 1;
|
2001-08-29 02:08:04 +00:00
|
|
|
break;
|
|
|
|
case InsetMinipage::bottom:
|
2001-09-02 18:10:50 +00:00
|
|
|
item = 2;
|
2001-08-29 02:08:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2001-09-02 18:10:50 +00:00
|
|
|
dialog_->valignCO->setCurrentItem(item);
|
2001-08-29 02:08:04 +00:00
|
|
|
}
|