-void MathAtom::metrics(MathStyles st) const
-{
- MathStyles tt = smallerStyleScript(st);
- if (nucleus())
- nucleus()->metrics(st);
- if (up())
- up()->metrics(tt);
- if (down())
- down()->metrics(tt);
-}
-
-
-MathScriptInset * MathAtom::up() const
-{
- return script_[1];
-}
-
-
-MathScriptInset * MathAtom::down() const
-{
- return script_[0];
-}
-
-
-MathScriptInset * & MathAtom::up()
-{
- return script_[1];
-}
-
-
-MathScriptInset * & MathAtom::down()
-{
- return script_[0];
-}
-
-
-int MathAtom::dy0() const
-{
- if (!down())
- return ndes();
- int des = down()->ascent();
- if (hasLimits())
- des += ndes() + 2;
- else
- des = std::max(des, ndes());
- return des;
-}
-
-
-int MathAtom::dy1() const
-{
- if (!up())
- return nasc();
- int asc = up()->descent();
- if (hasLimits())
- asc += nasc() + 2;
- else
- asc = std::max(asc, nasc());
- asc = std::max(asc, mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I'));
- return asc;
-}
-
-
-int MathAtom::dx0() const
-{
- lyx::Assert(down());
- return hasLimits() ? (width() - down()->width()) / 2 : nwid();
-}
-
-
-int MathAtom::dx1() const
-{
- lyx::Assert(up());
- return hasLimits() ? (width() - up()->width()) / 2 : nwid();
-}
-
-
-int MathAtom::dxx() const
-{
- //lyx::Assert(nucleus());
- return hasLimits() ? (width() - nwid()) / 2 : 0;
-}
-
-
-int MathAtom::ascent() const
-{
- return dy1() + (up() ? up()->ascent() : 0);
-}
-
-
-int MathAtom::descent() const
-{
- return dy0() + (down() ? down()->descent() : 0);
-}
-
-
-int MathAtom::width() const
-{
- int wid = 0;
- if (hasLimits()) {
- wid = nwid();
- if (up())
- wid = std::max(wid, up()->width());
- if (down())
- wid = std::max(wid, down()->width());
- } else {
- if (up())
- wid = std::max(wid, up()->width());
- if (down())
- wid = std::max(wid, down()->width());
- wid += nwid();
- }
- return wid;
-}
-
-
-int MathAtom::nwid() const
-{
- return nucleus() ?
- nucleus()->width() :
- mathed_char_width(LM_TC_TEX, LM_ST_TEXT, '.');
-}
-
-
-int MathAtom::nasc() const
-{
- return nucleus() ? nucleus()->ascent()
- : mathed_char_ascent(LM_TC_VAR, LM_ST_TEXT, 'I');
-}
-
-
-int MathAtom::ndes() const
-{
- return nucleus() ? nucleus()->descent()
- : mathed_char_descent(LM_TC_VAR, LM_ST_TEXT, 'I');
-}
-
-
-void MathAtom::draw(Painter & pain, int x, int y) const
-{
- xo(x);
- yo(y);
- if (nucleus())
- nucleus()->draw(pain, x + dxx(), y);
- else
- drawStr(pain, LM_TC_TEX, LM_ST_TEXT, x + dxx(), y, ".");
- if (up())
- up()->draw(pain, x + dx1(), y - dy1());
- if (down())
- down()->draw(pain, x + dx0(), y + dy0());
-}
-
-
-void MathAtom::write(std::ostream & os, bool fragile) const
-{
- if (nucleus()) {
- nucleus()->write(os, fragile);
- if (nucleus()->takesLimits()) {
- if (limits_ == -1)
- os << "\\nolimits ";
- if (limits_ == 1)
- os << "\\limits ";
- }
- } else
- os << "{}";
-
- if (down()) {
- os << "_{";
- down()->write(os, fragile);
- os << "}";
- }
-
- if (up()) {
- os << "^{";
- up()->write(os, fragile);
- os << "}";
- }
-}
-
-
-bool MathAtom::hasLimits() const
-{
- return
- limits_ == 1 || (limits_ == 0 && nucleus() && nucleus()->isScriptable());
-}
-
-
-bool MathAtom::hasInner() const
-{
- return nucleus_ && (script_[0] || script_[1]);
-}