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
|
|
|
|
|
|
|
MathBigopInset::MathBigopInset(string const & nam, int id, short st)
|
2001-02-28 11:56:36 +00:00
|
|
|
: MathedInset(nam, LM_OT_BIGOP, st), lims_(-1), sym_(id)
|
|
|
|
{}
|
2001-02-13 13:28:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathBigopInset::Clone()
|
|
|
|
{
|
2001-02-28 11:56:36 +00:00
|
|
|
return new MathBigopInset(name, sym_, GetStyle());
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-27 12:35:55 +00:00
|
|
|
void MathBigopInset::draw(Painter & pain, int x, int y)
|
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) {
|
|
|
|
s += (sym_ == LM_oint) ? LM_int : sym_;
|
2001-02-13 13:28:32 +00:00
|
|
|
t = LM_TC_BSYM;
|
|
|
|
} else {
|
|
|
|
s = name;
|
|
|
|
t = LM_TC_TEXTRM;
|
|
|
|
}
|
2001-02-28 11:56:36 +00:00
|
|
|
if (sym_ == LM_oint) {
|
|
|
|
pain.arc(x, y - 5 * width / 4, width, width, 0, 360 * 64,
|
2001-02-13 13:28:32 +00:00
|
|
|
LColor::mathline);
|
|
|
|
++x;
|
|
|
|
}
|
2001-02-15 12:22:01 +00:00
|
|
|
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
|
|
|
void MathBigopInset::Write(ostream & os, bool /* fragile */)
|
|
|
|
{
|
|
|
|
bool const limp = GetLimits();
|
|
|
|
|
|
|
|
os << '\\' << name;
|
|
|
|
|
|
|
|
if (limp && !(sym_ != LM_int && sym_ != LM_oint
|
|
|
|
&& (GetStyle() == LM_ST_DISPLAY)))
|
|
|
|
os << "\\limits ";
|
|
|
|
else
|
|
|
|
if (!limp && (sym_ != LM_int && sym_ != LM_oint
|
|
|
|
&& (GetStyle() == LM_ST_DISPLAY)))
|
|
|
|
os << "\\nolimits ";
|
|
|
|
else
|
|
|
|
os << ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
void MathBigopInset::WriteNormal(ostream & os)
|
|
|
|
{
|
|
|
|
bool const limp = GetLimits();
|
|
|
|
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "[bigop " << name;
|
2001-04-25 15:43:57 +00:00
|
|
|
|
|
|
|
if (limp && !(sym_ != LM_int && sym_ != LM_oint
|
|
|
|
&& (GetStyle() == LM_ST_DISPLAY)))
|
|
|
|
os << " limits";
|
|
|
|
else
|
|
|
|
if (!limp && (sym_ != LM_int && sym_ != LM_oint
|
|
|
|
&& (GetStyle() == LM_ST_DISPLAY)))
|
|
|
|
os << " nolimits";
|
|
|
|
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MathBigopInset::Metrics()
|
2001-02-13 13:28:32 +00:00
|
|
|
{
|
|
|
|
//char c;
|
|
|
|
string s;
|
|
|
|
short t;
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
if (sym_ < 256 || sym_ == LM_oint) {
|
|
|
|
char const c = (sym_ == LM_oint) ? LM_int: sym_;
|
2001-02-13 13:28:32 +00:00
|
|
|
s += c;
|
|
|
|
t = LM_TC_BSYM;
|
|
|
|
} else {
|
|
|
|
s = name;
|
|
|
|
t = LM_TC_TEXTRM;
|
|
|
|
}
|
2001-02-15 12:22:01 +00:00
|
|
|
mathed_string_height(t, size(), s, ascent, descent);
|
|
|
|
width = mathed_string_width(t, size(), s);
|
2001-02-28 11:56:36 +00:00
|
|
|
if (sym_ == LM_oint) width += 2;
|
2001-02-13 13:28:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
bool MathBigopInset::GetLimits() const
|
|
|
|
{
|
|
|
|
// Default case
|
|
|
|
if (lims_ < 0) {
|
|
|
|
return sym_ != LM_int &&
|
|
|
|
sym_ != LM_oint &&
|
|
|
|
GetStyle() == 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
|
|
|
}
|