2001-12-18 03:16:46 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-11-05 17:08:45 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "math_binaryopinset.h"
|
2002-05-23 09:21:32 +00:00
|
|
|
#include "frontends/Painter.h"
|
2001-11-05 17:08:45 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_support.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-11-05 17:08:45 +00:00
|
|
|
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::max;
|
|
|
|
|
|
|
|
|
2001-11-05 17:08:45 +00:00
|
|
|
MathBinaryOpInset::MathBinaryOpInset(char op)
|
|
|
|
: MathNestInset(2), op_(op)
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
MathInset * MathBinaryOpInset::clone() const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
2001-11-05 17:08:45 +00:00
|
|
|
return new MathBinaryOpInset(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathBinaryOpInset::opwidth() const
|
|
|
|
{
|
|
|
|
return mathed_char_width(LM_TC_CONST, mi_, op_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
|
|
|
|
{
|
|
|
|
mi_ = mi;
|
|
|
|
xcell(0).metrics(mi);
|
|
|
|
xcell(1).metrics(mi);
|
|
|
|
width_ = xcell(0).width() + xcell(1).width() + opwidth();
|
2002-02-16 15:59:55 +00:00
|
|
|
ascent_ = max(xcell(0).ascent(), xcell(1).ascent());
|
|
|
|
descent_ = max(xcell(0).descent(), xcell(1).descent());
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
|
2002-03-21 17:42:56 +00:00
|
|
|
{
|
|
|
|
xcell(0).draw(pain, x, y);
|
2001-11-05 17:08:45 +00:00
|
|
|
drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_);
|
2002-03-21 17:42:56 +00:00
|
|
|
xcell(1).draw(pain, x + width() - xcell(1).width(), y);
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathBinaryOpInset::write(WriteStream & os) const
|
2001-11-05 17:08:45 +00:00
|
|
|
{
|
|
|
|
os << '{' << cell(0) << op_ << cell(1) << '}';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathBinaryOpInset::normalize(NormalStream & os) const
|
2001-11-05 17:08:45 +00:00
|
|
|
{
|
2001-11-08 12:06:56 +00:00
|
|
|
os << "[binop " << op_ << ' ' << cell(0) << ' ' << cell(1) << ']';
|
2001-11-05 17:08:45 +00:00
|
|
|
}
|