2002-06-24 15:37:14 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_fboxinset.h"
|
|
|
|
#include "math_support.h"
|
|
|
|
#include "math_mathmlstream.h"
|
2002-07-30 16:04:41 +00:00
|
|
|
#include "math_streamstr.h"
|
|
|
|
#include "math_parser.h"
|
2002-06-24 15:37:14 +00:00
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
MathInset * MathFboxInset::clone() const
|
|
|
|
{
|
|
|
|
return new MathFboxInset(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 16:04:41 +00:00
|
|
|
MathInset::mode_type MathFboxInset::currentMode() const
|
|
|
|
{
|
|
|
|
if (key_->name == "fbox")
|
|
|
|
return TEXT_MODE;
|
|
|
|
return MATH_MODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-24 15:37:14 +00:00
|
|
|
void MathFboxInset::metrics(MathMetricsInfo & mi) const
|
|
|
|
{
|
2002-07-30 16:04:41 +00:00
|
|
|
if (key_->name == "fbox") {
|
|
|
|
MathFontSetChanger dummy(mi.base, "textnormal");
|
2002-08-02 14:29:42 +00:00
|
|
|
dim_ = cell(0).metrics(mi);
|
2002-07-30 16:04:41 +00:00
|
|
|
metricsMarkers2(5); // 5 pixels margin
|
|
|
|
} else {
|
2002-08-02 14:29:42 +00:00
|
|
|
dim_ = cell(0).metrics(mi);
|
2002-07-30 16:04:41 +00:00
|
|
|
metricsMarkers2(5); // 5 pixels margin
|
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const
|
|
|
|
{
|
|
|
|
pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
|
|
|
|
LColor::black);
|
2002-07-30 16:04:41 +00:00
|
|
|
if (key_->name == "fbox") {
|
|
|
|
MathFontSetChanger 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
|
|
|
}
|