2001-02-13 13:28:32 +00:00
|
|
|
#include "math_bigopinset.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "mathed/support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
|
2001-02-14 15:00:50 +00:00
|
|
|
using std::ostream;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
MathBigopInset::MathBigopInset(string const & name, int id)
|
2001-07-12 07:18:29 +00:00
|
|
|
: MathUpDownInset(false, false), sym_(id), limits_(0)
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
|
|
|
SetName(name);
|
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathBigopInset::clone() const
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return new MathBigopInset(*this);
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
int MathBigopInset::limits() const
|
|
|
|
{
|
|
|
|
return limits_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigopInset::limits(int limits)
|
|
|
|
{
|
|
|
|
limits_ = limits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathBigopInset::hasLimits() const
|
|
|
|
{
|
|
|
|
return limits_ == 1 || (limits_ == 0 && size() == LM_ST_DISPLAY);
|
|
|
|
}
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathBigopInset::Write(ostream & os, bool fragile) const
|
2001-02-28 11:56:36 +00:00
|
|
|
{
|
2001-06-27 14:10:35 +00:00
|
|
|
//bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
|
2001-06-25 00:06:33 +00:00
|
|
|
os << '\\' << name();
|
2001-07-12 07:18:29 +00:00
|
|
|
MathUpDownInset::Write(os, fragile);
|
2001-02-28 11:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathBigopInset::WriteNormal(ostream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
{
|
2001-07-12 07:18:29 +00:00
|
|
|
os << "[bigop " << name() << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
|
|
|
|
void MathBigopInset::Metrics(MathStyles st, int, int)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-07-12 07:18:29 +00:00
|
|
|
//cerr << "\nBigopDraw\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
size(st);
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
if (sym_ < 256 || sym_ == LM_oint) {
|
2001-07-12 07:18:29 +00:00
|
|
|
ssym_ = string();
|
|
|
|
ssym_ += (sym_ == LM_oint) ? LM_int : sym_;
|
|
|
|
code_ = LM_TC_BSYM;
|
2001-02-13 13:28:32 +00:00
|
|
|
} else {
|
2001-07-12 07:18:29 +00:00
|
|
|
ssym_ = name();
|
|
|
|
code_ = LM_TC_TEXTRM;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
int wid;
|
|
|
|
mathed_string_dim(code_, size(), ssym_, ascent_, descent_, wid);
|
2001-06-25 00:06:33 +00:00
|
|
|
if (sym_ == LM_oint)
|
2001-06-27 14:10:35 +00:00
|
|
|
wid += 2;
|
2001-07-12 07:18:29 +00:00
|
|
|
//cerr << " asc: " << ascent_ << " des: " << descent_
|
|
|
|
// << " wid: " << wid << "\n";
|
|
|
|
//cerr << " hasLimits: " << hasLimits() << " up: "
|
|
|
|
// << up() << " down: " << down() << "\n";
|
|
|
|
|
|
|
|
width_ = wid;
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
if (hasLimits()) {
|
2001-07-12 07:18:29 +00:00
|
|
|
xcell(0).Metrics(st);
|
|
|
|
xcell(1).Metrics(st);
|
|
|
|
//cerr << " 0: ascent_: " << xcell(0).ascent() << " descent_: " <<
|
|
|
|
// xcell(0).descent() << " width_: " << xcell(0).width() << "\n";
|
|
|
|
//cerr << " 1: ascent_: " << xcell(1).ascent() << " descent_: " <<
|
|
|
|
// xcell(1).descent() << " width_: " << xcell(1).width() << "\n";
|
|
|
|
if (up()) {
|
|
|
|
ascent_ += xcell(0).height() + 1;
|
|
|
|
width_ = std::max(width_, xcell(0).width());
|
|
|
|
dy0_ = - (ascent_ - xcell(0).ascent());
|
|
|
|
}
|
|
|
|
if (down()) {
|
|
|
|
descent_ += xcell(1).height() + 1;
|
|
|
|
width_ = std::max(width_, xcell(1).width());
|
|
|
|
dy1_ = descent_ - xcell(1).descent();
|
|
|
|
}
|
|
|
|
dxx_ = (width_ - wid) / 2;
|
|
|
|
dx0_ = (width_ - xcell(0).width()) / 2;
|
|
|
|
dx1_ = (width_ - xcell(1).width()) / 2;
|
|
|
|
//cerr << " ascent_: " << ascent_ << " descent_: "
|
|
|
|
// << descent_ << " width_: " << width_ << "\n";
|
|
|
|
//cerr << " dx0_: " << dx0_ << " dx1_: " << dx1_
|
|
|
|
// << " dxx_: " << dxx_ << "\n";
|
|
|
|
//cerr << " dy0_: " << dy0_ << " dy1_: " << dy1_
|
|
|
|
// << "\n";
|
2001-06-27 14:10:35 +00:00
|
|
|
} else {
|
2001-07-12 07:18:29 +00:00
|
|
|
MathUpDownInset::Metrics(st, ascent_, descent_);
|
|
|
|
width_ += wid;
|
|
|
|
dx0_ = wid;
|
|
|
|
dx1_ = wid;
|
|
|
|
dxx_ = 0;
|
2001-06-27 14:10:35 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigopInset::draw(Painter & pain, int x, int y)
|
2001-07-12 07:18:29 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xo(x);
|
|
|
|
yo(y);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-07-20 14:54:13 +00:00
|
|
|
drawStr(pain, code_, size_, x + dxx_, y, ssym_);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
if (up())
|
|
|
|
xcell(0).draw(pain, x + dx0_, y + dy0_);
|
|
|
|
if (down())
|
|
|
|
xcell(1).draw(pain, x + dx1_, y + dy1_);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
if (sym_ == LM_oint) {
|
|
|
|
int xx = x - 1;
|
|
|
|
int yy = y - (ascent_ - descent_) / 2;
|
|
|
|
pain.arc(xx, yy, width_, width_, 0, 360 * 64, LColor::mathline);
|
2001-06-27 14:10:35 +00:00
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|