-// only used for inset right now. should also be used for main text
-void Text::draw(PainterInfo & pi, int x, int y) const
-{
- paintTextInset(*this, pi, x, y);
-}
-
-
-// only used for inset right now. should also be used for main text
-void Text::drawSelection(PainterInfo & pi, int x, int) const
-{
- Cursor & cur = pi.base.bv->cursor();
- if (!cur.selection())
- return;
- if (!ptr_cmp(cur.text(), this))
- return;
-
- LYXERR(Debug::DEBUG)
- << BOOST_CURRENT_FUNCTION
- << "draw selection at " << x
- << endl;
-
- DocIterator beg = cur.selectionBegin();
- DocIterator end = cur.selectionEnd();
-
- BufferView & bv = *pi.base.bv;
- Buffer const & buffer = *bv.buffer();
-
- // 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;
-
- Paragraph const & par1 = pars_[beg.pit()];
- Paragraph const & par2 = pars_[end.pit()];
- TextMetrics const & tm = bv.textMetrics(this);
- ParagraphMetrics const & pm1 = tm.parMetrics(beg.pit());
- ParagraphMetrics const & pm2 = tm.parMetrics(end.pit());
-
- bool const above = (bv_funcs::status(&bv, beg)
- == bv_funcs::CUR_ABOVE);
- bool const below = (bv_funcs::status(&bv, end)
- == bv_funcs::CUR_BELOW);
- int y1,y2,x1,x2;
- if (above) {
- y1 = 0;
- y2 = 0;
- x1 = 0;
- x2 = tm.width();
- } else {
- Row const & row1 = pm1.getRow(beg.pos(), beg.boundary());
- y1 = bv_funcs::getPos(bv, beg, beg.boundary()).y_ - row1.ascent();
- y2 = y1 + row1.height();
- int const startx = cursorX(bv, beg.top(), beg.boundary());
- if (!isRTL(buffer, par1)) {
- x1 = startx;
- x2 = 0 + tm.width();
- }
- else {
- x1 = 0;
- x2 = startx;
- }
- }
-
- int Y1,Y2,X1,X2;
- if (below) {
- Y1 = bv.workHeight();
- Y2 = bv.workHeight();
- X1 = 0;
- X2 = tm.width();
- } else {
- Row const & row2 = pm2.getRow(end.pos(), end.boundary());
- Y1 = bv_funcs::getPos(bv, end, end.boundary()).y_ - row2.ascent();
- Y2 = Y1 + row2.height();
- int const endx = cursorX(bv, end.top(), end.boundary());
- if (!isRTL(buffer, par2)) {
- X1 = 0;
- X2 = endx;
- }
- else {
- X1 = endx;
- X2 = 0 + tm.width();
- }
- }
-
- if (!above && !below && &pm1.getRow(beg.pos(), beg.boundary())
- == &pm2.getRow(end.pos(), end.boundary()))
- {
- // paint only one rectangle
- int const b( !isRTL(*bv.buffer(), par1) ? x + x1 : x + X1 );
- int const w( !isRTL(*bv.buffer(), par1) ? X2 - x1 : x2 - X1 );
- pi.pain.fillRectangle(b, y1, w, y2 - y1, Color::selection);
- return;
- }
-
- LYXERR(Debug::DEBUG) << " y1: " << y1 << " y2: " << y2
- << "X1:" << X1 << " x2: " << X2 << " wid: " << tm.width()
- << endl;
-
- // paint upper rectangle
- pi.pain.fillRectangle(x + x1, y1, x2 - x1, y2 - y1,
- Color::selection);
- // paint bottom rectangle
- pi.pain.fillRectangle(x + X1, Y1, X2 - X1, Y2 - Y1,
- Color::selection);
- // paint center rectangle
- pi.pain.fillRectangle(x, y2, tm.width(),
- Y1 - y2, Color::selection);
-}
-
-
-bool Text::isLastRow(pit_type pit, Row const & row) const
-{
- return row.endpos() >= pars_[pit].size()
- && pit + 1 == pit_type(paragraphs().size());
-}
-
-
-bool Text::isFirstRow(pit_type pit, Row const & row) const
-{
- return row.pos() == 0 && pit == 0;
-}
-
-