return data_.find(thing) != data_.end();
}
+// T * find(int x, int y) const
+// {
+// T *
+// cache_type iter
+// }
+
private:
friend class CoordCache;
}
}
- std::map<T const *, Point> data_;
+ typedef std::map<T const *, Point> cache_type;
+ cache_type data_;
};
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->top_y());
+ theCoords.insets_.add(this, x, y);
}
}
-//Paragraph::value_type Paragraph::getChar(pos_type pos) const
-//{
-// // This is in the critical path!
-// pos_type const siz = text_.size();
-//
-// BOOST_ASSERT(0 <= pos);
-// BOOST_ASSERT(pos <= siz);
-//
-// if (pos == siz) {
-// lyxerr << "getChar() on pos " << pos << " in par id "
-// << id() << " of size " << siz
-// << " is a bit silly !" << endl;
-// BOOST_ASSERT(false);
-// }
-//
-// return text_[pos];
-//}
-
-
int Paragraph::id() const
{
return pimpl_->id_;
for (Paragraph::depth_type i = 1; i <= depth; ++i) {
int const w = nestMargin() / 5;
- int x = xo_ + w * i;
- // only consider the changebar space if we're drawing outer left
- if (xo_ == 0)
+ int x = int(xo_) + w * i;
+ // only consider the changebar space if we're drawing outermost text
+ if (text_.isMainText())
x += changebarMargin();
int const h = yo_ + row_.height() - 1 - (i - next_depth - 1) * 3;
}
-// y is relative to this LyXText's top
-Row const & LyXText::getRowNearY(int y, par_type & pit) const
-{
- BOOST_ASSERT(!paragraphs().empty());
- BOOST_ASSERT(!paragraphs().begin()->rows.empty());
- par_type const pend = paragraphs().size() - 1;
- pit = 0;
- while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
- ++pit;
-
- RowList::iterator rit = pars_[pit].rows.end();
- RowList::iterator const rbegin = pars_[pit].rows.begin();
- do {
- --rit;
- } while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
-
- return *rit;
-}
-
-
Row const & LyXText::firstRow() const
{
return *paragraphs().front().rows.begin();
bv()->top_y() - yo_ + bv()->workHeight(),
pit, end);
+ // convert to screen-absolute y coordinate
+ y -= bv()->top_y();
lyxerr << "checkInsetHit: x: " << x << " y: " << y << endl;
lyxerr << " pit: " << pit << " end: " << end << endl;
for (; pit != end; ++pit) {
}
+// y is relative to this LyXText's top
+// this is only used in the two functions below
+Row const & LyXText::getRowNearY(int y, par_type & pit) const
+{
+ BOOST_ASSERT(!paragraphs().empty());
+ BOOST_ASSERT(!paragraphs().begin()->rows.empty());
+ par_type const pend = paragraphs().size() - 1;
+ pit = 0;
+ while (int(pars_[pit].y + pars_[pit].height) < y && pit != pend)
+ ++pit;
+
+ RowList::iterator rit = pars_[pit].rows.end();
+ RowList::iterator const rbegin = pars_[pit].rows.begin();
+ do {
+ --rit;
+ } while (rit != rbegin && int(pars_[pit].y + rit->y_offset()) > y);
+
+ return *rit;
+}
+
+
// x,y are absolute coordinates
// sets cursor only within this LyXText
void LyXText::setCursorFromCoordinates(LCursor & cur, int x, int y)
// ignore motions deeper nested than the real anchor
LCursor & bvcur = cur.bv().cursor();
- if (!bvcur.anchor_.hasPart(cur))
- break;
-
- CursorSlice old = cur.top();
- setCursorFromCoordinates(cur, cmd.x, cmd.y);
+ if (bvcur.anchor_.hasPart(cur)) {
+ CursorSlice old = cur.top();
+ setCursorFromCoordinates(cur, cmd.x, cmd.y);
+
+ // This is to allow jumping over large insets
+ // FIXME: shouldn't be top-text-specific
+ if (isMainText() && cur.top() == old) {
+ if (cmd.y - bv->top_y() >= bv->workHeight())
+ cursorDown(cur);
+ else if (cmd.y - bv->top_y() < 0)
+ cursorUp(cur);
+ }
- // This is to allow jumping over large insets
- // FIXME: shouldn't be top-text-specific
- if (isMainText() && cur.top() == old) {
- if (cmd.y - bv->top_y() >= bv->workHeight())
- cursorDown(cur);
- else if (cmd.y - bv->top_y() < 0)
- cursorUp(cur);
+ // don't set anchor_
+ bv->cursor().setCursor(cur);
+ bv->cursor().selection() = true;
+ lyxerr << "MOTION: " << bv->cursor() << endl;
}
-
- // don't set anchor_
- bv->cursor().setCursor(cur);
- bv->cursor().selection() = true;
- lyxerr << "MOTION: " << bv->cursor() << endl;
break;
}