mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-11 21:49:51 +00:00
102 lines
2.1 KiB
C++
102 lines
2.1 KiB
C++
|
/**
|
||
|
* \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>
|
||
|
#include <qradiobutton.h>
|
||
|
#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"
|
||
|
|
||
|
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);
|
||
|
bc().addReadOnly(dialog_->topRB);
|
||
|
bc().addReadOnly(dialog_->bottomRB);
|
||
|
bc().addReadOnly(dialog_->middleRB);
|
||
|
}
|
||
|
|
||
|
|
||
|
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);
|
||
|
|
||
|
controller().params().width = len.asString();
|
||
|
|
||
|
if (dialog_->topRB->isChecked())
|
||
|
controller().params().pos = InsetMinipage::top;
|
||
|
else if (dialog_->middleRB->isChecked())
|
||
|
controller().params().pos = InsetMinipage::center;
|
||
|
else
|
||
|
controller().params().pos = InsetMinipage::bottom;
|
||
|
}
|
||
|
|
||
|
|
||
|
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().width.c_str());
|
||
|
dialog_->widthED->setText(numtostr(len.value()).c_str());
|
||
|
dialog_->unitsLC->setCurrentItem(len.unit());
|
||
|
|
||
|
QRadioButton * button = dialog_->topRB;
|
||
|
|
||
|
switch (controller().params().pos) {
|
||
|
case InsetMinipage::center:
|
||
|
button = dialog_->middleRB;
|
||
|
break;
|
||
|
case InsetMinipage::bottom:
|
||
|
button = dialog_->bottomRB;
|
||
|
break;
|
||
|
}
|
||
|
button->setChecked(true);
|
||
|
}
|