-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];
-}
-
-
-int MathAtom::dy0() const
-{
- lyx::Assert(down());
- int des = down()->ascent();
- if (hasLimits())
- des += ndes() + 2;
- else
- des = std::max(des, ndes());
- return des;
-}
-
-
-int MathAtom::dy1() const
-{
- lyx::Assert(up());
- 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
-{
- int asc = nasc();
- if (up())
- asc += hasLimits() ? up()->height() + 2 : up()->ascent();
- return asc;
-}
-
-
-int MathAtom::descent() const
-{
- int des = ndes();
- if (down())
- des += hasLimits() ? down()->height() + 2 : down()->descent();
- return des;
-}
-
-
-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() : 0;
-}
-
-
-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);
- if (up())
- up()->draw(pain, x + dx1(), y - dy1());
- if (down())
- down()->draw(pain, x + dx0(), y + dy0());
-}