2001-02-13 13:28:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "math_bigopinset.h"
|
|
|
|
#include "LColor.h"
|
|
|
|
#include "Painter.h"
|
|
|
|
#include "mathed/support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
|
|
|
|
|
|
|
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)
|
|
|
|
: MathInset(name, LM_OT_BIGOP), lims_(-1), sym_(id)
|
2001-02-28 11:56:36 +00:00
|
|
|
{}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +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-06-25 00:06:33 +00:00
|
|
|
void MathBigopInset::Write(ostream & os, bool fragile) const
|
2001-02-28 11:56:36 +00:00
|
|
|
{
|
|
|
|
bool const limp = GetLimits();
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
os << '\\' << name();
|
|
|
|
|
|
|
|
bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
|
2001-02-28 11:56:36 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
if (limp && !f)
|
2001-02-28 11:56:36 +00:00
|
|
|
os << "\\limits ";
|
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
if (!limp && f)
|
2001-02-28 11:56:36 +00:00
|
|
|
os << "\\nolimits ";
|
|
|
|
else
|
|
|
|
os << ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathBigopInset::WriteNormal(ostream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
{
|
|
|
|
bool const limp = GetLimits();
|
2001-06-25 00:06:33 +00:00
|
|
|
bool f = sym_ != LM_int && sym_ != LM_oint;
|
2001-04-25 15:43:57 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
os << "[bigop " << name();
|
2001-04-25 15:43:57 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
if (limp && !f)
|
2001-04-25 15:43:57 +00:00
|
|
|
os << " limits";
|
|
|
|
else
|
2001-06-25 00:06:33 +00:00
|
|
|
if (!limp && f)
|
2001-04-25 15:43:57 +00:00
|
|
|
os << " nolimits";
|
|
|
|
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathBigopInset::Metrics(MathStyles st)
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
size(st);
|
2001-02-13 13:28:32 +00:00
|
|
|
string s;
|
|
|
|
short t;
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
if (sym_ < 256 || sym_ == LM_oint) {
|
2001-06-25 00:06:33 +00:00
|
|
|
char const c = (sym_ == LM_oint) ? LM_int : sym_;
|
2001-02-13 13:28:32 +00:00
|
|
|
s += c;
|
|
|
|
t = LM_TC_BSYM;
|
|
|
|
} else {
|
2001-06-25 00:06:33 +00:00
|
|
|
s = name();
|
2001-02-13 13:28:32 +00:00
|
|
|
t = LM_TC_TEXTRM;
|
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
mathed_string_dim(t, size(), s, ascent_, descent_, width_);
|
|
|
|
if (sym_ == LM_oint)
|
|
|
|
width_ += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigopInset::draw(Painter & pain, int x, int y)
|
|
|
|
{
|
|
|
|
xo(x);
|
|
|
|
yo(y);
|
|
|
|
string s;
|
|
|
|
short t;
|
|
|
|
|
|
|
|
if (sym_ < 256 || sym_ == LM_oint) {
|
|
|
|
s += (sym_ == LM_oint) ? LM_int : sym_;
|
|
|
|
t = LM_TC_BSYM;
|
|
|
|
} else {
|
|
|
|
s = name();
|
|
|
|
t = LM_TC_TEXTRM;
|
|
|
|
}
|
|
|
|
if (sym_ == LM_oint) {
|
|
|
|
pain.arc(x, y - 5 * width_ / 4, width_, width_, 0, 360 * 64,
|
|
|
|
LColor::mathline);
|
|
|
|
++x;
|
|
|
|
}
|
|
|
|
pain.text(x, y, s, mathed_get_font(t, size()));
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
bool MathBigopInset::GetLimits() const
|
|
|
|
{
|
|
|
|
// Default case
|
2001-06-25 00:06:33 +00:00
|
|
|
if (lims_ < 0)
|
|
|
|
return sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
// Custom
|
|
|
|
return lims_ > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigopInset::SetLimits(bool ls)
|
|
|
|
{
|
|
|
|
lims_ = ls ? 1 : 0;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|