- pi.pain.setDrawingEnabled(true);
-
- //LYXERR(Debug::PAINTING) << "." << endl;
-}
-
-
-// only used for inset right now. should also be used for main text
-void TextMetrics::drawSelection(PainterInfo & pi, int x, int) const
-{
- Cursor & cur = bv_->cursor();
- if (!cur.selection())
- return;
- if (!ptr_cmp(cur.text(), text_))
- return;
-
- LYXERR(Debug::DEBUG)
- << BOOST_CURRENT_FUNCTION
- << "draw selection at " << x
- << endl;
-
- DocIterator beg = cur.selectionBegin();
- DocIterator end = cur.selectionEnd();
-
- // the selection doesn't touch the visible screen?
- if (bv_funcs::status(bv_, beg) == bv_funcs::CUR_BELOW
- || bv_funcs::status(bv_, end) == bv_funcs::CUR_ABOVE)
- return;
-
- if (beg.pit() < par_metrics_.begin()->first) {
- beg.pit() = par_metrics_.begin()->first;
- beg.pos() = 0;
- }
- if (end.pit() > par_metrics_.rbegin()->first) {
- end.pit() = par_metrics_.rbegin()->first;
- end.pos() = end.lastpos();
- }
-
- ParagraphMetrics const & pm1 = par_metrics_[beg.pit()];
- ParagraphMetrics const & pm2 = par_metrics_[end.pit()];
- Row const & row1 = pm1.getRow(beg.pos(), beg.boundary());
- Row const & row2 = pm2.getRow(end.pos(), end.boundary());
-
- // clip above
- int middleTop;
- bool const clipAbove =
- (bv_funcs::status(bv_, beg) == bv_funcs::CUR_ABOVE);
- if (clipAbove)
- middleTop = 0;
- else
- middleTop = bv_funcs::getPos(*bv_, beg, beg.boundary()).y_ + row1.descent();
-
- // clip below
- int middleBottom;
- bool const clipBelow =
- (bv_funcs::status(bv_, end) == bv_funcs::CUR_BELOW);
- if (clipBelow)
- middleBottom = bv_->workHeight();
- else
- middleBottom = bv_funcs::getPos(*bv_, end, end.boundary()).y_ - row2.ascent();