]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_xdata.C
enable direct input of #1...#9; some whitespace changes
[lyx.git] / src / mathed / math_xdata.C
index cffec88712d762a48e5ac119cf2a6443e7b90bd0..998c3e013052aa97ae2dad5aab42e862680d0860 100644 (file)
@@ -18,15 +18,15 @@ MathXArray::MathXArray()
 {}
 
 
-void MathXArray::metrics(MathMetricsInfo const & st) const
+void MathXArray::metrics(MathMetricsInfo const & mi) const
 {
-       size_ = st;
-       mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_);
+       size_ = mi;
+       mathed_char_dim(LM_TC_VAR, mi, 'I', ascent_, descent_, width_);
 
        if (data_.empty()) 
                return;
 
-       math_font_max_dim(LM_TC_TEXTRM, st, ascent_, descent_); 
+       math_font_max_dim(LM_TC_TEXTRM, mi, ascent_, descent_); 
        width_ = 0;
 
        //lyxerr << "MathXArray::metrics(): '" << data_ << "'\n";
@@ -35,13 +35,13 @@ void MathXArray::metrics(MathMetricsInfo const & st) const
                MathInset const * p = it->nucleus();
                MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
                if (q) {
-                       q->metrics(p, st);
-                       ascent_  = std::max(ascent_,  q->ascent(p));
-                       descent_ = std::max(descent_, q->descent(p));
-                       width_  += q->width(p); 
+                       q->metrics(p, mi);
+                       ascent_  = std::max(ascent_,  q->ascent2(p));
+                       descent_ = std::max(descent_, q->descent2(p));
+                       width_  += q->width2(p);        
                        ++it;
                } else {
-                       p->metrics(st);
+                       p->metrics(mi);
                        ascent_  = std::max(ascent_,  p->ascent());
                        descent_ = std::max(descent_, p->descent());
                        width_  += p->width();  
@@ -67,7 +67,7 @@ void MathXArray::draw(Painter & pain, int x, int y) const
                MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
                if (q) {
                        q->draw(p, pain, x, y);
-                       x += q->width(p);
+                       x += q->width2(p);
                        ++it;
                } else {
                        p->draw(pain, x, y);
@@ -87,7 +87,7 @@ int MathXArray::pos2x(size_type targetpos) const
                if (q) {
                        ++it;
                        if (it < target)
-                               x += q->width(p);
+                               x += q->width2(p);
                        else  // "half" position
                                x += q->dxx(p) + q->nwid(p);
                } else
@@ -111,7 +111,7 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
                if (it + 1 != end())
                        q = asScript(it);
                if (q) {
-                       wid = q->width(p);
+                       wid = q->width2(p);
                        ++it;
                } else
                        wid = p->width();
@@ -122,3 +122,58 @@ MathArray::size_type MathXArray::x2pos(int targetx) const
                --it;
        return it - begin();
 }
+
+
+int MathXArray::dist(int x, int y) const
+{
+       int xx = 0;
+       int yy = 0;
+
+       if (x < xo_)
+               xx = xo_ - x;
+       else if (x > xo_ + width_)
+               xx = x - xo_ - width_;
+
+       if (y < yo_ - ascent_)
+               yy = yo_ - ascent_ - y;
+       else if (y > yo_ + descent_)
+               yy = y - yo_ - descent_;
+
+       return xx + yy; 
+}
+
+
+void MathXArray::boundingBox(int & x1, int & x2, int & y1, int & y2)
+{
+       x1 = xo_;
+       x2 = xo_ + width_;
+       y1 = yo_ - ascent_;
+       y2 = yo_ + descent_;
+}
+
+/*
+void MathXArray::findPos(MathPosFinder & f) const
+{
+       double x = xo_;
+       double y = yo_; 
+       for (const_iterator it = begin(); it < end(); ++it) {
+               // check this position in the cell first
+               f.visit(x, y);
+               f.nextPos();
+
+               // check inset
+               MathInset const * p = it->nucleus();
+               p->findPos(f);
+
+               // move on
+               MathScriptInset const * q = (it + 1 == end()) ? 0 : asScript(it);
+               if (q) {
+                       x += q->width(p);
+                       f.nextPos();
+                       ++it;
+               } else {
+                       x += p->width();
+               }
+       }
+}
+*/