namespace Alert = lyx::frontend::Alert;
-
namespace {
unsigned int const saved_positions_num = 20;
theFontMetrics(cursor_.getFont());
int const asc = fm.maxAscent();
int const des = fm.maxDescent();
- Point const p = bv_funcs::getPos(cursor_, cursor_.boundary());
+ Point const p = bv_funcs::getPos(*this, cursor_, cursor_.boundary());
if (p.y_ - asc >= 0 && p.y_ + des < height_)
return false;
}
cur.clearSelection();
break;
case bv_funcs::CUR_INSIDE:
- int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
+ int const y = bv_funcs::getPos(*this, cur, cur.boundary()).y_;
int const newy = min(last, max(y, first));
if (y != newy) {
cur.reset(buffer_->inset());
void BufferView::updateMetrics(bool singlepar)
{
// Remove old position cache
- theCoords.clear();
+ coord_cache_.clear();
LyXText & buftext = buffer_->text();
lyx::pit_type size = int(buftext.paragraphs().size());
// The coordinates of all these paragraphs are correct, cache them
int y = y1;
- CoordCache::InnerParPosCache & parPos = theCoords.parPos()[&buftext];
+ CoordCache::InnerParPosCache & parPos = coord_cache_.parPos()[&buftext];
for (lyx::pit_type pit = pit1; pit <= pit2; ++pit) {
Paragraph const & par = buftext.getPar(pit);
y += par.ascent();
#ifndef BUFFER_VIEW_H
#define BUFFER_VIEW_H
+#include "coordcache.h"
#include "cursor.h"
#include "metricsinfo.h"
///
void updateMetrics(bool singlepar = false);
+ ///
+ CoordCache & coordCache() {
+ return coord_cache_;
+ }
+ ///
+ CoordCache const & coordCache() const {
+ return coord_cache_;
+ }
/// get this view's keyboard map handler
Intl & getIntl() { return *intl_.get(); }
///
///
ViewMetricsInfo metrics_info_;
-
+ CoordCache coord_cache_;
///
Buffer * buffer_;
}
-Point getPos(DocIterator const & dit, bool boundary)
+Point getPos(BufferView & bv, DocIterator const & dit, bool boundary)
{
CursorSlice const & bot = dit.bottom();
CoordCache::ParPosCache::const_iterator cache_it =
- theCoords.getParPos().find(bot.text());
- if (cache_it == theCoords.getParPos().end())
+ bv.coordCache().getParPos().find(bot.text());
+ if (cache_it == bv.coordCache().getParPos().end())
return Point(-1, -1);
CoordCache::InnerParPosCache const & cache = cache_it->second;
// this could be used elsewhere as well?
CurStatus status(BufferView const * bv, DocIterator const & dit)
{
- CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(dit.bottom().text())->second;
+ CoordCache::InnerParPosCache const & cache =
+ bv->coordCache().getParPos().find(dit.bottom().text())->second;
if (cache.find(dit.bottom().pit()) != cache.end())
return CUR_INSIDE;
*/
std::string const freefont2string();
-Point getPos(DocIterator const & dit, bool boundary);
+Point getPos(BufferView & bv, DocIterator const & dit, bool boundary);
enum CurStatus {
CUR_INSIDE,
#include <boost/assert.hpp>
-CoordCache theCoords;
-
// just a helper to be able to set a breakpoint
void lyxbreaker(void const * data, const char * hint, int size)
{
SliceCache slices1_;
};
-extern CoordCache theCoords;
-
#endif
int xo;
int yo;
InsetBase const * inset = &it.inset();
- Point o = theCoords.getInsets().xy(inset);
+ Point o = c.bv().coordCache().getInsets().xy(inset);
inset->cursorPos(it.top(), c.boundary(), xo, yo);
// Convert to absolute
xo += o.x_;
{
BOOST_ASSERT(!cursor.empty());
InsetBase & inset = cursor[0].inset();
+ BufferView & bv = cursor.bv();
- CoordCache::InnerParPosCache const & cache = theCoords.getParPos().find(cursor.bottom().text())->second;
+ CoordCache::InnerParPosCache const & cache =
+ bv.coordCache().getParPos().find(cursor.bottom().text())->second;
// Get an iterator on the first paragraph in the cache
DocIterator it(inset);
it.push_back(CursorSlice(inset));
for ( ; it != et; it.forwardPos(true)) {
// avoid invalid nesting when selecting
if (!cursor.selection() || positionable(it, cursor.anchor_)) {
- Point p = bv_funcs::getPos(it, false);
+ Point p = bv_funcs::getPos(bv, it, false);
int xo = p.x_;
int yo = p.y_;
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
// avoid invalid nesting when selecting
if (bv_funcs::status(&bv, it) == bv_funcs::CUR_INSIDE
&& (!cur.selection() || positionable(it, cur.anchor_))) {
- Point p = bv_funcs::getPos(it, false);
+ Point p = bv_funcs::getPos(bv, it, false);
int xo = p.x_;
int yo = p.y_;
if (xlow <= xo && xo <= xhigh && ylow <= yo && yo <= yhigh) {
void LCursor::getPos(int & x, int & y) const
{
- Point p = bv_funcs::getPos(*this, boundary());
+ Point p = bv_funcs::getPos(bv(), *this, boundary());
x = p.x_;
y = p.y_;
}
#include "inset.h"
+#include "BufferView.h"
#include "debug.h"
#include "gettext.h"
#include "lyxtext.h"
}
-void InsetOld::setPosCache(PainterInfo const &, int x, int y) const
+void InsetOld::setPosCache(PainterInfo const & pi, int x, int y) const
{
//lyxerr << "InsetOld:: position cache to " << x << " " << y << std::endl;
- theCoords.insets().add(this, x, y);
+ pi.base.bv->coordCache().insets().add(this, x, y);
}
}
-int InsetBase::xo() const
+int InsetBase::xo(BufferView & bv) const
{
- return theCoords.getInsets().x(this);
+ return bv.coordCache().getInsets().x(this);
}
-int InsetBase::yo() const
+int InsetBase::yo(BufferView & bv) const
{
- return theCoords.getInsets().y(this);
+ return bv.coordCache().getInsets().y(this);
}
-bool InsetBase::covers(int x, int y) const
+bool InsetBase::covers(BufferView & bv, int x, int y) const
{
//lyxerr << "InsetBase::covers, x: " << x << " y: " << y
- // << " xo: " << xo() << " yo: " << yo()
- // << " x1: " << xo() << " x2: " << xo() + width()
- // << " y1: " << yo() - ascent() << " y2: " << yo() + descent()
+ // << " xo: " << xo(bv) << " yo: " << yo()
+ // << " x1: " << xo(bv) << " x2: " << xo() + width()
+ // << " y1: " << yo(bv) - ascent() << " y2: " << yo() + descent()
// << std::endl;
- return theCoords.getInsets().has(this)
- && x >= xo()
- && x <= xo() + width()
- && y >= yo() - ascent()
- && y <= yo() + descent();
+ return bv.coordCache().getInsets().has(this)
+ && x >= xo(bv)
+ && x <= xo(bv) + width()
+ && y >= yo(bv) - ascent()
+ && y <= yo(bv) + descent();
}
/// add space for markers
void metricsMarkers2(Dimension & dim, int framesize = 1) const;
/// last drawn position for 'important' insets
- int xo() const;
+ int xo(BufferView & bv) const;
/// last drawn position for 'important' insets
- int yo() const;
+ int yo(BufferView & bv) const;
/// set x/y drawing position cache if available
virtual void setPosCache(PainterInfo const &, int, int) const {}
/// do we cover screen position x/y?
- virtual bool covers(int x, int y) const;
+ virtual bool covers(BufferView & bv, int x, int y) const;
/// get the screen positions of the cursor (see note in cursor.C)
virtual void cursorPos(CursorSlice const & sl, bool boundary,
int & x, int & y) const;
}
-int InsetTabular::dist(idx_type const cell, int x, int y) const
+int InsetTabular::dist(BufferView & bv, idx_type const cell, int x, int y) const
{
int xx = 0;
int yy = 0;
InsetBase const & inset = *tabular.getCellInset(cell);
- Point o = theCoords.getInsets().xy(&inset);
+ Point o = bv.coordCache().getInsets().xy(&inset);
int const xbeg = o.x_ - tabular.getBeginningOfTextInCell(cell);
int const xend = xbeg + tabular.getWidthOfColumn(cell);
row_type const row = tabular.row_of_cell(cell);
//lyxerr << "InsetTabular::editXY: " << this << endl;
cur.selection() = false;
cur.push(*this);
- cur.idx() = getNearestCell(x, y);
+ cur.idx() = getNearestCell(cur.bv(), x, y);
resetPos(cur);
return cell(cur.idx())->text_.editXY(cur, x, y);
}
void InsetTabular::setCursorFromCoordinates(LCursor & cur, int x, int y) const
{
- cur.idx() = getNearestCell(x, y);
+ cur.idx() = getNearestCell(cur.bv(), x, y);
cell(cur.idx())->text_.setCursorFromCoordinates(cur, x, y);
}
-InsetTabular::idx_type InsetTabular::getNearestCell(int x, int y) const
+InsetTabular::idx_type InsetTabular::getNearestCell(BufferView & bv, int x, int y) const
{
idx_type idx_min = 0;
int dist_min = std::numeric_limits<int>::max();
for (idx_type i = 0, n = nargs(); i != n; ++i) {
- if (theCoords.getInsets().has(tabular.getCellInset(i).get())) {
- int const d = dist(i, x, y);
+ if (bv.coordCache().getInsets().has(tabular.getCellInset(i).get())) {
+ int const d = dist(bv, i, x, y);
if (d < dist_min) {
dist_min = d;
idx_min = i;
int const X1 = 0;
int const X2 = maxwidth;
int const offset = ADD_TO_TABULAR_WIDTH + 2;
- int const x1 = xo() + getCellXPos(cur.idx()) + offset;
+ int const x1 = xo(cur.bv()) + getCellXPos(cur.idx()) + offset;
int const x2 = x1 + tabular.getWidthOfColumn(cur.idx());
if (x1 < X1)
bool tablemode(LCursor & cur) const;
/// return the "Manhattan distance" to nearest corner
- int dist(idx_type cell, int x, int y) const;
+ int dist(BufferView &, idx_type cell, int x, int y) const;
/// return the cell nearest to x, y
- idx_type getNearestCell(int x, int y) const;
+ idx_type getNearestCell(BufferView &, int x, int y) const;
///
Buffer const * buffer_;
#include <config.h>
#include "InsetMathDim.h"
+
+#include "BufferView.h"
#include "coordcache.h"
#include "debug.h"
+#include "metricsinfo.h"
InsetMathDim::InsetMathDim()
}
-void InsetMathDim::setPosCache(PainterInfo const &, int x, int y) const
+void InsetMathDim::setPosCache(PainterInfo const & pi, int x, int y) const
{
//lyxerr << "InsetMathDim: cache to " << x << " " << y << std::endl;
- theCoords.insets().add(this, x, y);
+ pi.base.bv->coordCache().insets().add(this, x, y);
}
return false;
cur.idx() += ncols();
}
- cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo());
+ cur.pos() = cur.cell().x2pos(cur.x_target() - cur.cell().xo(cur.bv()));
return true;
}
#include "dispatchresult.h"
#include "funcrequest.h"
#include "gettext.h"
+#include "lyxtext.h"
#include "outputparams.h"
#include "undo.h"
// absolute again when actually drawing the cursor. What a mess.
BOOST_ASSERT(ptr_cmp(&sl.inset(), this));
MathArray const & ar = sl.cell();
- if (!theCoords.getArrays().has(&ar)) {
+ CoordCache & coord_cache = sl.text()->bv()->coordCache();
+ if (!coord_cache.getArrays().has(&ar)) {
// this can (semi-)legally happen if we just created this cell
// and it never has been drawn before. So don't ASSERT.
//lyxerr << "no cached data for array " << &ar << endl;
y = 0;
return;
}
- Point const pt = theCoords.getArrays().xy(&ar);
- if (!theCoords.getInsets().has(this)) {
+ Point const pt = coord_cache.getArrays().xy(&ar);
+ if (!coord_cache.getInsets().has(this)) {
// same as above
//lyxerr << "no cached data for inset " << this << endl;
x = 0;
y = 0;
return;
}
- Point const pt2 = theCoords.getInsets().xy(this);
+ Point const pt2 = coord_cache.getInsets().xy(this);
//lyxerr << "retrieving position cache for MathArray "
// << pt.x_ << ' ' << pt.y_ << std::endl;
x = pt.x_ - pt2.x_ + ar.pos2x(sl.pos());
void InsetMathNest::drawSelection(PainterInfo & pi, int x, int y) const
{
+ BufferView & bv = *pi.base.bv;
// this should use the x/y values given, not the cached values
- LCursor & cur = pi.base.bv->cursor();
+ LCursor & cur = bv.cursor();
if (!cur.selection())
return;
if (!ptr_cmp(&cur.inset(), this))
CursorSlice s1 = cur.selBegin();
CursorSlice s2 = cur.selEnd();
+
//lyxerr << "InsetMathNest::drawing selection: "
// << " s1: " << s1 << " s2: " << s2 << endl;
if (s1.idx() == s2.idx()) {
MathArray const & c = cell(s1.idx());
- int x1 = c.xo() + c.pos2x(s1.pos());
- int y1 = c.yo() - c.ascent();
- int x2 = c.xo() + c.pos2x(s2.pos());
- int y2 = c.yo() + c.descent();
+ int x1 = c.xo(bv) + c.pos2x(s1.pos());
+ int y1 = c.yo(bv) - c.ascent();
+ int x2 = c.xo(bv) + c.pos2x(s2.pos());
+ int y2 = c.yo(bv) + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
//lyxerr << "InsetMathNest::drawing selection 3: "
// << " x1: " << x1 << " x2: " << x2
for (idx_type i = 0; i < nargs(); ++i) {
if (idxBetween(i, s1.idx(), s2.idx())) {
MathArray const & c = cell(i);
- int x1 = c.xo();
- int y1 = c.yo() - c.ascent();
- int x2 = c.xo() + c.width();
- int y2 = c.yo() + c.descent();
+ int x1 = c.xo(bv);
+ int y1 = c.yo(bv) - c.ascent();
+ int x2 = c.xo(bv) + c.width();
+ int y2 = c.yo(bv) + c.descent();
pi.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
}
}
int idx_min = 0;
int dist_min = 1000000;
for (idx_type i = 0, n = nargs(); i != n; ++i) {
- int const d = cell(i).dist(x, y);
+ int const d = cell(i).dist(cur.bv(), x, y);
if (d < dist_min) {
dist_min = d;
idx_min = i;
MathArray & ar = cell(idx_min);
cur.push(*this);
cur.idx() = idx_min;
- cur.pos() = ar.x2pos(x - ar.xo());
+ cur.pos() = ar.x2pos(x - ar.xo(cur.bv()));
+
//lyxerr << "found cell : " << idx_min << " pos: " << cur.pos() << endl;
if (dist_min == 0) {
// hit inside cell
for (pos_type i = 0, n = ar.size(); i < n; ++i)
- if (ar[i]->covers(x, y))
+ if (ar[i]->covers(cur.bv(), x, y))
return ar[i].nucleus()->editXY(cur, x, y);
}
return this;
if (nuc().size())
nuc().draw(pi, x + dxx(), y);
else {
- nuc().setXY(x + dxx(), y);
+ nuc().setXY(*pi.base.bv, x + dxx(), y);
if (editing(pi.base.bv))
pi.draw(x + dxx(), y, char_type('.'));
}
#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"
void MathArray::draw(PainterInfo & pi, int x, int y) const
{
//lyxerr << "MathArray::draw: x: " << x << " y: " << y << endl;
- setXY(x, y);
+ setXY(*pi.base.bv, x, y);
if (empty()) {
pi.pain.rectangle(x, y - ascent(), width(), height(), LColor::mathline);
}
}
#endif
- theCoords.insets().add(at.nucleus(), x, y);
+ //BufferView & bv = *pi.base.bv;
+ pi.base.bv->coordCache().insets().add(at.nucleus(), x, y);
at->drawSelection(pi, x, y);
at->draw(pi, x, y);
x += at->width();
void MathArray::drawT(TextPainter & pain, int x, int y) const
{
//lyxerr << "x: " << x << " y: " << y << ' ' << pain.workAreaHeight() << endl;
- setXY(x, y);
+
+ // FIXME: Abdel 13/10/2006
+ // The setXV() call below is commented out for now because
+ // we don't have access to a BufferView at this level.
+ // In any case, this drawT() method is never used, this is dead code.
+ //
+ /* Georg explanation of current situation:
+ AFAIK the text painter was used to export math formulas as ASCII art.
+ Therefore the setXY() call makes sense. Imagine that the text painter is
+ like a real painter, but operating on a very coarse grid of character cells
+ where each cell can be filled with an ASCII character.
+ I don't know why it is currently disabled. I do know that we have a bugzilla
+ request for reenabling it. I believe only Andre can tell whether that is
+ doable or whether the whole drawT machinery should be removed.
+ */
+ //setXY(bv, x, y);
for (const_iterator it = begin(), et = end(); it != et; ++it) {
(*it)->drawT(pain, x, y);
}
-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;
}
-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() const
+int MathArray::xo(BufferView & bv) const
{
- return theCoords.getArrays().x(this);
+ return bv.coordCache().getArrays().x(this);
}
-int MathArray::yo() const
+int MathArray::yo(BufferView & bv) const
{
- return theCoords.getArrays().y(this);
+ return bv.coordCache().getArrays().y(this);
}
#include "MathAtom.h"
#include "dimension.h"
+class BufferView;
class LaTeXFeatures;
class ReplaceData;
class MetricsInfo;
void touch() const;
/// access to cached x coordinate of last drawing
- int xo() const;
+ int xo(BufferView & bv) const;
/// access to cached y coordinate of last drawing
- int yo() const;
+ int yo(BufferView & bv) const;
/// access to cached x coordinate of mid point of last drawing
- int xm() const { return xo() + dim_.wid / 2; }
+ int xm(BufferView & bv) const { return xo(bv) + dim_.wid / 2; }
/// access to cached y coordinate of mid point of last drawing
- int ym() const { return yo() + (dim_.des - dim_.asc) / 2; }
+ int ym(BufferView & bv) const { return yo(bv) + (dim_.des - dim_.asc) / 2; }
/// write access to coordinate;
- void setXY(int x, int y) const;
+ void setXY(BufferView & bv, int x, int y) const;
/// returns x coordinate of given position in the array
int pos2x(size_type pos) const;
/// returns position of given x coordinate
size_type x2pos(int targetx, int glue) const;
/// returns distance of this cell to the point given by x and y
// assumes valid position and size cache
- int dist(int x, int y) const;
+ int dist(BufferView & bv, int x, int y) const;
/// ascent of this cell above the baseline
int ascent() const { return dim_.asc; }
LyXFont const getLabelFont() const;
/// bufferview to paint on
- BufferView const & bv_;
+ BufferView & bv_;
/// Painter to use
Painter & pain_;
font;
pi.ltr_pos = (text_.bidi.level(pos) % 2 == 0);
pi.erased_ = erased_ || isDeletedText(par_, pos);
- theCoords.insets().add(inset, int(x_), yo_);
+ bv_.coordCache().insets().add(inset, int(x_), yo_);
InsetText const * const in = inset->asTextInset();
// non-wide insets are painted completely. Recursive
bool tmp = refreshInside;
static PainterInfo nullpi(pi.base.bv, nop);
int const ww = pi.base.bv->workHeight();
- theCoords.parPos()[&text][pit] = Point(x, y);
+ pi.base.bv->coordCache().parPos()[&text][pit] = Point(x, y);
Paragraph const & par = text.paragraphs()[pit];
if (par.rows().empty())
} // namespace anon
-void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
+void paintText(BufferView & bv, ViewMetricsInfo const & vi,
Painter & pain)
{
LyXText & text = bv.buffer()->text();
if (vi.p1 > 0) {
text.redoParagraph(vi.p1 - 1);
- theCoords.parPos()[&text][vi.p1 - 1] =
+ bv.coordCache().parPos()[&text][vi.p1 - 1] =
Point(0, vi.y1 - text.getPar(vi.p1 - 1).descent());
}
if (vi.p2 < lyx::pit_type(text.paragraphs().size()) - 1) {
text.redoParagraph(vi.p2 + 1);
- theCoords.parPos()[&text][vi.p2 + 1] =
+ bv.coordCache().parPos()[&text][vi.p2 + 1] =
Point(0, vi.y2 + text.getPar(vi.p2 + 1).ascent());
}
/// paint visible paragraph of main text
-void paintText(BufferView const & bv, ViewMetricsInfo const & vi,
+void paintText(BufferView & bv, ViewMetricsInfo const & vi,
lyx::frontend::Painter & painter);
/// paint the rows of a text inset
DocIterator beg = cur.selectionBegin();
DocIterator end = cur.selectionEnd();
+ BufferView * bv = pi.base.bv;
+
// the selection doesn't touch the visible screen
- if (bv_funcs::status(pi.base.bv, beg) == bv_funcs::CUR_BELOW
- || bv_funcs::status(pi.base.bv, end) == bv_funcs::CUR_ABOVE)
+ if (bv_funcs::status(bv, beg) == bv_funcs::CUR_BELOW
+ || bv_funcs::status(bv, end) == bv_funcs::CUR_ABOVE)
return;
Paragraph const & par1 = pars_[beg.pit()];
Paragraph const & par2 = pars_[end.pit()];
- bool const above = (bv_funcs::status(pi.base.bv, beg)
+ bool const above = (bv_funcs::status(bv, beg)
== bv_funcs::CUR_ABOVE);
- bool const below = (bv_funcs::status(pi.base.bv, end)
+ bool const below = (bv_funcs::status(bv, end)
== bv_funcs::CUR_BELOW);
int y1,y2,x1,x2;
if (above) {
x2 = dim_.wid;
} else {
Row const & row1 = par1.getRow(beg.pos(), beg.boundary());
- y1 = bv_funcs::getPos(beg, beg.boundary()).y_ - row1.ascent();
+ y1 = bv_funcs::getPos(*bv, beg, beg.boundary()).y_ - row1.ascent();
y2 = y1 + row1.height();
int const startx = cursorX(beg.top(), beg.boundary());
x1 = !isRTL(par1) ? startx : 0;
int Y1,Y2,X1,X2;
if (below) {
- Y1 = pi.base.bv->workHeight();
- Y2 = pi.base.bv->workHeight();
+ Y1 = bv->workHeight();
+ Y2 = bv->workHeight();
X1 = 0;
X2 = dim_.wid;
} else {
Row const & row2 = par2.getRow(end.pos(), end.boundary());
- Y1 = bv_funcs::getPos(end, end.boundary()).y_ - row2.ascent();
+ Y1 = bv_funcs::getPos(*bv, end, end.boundary()).y_ - row2.ascent();
Y2 = Y1 + row2.height();
int const endx = cursorX(end.top(), end.boundary());
X1 = !isRTL(par2) ? 0 : endx;
{
BOOST_ASSERT(this == cur.text());
pit_type pit = getPitNearY(y);
- int yy = theCoords.get(this, pit).y_ - pars_[pit].ascent();
+ int yy = cur.bv().coordCache().get(this, pit).y_ - pars_[pit].ascent();
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< ": x: " << x
<< BOOST_CURRENT_FUNCTION
<< ": examining inset " << inset << endl;
- if (theCoords.getInsets().has(inset))
+ if (bv()->coordCache().getInsets().has(inset))
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
- << ": xo: " << inset->xo() << "..."
- << inset->xo() + inset->width()
- << " yo: " << inset->yo() - inset->ascent()
+ << ": xo: " << inset->xo(*bv()) << "..."
+ << inset->xo(*bv()) + inset->width()
+ << " yo: " << inset->yo(*bv()) - inset->ascent()
<< "..."
- << inset->yo() + inset->descent()
+ << inset->yo(*bv()) + inset->descent()
<< endl;
else
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< ": inset has no cached position" << endl;
#endif
- if (inset->covers(x, y)) {
+ if (inset->covers(*bv(), x, y)) {
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< ": Hit inset: " << inset << endl;
pos_type LyXText::getColumnNearX(pit_type const pit,
Row const & row, int & x, bool & boundary) const
{
- int const xo = theCoords.get(this, pit).x_;
+ int const xo = bv()->coordCache().get(this, pit).x_;
x -= xo;
RowMetrics const r = computeRowMetrics(pit, row);
Paragraph const & par = pars_[pit];
pit_type LyXText::getPitNearY(int y) const
{
BOOST_ASSERT(!paragraphs().empty());
- BOOST_ASSERT(theCoords.getParPos().find(this) != theCoords.getParPos().end());
- CoordCache::InnerParPosCache const & cc = theCoords.getParPos().find(this)->second;
+ BOOST_ASSERT(bv()->coordCache().getParPos().find(this) != bv()->coordCache().getParPos().end());
+ CoordCache::InnerParPosCache const & cc = bv()->coordCache().getParPos().find(this)->second;
lyxerr[Debug::DEBUG]
<< BOOST_CURRENT_FUNCTION
<< ": y: " << y << " cache size: " << cc.size()
Row const & LyXText::getRowNearY(int y, pit_type pit) const
{
Paragraph const & par = pars_[pit];
- int yy = theCoords.get(this, pit).y_ - par.ascent();
+ int yy = bv()->coordCache().get(this, pit).y_ - par.ascent();
BOOST_ASSERT(!par.rows().empty());
RowList::const_iterator rit = par.rows().begin();
RowList::const_iterator const rlast = boost::prior(par.rows().end());
row = par.pos2row(cur.pos());
if (!cur.selection()) {
- int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
+ int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;
LCursor old = cur;
// Go to middle of previous row. 16 found to work OK;
// 12 = top/bottom margin of display math
row = par.pos2row(cur.pos());
if (!cur.selection()) {
- int const y = bv_funcs::getPos(cur, cur.boundary()).y_;
+ int const y = bv_funcs::getPos(cur.bv(), cur, cur.boundary()).y_;
LCursor old = cur;
// To middle of next row
int const margin = 3 * InsetMathHull::displayMargin() / 2;