2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_fboxinset.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-06-24 15:37:14 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#include "math_fboxinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2002-06-24 15:37:14 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2002-07-30 16:04:41 +00:00
|
|
|
|
#include "math_parser.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_streamstr.h"
|
2002-06-24 15:37:14 +00:00
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
2002-07-30 16:04:41 +00:00
|
|
|
|
MathFboxInset::MathFboxInset(latexkeys const * key)
|
|
|
|
|
: MathNestInset(1), key_(key)
|
2002-06-24 15:37:14 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathFboxInset::clone() const
|
2002-06-24 15:37:14 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathFboxInset(*this));
|
2002-06-24 15:37:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-30 16:04:41 +00:00
|
|
|
|
MathInset::mode_type MathFboxInset::currentMode() const
|
|
|
|
|
{
|
|
|
|
|
if (key_->name == "fbox")
|
|
|
|
|
return TEXT_MODE;
|
|
|
|
|
return MATH_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-06-24 15:37:14 +00:00
|
|
|
|
{
|
2002-07-30 16:04:41 +00:00
|
|
|
|
if (key_->name == "fbox") {
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(mi.base, "textnormal");
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metrics(mi, dim_);
|
2002-07-30 16:04:41 +00:00
|
|
|
|
} else {
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metrics(mi, dim_);
|
2002-07-30 16:04:41 +00:00
|
|
|
|
}
|
2003-05-28 13:22:36 +00:00
|
|
|
|
metricsMarkers(5); // 5 pixels margin
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2002-06-24 15:37:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathFboxInset::draw(PainterInfo & pi, int x, int y) const
|
2002-06-24 15:37:14 +00:00
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
|
|
|
|
|
dim_.width() - 2, dim_.height() - 2, LColor::foreground);
|
2002-07-30 16:04:41 +00:00
|
|
|
|
if (key_->name == "fbox") {
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(pi.base, "textnormal");
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, x + 5, y);
|
2002-07-30 16:04:41 +00:00
|
|
|
|
} else {
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, x + 5, y);
|
2002-07-30 16:04:41 +00:00
|
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathFboxInset::write(WriteStream & os) const
|
|
|
|
|
{
|
2002-07-30 16:04:41 +00:00
|
|
|
|
os << '\\' << key_->name << '{' << cell(0) << '}';
|
2002-06-24 15:37:14 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathFboxInset::normalize(NormalStream & os) const
|
|
|
|
|
{
|
2002-07-30 16:04:41 +00:00
|
|
|
|
os << '[' << key_->name << ' ' << cell(0) << ']';
|
2002-06-24 15:37:14 +00:00
|
|
|
|
}
|