#endif
#include "math_scriptinset.h"
-#include "debug.h"
#include "math_support.h"
+#include "math_symbolinset.h"
#include "math_mathmlstream.h"
#include "support/LAssert.h"
+#include "debug.h"
MathScriptInset::MathScriptInset()
int MathScriptInset::dx0(MathInset const * nuc) const
{
lyx::Assert(hasDown());
- return hasLimits(nuc) ? (width(nuc) - down().width()) / 2 : nwid(nuc);
+ return hasLimits(nuc) ? (width2(nuc) - down().width()) / 2 : nwid(nuc);
}
int MathScriptInset::dx1(MathInset const * nuc) const
{
lyx::Assert(hasUp());
- return hasLimits(nuc) ? (width(nuc) - up().width()) / 2 : nwid(nuc);
+ return hasLimits(nuc) ? (width2(nuc) - up().width()) / 2 : nwid(nuc);
}
int MathScriptInset::dxx(MathInset const * nuc) const
{
//lyx::Assert(nuc());
- return hasLimits(nuc) ? (width(nuc) - nwid(nuc)) / 2 : 0;
+ return hasLimits(nuc) ? (width2(nuc) - nwid(nuc)) / 2 : 0;
}
-int MathScriptInset::ascent(MathInset const * nuc) const
+int MathScriptInset::ascent2(MathInset const * nuc) const
{
return dy1(nuc) + (hasUp() ? up().ascent() : 0);
}
-int MathScriptInset::descent(MathInset const * nuc) const
+int MathScriptInset::descent2(MathInset const * nuc) const
{
return dy0(nuc) + (hasDown() ? down().descent() : 0);
}
-int MathScriptInset::width(MathInset const * nuc) const
+int MathScriptInset::width2(MathInset const * nuc) const
{
int wid = 0;
if (hasLimits(nuc)) {
MathNestInset::metrics(mi);
if (nuc)
nuc->metrics(mi);
-
- ascent_ = ascent(nuc);
- descent_ = descent(nuc);
- width_ = width(nuc);
+ ascent_ = ascent2(nuc);
+ descent_ = descent2(nuc);
+ width_ = width2(nuc);
}
bool MathScriptInset::hasLimits(MathInset const * nuc) const
{
- return limits_ == 1 || (limits_ == 0 && nuc && nuc->isScriptable());
+ // obviuos cases
+ if (limits_ == 1)
+ return true;
+ if (limits_ == -1)
+ return false;
+
+ // we can only display limits if the nucleus wants some
+ if (!nuc)
+ return false;
+ if (!nuc->isScriptable())
+ return false;
+
+ // per default \int has limits beside the \int even in displayed formulas
+ if (nuc->asSymbolInset())
+ if (nuc->asSymbolInset()->name().find("int") != string::npos)
+ return false;
+
+ // assume "real" limits for everything else
+ return true;
}
void MathScriptInset::write(WriteStream & os) const
{
//lyxerr << "unexpected call to MathScriptInset::write()\n";
- write(0, os);
+ write2(0, os);
}
-void MathScriptInset::write(MathInset const * nuc, WriteStream & os) const
+void MathScriptInset::write2(MathInset const * nuc, WriteStream & os) const
{
if (nuc) {
os << nuc;
os << "\\limits ";
}
} else
- if (os.firstitem)
+ if (os.firstitem())
lyxerr << "suppressing {} \n";
else
os << "{}";
void MathScriptInset::normalize(NormalStream & os) const
{
//lyxerr << "unexpected call to MathScriptInset::normalize()\n";
- normalize(0, os);
+ normalize2(0, os);
}
-void MathScriptInset::normalize(MathInset const * nuc, NormalStream & os) const
+void MathScriptInset::normalize2(MathInset const * nuc, NormalStream & os) const
{
bool d = hasDown() && down().data_.size();
bool u = hasUp() && up().data_.size();
}
-void MathScriptInset::maplize(MathInset const * nuc, MapleStream & os) const
+void MathScriptInset::maplize2(MathInset const * nuc, MapleStream & os) const
{
if (nuc)
os << nuc;
}
-void MathScriptInset::mathmlize(MathInset const * nuc, MathMLStream & os) const
+void MathScriptInset::mathmlize2(MathInset const * nuc, MathMLStream & os) const
{
bool d = hasDown() && down().data_.size();
bool u = hasUp() && up().data_.size();
}
-void MathScriptInset::octavize(MathInset const * nuc, OctaveStream & os) const
+void MathScriptInset::octavize2(MathInset const * nuc, OctaveStream & os) const
{
if (nuc)
os << nuc;