#include "math_support.h"
#include "math_replace.h"
+#include "coordcache.h"
#include "LColor.h"
#include "BufferView.h"
#include "buffer.h"
MathArray::MathArray()
- : xo_(0), yo_(0), clean_(false), drawn_(false)
{}
MathArray::MathArray(const_iterator from, const_iterator to)
- : base_type(from, to), xo_(0), yo_(0), clean_(false), drawn_(false)
+ : base_type(from, to)
{}
void MathArray::touch() const
{
- clean_ = false;
- drawn_ = false;
}
void MathArray::metrics(MetricsInfo & mi) const
{
- //if (clean_)
- // return;
- clean_ = true;
- drawn_ = false;
-
mathed_char_dim(mi.base.font, 'I', dim_);
if (empty())
void MathArray::draw(PainterInfo & pi, int x, int y) const
{
- //if (drawn_ && x == xo_ && y == yo_)
- // return;
//lyxerr << "MathArray::draw: x: " << x << " y: " << y << endl;
-
- xo_ = x;
- yo_ = y;
- drawn_ = true;
+ setXY(x, y);
if (empty()) {
pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
void MathArray::metricsT(TextMetricsInfo const & mi, Dimension & dim) const
{
- //if (clean_)
- // return;
dim.clear();
Dimension d;
for (const_iterator it = begin(); it != end(); ++it) {
void MathArray::drawT(TextPainter & pain, int x, int y) const
{
- //if (drawn_ && x == xo_ && y == yo_)
- // return;
//lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
- xo_ = x;
- yo_ = y;
- drawn_ = true;
+ setXY(x, y);
for (const_iterator it = begin(), et = end(); it != et; ++it) {
(*it)->drawT(pain, x, y);
- //x += (*it->width_;
+ //x += (*it)->width_;
x += 2;
}
}
int xx = 0;
int yy = 0;
+ const int xo_ = xo();
+ const int yo_ = yo();
+
if (x < xo_)
xx = xo_ - x;
else if (x > xo_ + width())
}
-bool MathArray::contains(int x, int y) const
+void MathArray::setXY(int x, int y) const
{
- return xo_ <= x && x <= xo_ + width()
- && yo_ - ascent() <= y && y <= yo_ + descent();
+ //lyxerr << "setting position cache for MathArray " << this << std::endl;
+ theCoords.arrays_.add(this, x, y);
}
-void MathArray::center(int & x, int & y) const
+int MathArray::xo() const
{
- x = xo_ + width() / 2;
- y = yo_ + (descent() - ascent()) / 2;
+ return theCoords.arrays_.x(this);
}
-void MathArray::towards(int & x, int & y) const
+int MathArray::yo() const
{
- int cx = 0;
- int cy = 0;
- center(cx, cy);
-
- double r = 1.0;
- //int dist = (x - cx) * (x - cx) + (y - cy) * (y - cy);
-
- x = cx + int(r * (x - cx));
- y = cy + int(r * (y - cy));
+ return theCoords.arrays_.y(this);
}
-
-void MathArray::setXY(int x, int y) const
-{
- xo_ = x;
- yo_ = y;
-}