]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MathData.C
remove paperHeight() and paperWidth() in Painter and inherited classes.
[lyx.git] / src / mathed / MathData.C
index e644b7dcc3744107f53c921f6d2b4694d751bbca..a8b31f9b6eba3b3e18dfe68bf445fa543000f72b 100644 (file)
 #include "InsetMathScript.h"
 #include "InsetMathMacro.h"
 #include "MathMacroTable.h"
-#include "MathMLStream.h"
+#include "MathStream.h"
 #include "MathSupport.h"
 #include "MathReplace.h"
 
-#include "coordcache.h"
-#include "LColor.h"
+#include "BufferView.h"
 #include "buffer.h"
 #include "cursor.h"
 #include "debug.h"
+#include "LColor.h"
 
 #include "frontends/Painter.h"
 
 #include <boost/assert.hpp>
 
+
+namespace lyx {
+
 using std::abs;
 using std::endl;
 using std::min;
@@ -37,10 +40,6 @@ using std::string;
 using std::vector;
 
 
-MathArray::MathArray()
-{}
-
-
 MathArray::MathArray(const_iterator from, const_iterator to)
        : base_type(from, to)
 {}
@@ -106,17 +105,21 @@ void MathArray::erase(size_type pos1, size_type pos2)
 
 void MathArray::dump2() const
 {
-       NormalStream ns(lyxerr);
+       odocstringstream os;
+       NormalStream ns(os);
        for (const_iterator it = begin(); it != end(); ++it)
                ns << *it << ' ';
+       lyxerr << to_utf8(os.str());
 }
 
 
 void MathArray::dump() const
 {
-       NormalStream ns(lyxerr);
+       odocstringstream os;
+       NormalStream ns(os);
        for (const_iterator it = begin(); it != end(); ++it)
                ns << '<' << *it << '>';
+       lyxerr << to_utf8(os.str());
 }
 
 
@@ -218,7 +221,7 @@ void MathArray::metrics(MetricsInfo & mi, Dimension & dim) const
 namespace {
 
 bool isInside(DocIterator const & it, MathArray const & ar,
-       lyx::pos_type p1, lyx::pos_type p2)
+       pos_type p1, pos_type p2)
 {
        for (size_t i = 0; i != it.depth(); ++i) {
                CursorSlice const & sl = it[i];
@@ -275,7 +278,8 @@ void MathArray::metrics(MetricsInfo & mi) const
 void MathArray::draw(PainterInfo & pi, int x, int y) const
 {
        //lyxerr << "MathArray::draw: x: " << x << " y: " << y << endl;
-       setXY(x, y);
+       BufferView & bv  = *pi.base.bv;
+       setXY(bv, x, y);
 
        if (empty()) {
                pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
@@ -284,16 +288,15 @@ void MathArray::draw(PainterInfo & pi, int x, int y) const
 
        // don't draw outside the workarea
        if (y + descent() <= 0
-               || y - ascent() >= pi.pain.paperHeight()
+               || y - ascent() >= bv.workHeight()
                || x + width() <= 0
-               || x >= pi.pain.paperWidth())
+               || x >= bv. workWidth())
                return;
 
-       //BufferView & bv  = *pi.base.bv;
        for (size_t i = 0, n = size(); i != n; ++i) {
                MathAtom const & at = operator[](i);
 #if 0
-       Buffer const & buf = *bv.buffer();
+       Buffer const & buf = bv.buffer();
                // special macro handling
                MathMacro const * mac = at->asMacro();
                if (mac && buf.hasMacro(mac->name())) {
@@ -309,7 +312,7 @@ void MathArray::draw(PainterInfo & pi, int x, int y) const
                        }
                }
 #endif
-               theCoords.insets().add(at.nucleus(), x, y);
+               bv.coordCache().insets().add(at.nucleus(), x, y);
                at->drawSelection(pi, x, y);
                at->draw(pi, x, y);
                x += at->width();
@@ -331,7 +334,9 @@ void MathArray::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
 void MathArray::drawT(TextPainter & pain, int x, int y) const
 {
        //lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
-       setXY(x, y);
+
+       // FIXME: Abdel 16/10/2006
+       // This drawT() method is never used, this is dead code.
 
        for (const_iterator it = begin(), et = end(); it != et; ++it) {
                (*it)->drawT(pain, x, y);
@@ -402,13 +407,13 @@ MathArray::size_type MathArray::x2pos(int targetx, int glue) const
 }
 
 
-int MathArray::dist(int x, int y) const
+int MathArray::dist(BufferView & bv, int x, int y) const
 {
        int xx = 0;
        int yy = 0;
 
-       const int xo_ = xo();
-       const int yo_ = yo();
+       const int xo_ = xo(bv);
+       const int yo_ = yo(bv);
 
        if (x < xo_)
                xx = xo_ - x;
@@ -424,20 +429,40 @@ int MathArray::dist(int x, int y) const
 }
 
 
-void MathArray::setXY(int x, int y) const
+void MathArray::setXY(BufferView & bv, int x, int y) const
 {
        //lyxerr << "setting position cache for MathArray " << this << std::endl;
-       theCoords.arrays().add(this, x, y);
+       bv.coordCache().arrays().add(this, x, y);
+}
+
+
+int MathArray::xo(BufferView & bv) const
+{
+       return bv.coordCache().getArrays().x(this);
 }
 
 
-int MathArray::xo() const
+int MathArray::yo(BufferView & bv) const
 {
-       return theCoords.getArrays().x(this);
+       return bv.coordCache().getArrays().y(this);
 }
 
 
-int MathArray::yo() const
+std::ostream & operator<<(std::ostream & os, MathArray const & ar)
 {
-       return theCoords.getArrays().y(this);
+       odocstringstream oss;
+       NormalStream ns(oss);
+       ns << ar;
+       return os << to_utf8(oss.str());
 }
+
+
+odocstream & operator<<(odocstream & os, MathArray const & ar)
+{
+       NormalStream ns(os);
+       ns << ar;
+       return os;
+}
+
+
+} // namespace lyx