#include "math_textinset.h"
-#include "math_metricsinfo.h"
+#include "metricsinfo.h"
#include "debug.h"
}
-void MathTextInset::getPos(idx_type, pos_type pos, int & x, int & y) const
+void MathTextInset::getPos(idx_type /*idx*/, pos_type pos, int & x, int & y) const
{
idx_type const i = pos2row(pos);
pos_type const p = pos - cache_.cellinfo_[i].begin_;
cache_.getPos(i, p, x, y);
+ y = cache_.cell(i).yo();
}
-bool MathTextInset::idxUpDown(idx_type &, pos_type & pos, bool up,
+bool MathTextInset::idxUpDown2(idx_type &, pos_type & pos, bool up,
int /*targetx*/) const
{
// try to move only one screen row up or down if possible
idx_type i = pos2row(pos);
+ //lyxerr << "\nMathTextInset::idxUpDown() i: " << i << endl;
MathGridInset::CellInfo const & cell1 = cache_.cellinfo_[i];
- int const x = cells_[0].pos2x(cell1.begin_, pos, cell1.glue_);
+ int const x = cache_.cell(i).pos2x(pos - cell1.begin_, cell1.glue_);
if (up) {
if (i == 0)
return false;
return false;
}
MathGridInset::CellInfo const & cell2 = cache_.cellinfo_[i];
- pos = cell(0).x2pos(cell2.begin_, x, cell2.glue_);
+ pos = cell2.begin_ + cache_.cell(i).x2pos(x, cell2.glue_);
return true;
}
-void MathTextInset::metrics(MathMetricsInfo & mi) const
+void MathTextInset::metrics(MetricsInfo & mi) const
{
cell(0).metrics(mi);
// we do our own metrics fiddling
+ // save old positional information
+ int const old_xo = cache_.cell(0).xo();
+ int const old_yo = cache_.cell(0).yo();
+
// delete old cache
cache_ = MathGridInset(1, 0);
cache_.metrics(mi);
dim_ = cache_.dimensions();
//lyxerr << "outer dim: " << dim_ << endl;
+
+ // reset position cache
+ for (idx_type i = 0; i < cache_.nargs(); ++i)
+ cache_.cell(i).setXY(old_xo, old_yo);
+
}
-void MathTextInset::draw(MathPainterInfo & pi, int x, int y) const
+void MathTextInset::draw(PainterInfo & pi, int x, int y) const
{
cache_.draw(pi, x + 1, y);
}
-void MathTextInset::drawSelection(MathPainterInfo & pi,
+void MathTextInset::drawSelection(PainterInfo & pi,
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const
{
cache_.drawSelection(pi, idx1, pos1, idx2, pos2);