mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 21:49:51 +00:00
da4456f2aa
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5334 a592a061-630c-0410-9148-cb99ea01b6c8
106 lines
2.2 KiB
C
106 lines
2.2 KiB
C
/**
|
|
* \file QMinipage.C
|
|
* This file is part of LyX, the document processor.
|
|
* Licence details can be found in the file COPYING.
|
|
*
|
|
* \author John Levon
|
|
*
|
|
* Full author contact details are available in file CREDITS
|
|
*/
|
|
|
|
#include <config.h>
|
|
|
|
#ifdef __GNUG__
|
|
#pragma implementation
|
|
#endif
|
|
|
|
#include "debug.h"
|
|
#include "gettext.h"
|
|
#include "support/lstrings.h"
|
|
#include "LyXView.h"
|
|
#include "ControlMinipage.h"
|
|
|
|
#include "QMinipage.h"
|
|
#include "QMinipageDialog.h"
|
|
#include "Qt2BC.h"
|
|
#include "lengthcombo.h"
|
|
|
|
#include <qpushbutton.h>
|
|
#include <qcombobox.h>
|
|
#include <qlineedit.h>
|
|
|
|
typedef Qt2CB<ControlMinipage, Qt2DB<QMinipageDialog> > base_class;
|
|
|
|
QMinipage::QMinipage()
|
|
: base_class(_("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);
|
|
bc().addReadOnly(dialog_->valignCO);
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
controller().params().pageWidth = LyXLength(value, unit);
|
|
|
|
switch (dialog_->valignCO->currentItem()) {
|
|
case 0:
|
|
controller().params().pos = InsetMinipage::top;
|
|
break;
|
|
case 1:
|
|
controller().params().pos = InsetMinipage::center;
|
|
break;
|
|
case 2:
|
|
controller().params().pos = InsetMinipage::bottom;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
namespace {
|
|
string const numtostr(double val) {
|
|
string a(tostr(val));
|
|
if (a == "0")
|
|
a = "";
|
|
return a;
|
|
}
|
|
} // namespace anon
|
|
|
|
|
|
void QMinipage::update_contents()
|
|
{
|
|
LyXLength len(controller().params().pageWidth);
|
|
dialog_->widthED->setText(numtostr(len.value()).c_str());
|
|
dialog_->unitsLC->setCurrentItem(len.unit());
|
|
lyxerr << "width " << numtostr(len.value()).c_str() << " units " << len.unit() << std::endl;
|
|
|
|
int item = 0;
|
|
switch (controller().params().pos) {
|
|
case InsetMinipage::center:
|
|
item = 1;
|
|
break;
|
|
case InsetMinipage::bottom:
|
|
item = 2;
|
|
break;
|
|
}
|
|
dialog_->valignCO->setCurrentItem(item);
|
|
}
|