]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_xyarrowinset.C
fix typo that put too many include paths for most people
[lyx.git] / src / mathed / math_xyarrowinset.C
index 73f14eac5f6816c1ca3dd81220ad08021dfb608f..5f3489f3e3631cca333df6a07ce361334277baa3 100644 (file)
@@ -13,6 +13,9 @@
 #include "debug.h"
 
 
+using std::max;
+
+
 MathXYArrowInset::MathXYArrowInset()
        : MathNestInset(2)
 {}
@@ -26,7 +29,7 @@ MathInset * MathXYArrowInset::clone() const
 
 MathXYMatrixInset const * MathXYArrowInset::targetMatrix() const
 {
-       return mi_.inset ? mi_.inset->asXYMatrixInset() : 0;
+       return target_;
 }
 
 
@@ -45,8 +48,8 @@ MathXArray const & MathXYArrowInset::targetCell() const
                }
        }
        //lyxerr << "target: x: " << x << " y: " << y << "\n";
-       int n = mi_.idx + p->ncols() * y + x;
-       if (n < 0 || n >= int(p->nargs())) {
+       MathInset::idx_type n = mi_.idx + p->ncols() * y + x;
+       if (n >= p->nargs()) {
                lyxerr << "source: n: " << mi_.idx << "\n";
                lyxerr << "target: n: " << n << " out of range\n";
                n = 0;
@@ -63,19 +66,21 @@ MathXArray const & MathXYArrowInset::sourceCell() const
 
 void MathXYArrowInset::metrics(MathMetricsInfo const & mi) const
 {
-       mi_ = mi;
        MathNestInset::metrics(mi);
+       mi_ = mi;
+       whichFont(font_, LM_TC_TEXTRM, mi);
+       target_ = mi.inset ? mi.inset->asXYMatrixInset() : 0;
 
        if (editing()) {
-               int w    = mathed_string_width(LM_TC_TEXTRM, mi_, "target: ");
-               width_   = w + std::max(xcell(0).width(), xcell(1).width());
+               int w    = mathed_string_width(font_, "target: ");
+               width_   = w + max(xcell(0).width(), xcell(1).width());
                ascent_  = xcell(0).ascent();
                descent_ = xcell(0).descent() + xcell(1).height() + 10;
        } else {
                width_   = 0;
                ascent_  = 0;
                descent_ = 0;
-               //mathed_string_dim(LM_TC_TEXTRM, mi_, "X", ascent_, descent_, width_);
+               //mathed_string_dim(font_, "X", ascent_, descent_, width_);
        }
 }
 
@@ -89,24 +94,24 @@ void MathXYArrowInset::draw(Painter & pain, int x, int y) const
                int lasc;
                int ldes;
                int lwid;
-               mathed_string_dim(LM_TC_TEXTRM, mi_, "target: ", lasc, ldes, lwid);
+               mathed_string_dim(font_, "target: ", lasc, ldes, lwid);
 
                xcell(0).draw(pain, x + lwid, y);
-               drawStr(pain, LM_TC_TEXTRM, mi_, x + 3, y, "target");
-               y += std::max(xcell(0).descent(), ldes) + 5;
+               drawStr(pain, font_, x + 3, y, "target");
+               y += max(xcell(0).descent(), ldes) + 5;
 
-               y += std::max(xcell(1).ascent(), lasc) + 5;
+               y += max(xcell(1).ascent(), lasc) + 5;
                xcell(1).draw(pain, x + lwid, y);
-               drawStr(pain, LM_TC_TEXTRM, mi_, x + 3, y, "label");
+               drawStr(pain, font_, x + 3, y, "label");
 
        } else {
 
-               //drawStr(pain, LM_TC_TEXTRM, mi_, x, y, "X");
+               //drawStr(pain, font_, x, y, "X");
                MathXArray const & s = sourceCell();
                MathXArray const & t = targetCell();
                pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);
                xcell(1).draw(pain, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
-               
+
        }
 }