2001-02-13 13:28:32 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
#include <functional>
|
|
|
|
|
2001-02-13 13:28:32 +00:00
|
|
|
#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)
|
2001-07-06 12:09:32 +00:00
|
|
|
: MathScriptInset(true, false), lims_(0), sym_(id)
|
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-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-06-27 14:10:35 +00:00
|
|
|
if (limits() == 1)
|
2001-02-28 11:56:36 +00:00
|
|
|
os << "\\limits ";
|
2001-06-27 14:10:35 +00:00
|
|
|
else if (limits() == -1)
|
|
|
|
os << "\\nolimits ";
|
2001-02-28 11:56:36 +00:00
|
|
|
else
|
2001-06-27 14:10:35 +00:00
|
|
|
os << ' ';
|
|
|
|
MathScriptInset::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-06-25 00:06:33 +00:00
|
|
|
os << "[bigop " << name();
|
2001-06-27 14:10:35 +00:00
|
|
|
if (limits() == 1)
|
|
|
|
os << "\\limits ";
|
|
|
|
else if (limits() == -1)
|
|
|
|
os << "\\nolimits ";
|
2001-04-25 15:43:57 +00:00
|
|
|
else
|
2001-06-27 14:10:35 +00:00
|
|
|
os << ' ';
|
|
|
|
MathScriptInset::WriteNormal(os);
|
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-27 14:10:35 +00:00
|
|
|
MathScriptInset::Metrics(st);
|
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-27 14:10:35 +00:00
|
|
|
|
|
|
|
int asc, des, wid;
|
|
|
|
mathed_string_dim(t, size(), s, asc, des, wid);
|
2001-06-25 00:06:33 +00:00
|
|
|
if (sym_ == LM_oint)
|
2001-06-27 14:10:35 +00:00
|
|
|
wid += 2;
|
|
|
|
|
|
|
|
if (hasLimits()) {
|
|
|
|
ascent_ = asc + xcell(0).height() + 2;
|
|
|
|
descent_ = des + xcell(1).height() + 2;
|
2001-06-27 15:33:55 +00:00
|
|
|
width_ = std::max(width_, wid);
|
2001-06-27 14:10:35 +00:00
|
|
|
} else {
|
2001-06-27 15:33:55 +00:00
|
|
|
ascent_ = std::max(ascent_, asc);
|
|
|
|
descent_ = std::max(descent_, des);
|
2001-06-27 14:10:35 +00:00
|
|
|
width_ += wid;
|
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathBigopInset::draw(Painter & pain, int x, int y)
|
|
|
|
{
|
|
|
|
xo(x);
|
|
|
|
yo(y);
|
2001-06-27 14:10:35 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
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;
|
|
|
|
}
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
int asc, des, wid;
|
|
|
|
mathed_string_dim(t, size(), s, asc, des, wid);
|
|
|
|
|
|
|
|
if (hasLimits()) {
|
|
|
|
int w = width();
|
|
|
|
pain.text(x + (w - wid)/2, y, s, mathed_get_font(t, size()));
|
|
|
|
xcell(0).draw
|
|
|
|
(pain, x + (w - xcell(0).width())/2, y - asc - xcell(0).descent() - 1);
|
|
|
|
xcell(1).draw
|
|
|
|
(pain, x + (w - xcell(1).width())/2, y + des + xcell(1).ascent() + 1);
|
|
|
|
} else {
|
|
|
|
pain.text(x, y, s, mathed_get_font(t, size()));
|
|
|
|
MathScriptInset::draw(pain, x + wid, y);
|
|
|
|
}
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
int MathBigopInset::limits() const
|
|
|
|
{
|
|
|
|
return lims_;
|
2001-02-28 11:56:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
void MathBigopInset::limits(int limit)
|
2001-02-28 11:56:36 +00:00
|
|
|
{
|
2001-06-27 14:10:35 +00:00
|
|
|
lims_ = limit;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MathBigopInset::hasLimits() const
|
|
|
|
{
|
|
|
|
return limits() == 1 || (limits() == 0 && size() == LM_ST_DISPLAY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathBigopInset::idxDelete(int idx)
|
|
|
|
{
|
|
|
|
// ignore the return value, we do not want the inset to be deleted
|
|
|
|
MathScriptInset::idxDelete(idx);
|
|
|
|
return false;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|