]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.C
more cursor dispatch
[lyx.git] / src / rowpainter.C
index 8fe21d9e616c7fff7e3f9ab99ecc521dbea25a19..d9f8001afe9fafab5aa5e37ccfa45a5f6e74732f 100644 (file)
@@ -47,6 +47,7 @@ using std::string;
 extern int NEST_MARGIN;
 extern int CHANGEBAR_MARGIN;
 
+
 namespace {
 
 /**
@@ -125,6 +126,9 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
                hfill_(row_.fill_hfill()),
                label_hfill_(row_.fill_label_hfill())
 {
+       //lyxerr << "RowPainter: x: " << x_ << " xo: " << xo << " yo: " << yo
+       //      << " pit->y: " << pit_->y
+       //      << " row: " << (pit_->size() ? pit_->getChar(row_.pos()) : 'X') << endl;
        x_ += xo_;
 
        // background has already been cleared.
@@ -132,8 +136,9 @@ RowPainter::RowPainter(BufferView const & bv, LyXText const & text,
                paintBackground();
 
        // paint the selection background
-       if (bv_.selection().set() && &text_ == bv_.fullCursor().innerText())
-               paintSelection();
+#warning look here for selection
+       //if (bv_.cursor().selection() && &text_ == bv_.cursor().innerText())
+       //      paintSelection();
 
        // vertical lines for appendix
        paintAppendix();
@@ -189,12 +194,11 @@ int RowPainter::leftMargin() const
 
 void RowPainter::paintInset(pos_type const pos)
 {
-       InsetOld * inset = const_cast<InsetOld*>(pit_->getInset(pos));
-
+       InsetBase const * inset = pit_->getInset(pos);
        BOOST_ASSERT(inset);
-
        PainterInfo pi(const_cast<BufferView *>(&bv_));
        pi.base.font = getFont(pos);
+       inset->drawSelection(pi, int(x_), yo_ + row_.baseline());
        inset->draw(pi, int(x_), yo_ + row_.baseline());
        x_ += inset->width();
 }
@@ -242,7 +246,7 @@ void RowPainter::paintArabicComposeChar(pos_type & vpos)
        // first char
        char c = pit_->getChar(pos);
        c = pit_->transformChar(c, pos);
-       str +=c;
+       str += c;
        ++vpos;
 
        LyXFont const & font = getFont(pos);
@@ -391,14 +395,15 @@ void RowPainter::paintSelection()
        bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
 
        // the current selection
-       int const startx = text_.cursorX(bv_.selStart());
-       int const endx = text_.cursorX(bv_.selEnd());
-       int const starty = text_.cursorY(bv_.selStart());
-       int const endy = text_.cursorY(bv_.selEnd());
-       ParagraphList::iterator startpit = text_.getPar(bv_.selStart());
-       ParagraphList::iterator endpit = text_.getPar(bv_.selEnd());
-       RowList::iterator startrow = startpit->getRow(bv_.selStart().pos());
-       RowList::iterator endrow = endpit->getRow(bv_.selEnd().pos());
+       LCursor const & cur = bv_.cursor();
+       int const startx = text_.cursorX(cur.selBegin());
+       int const endx = text_.cursorX(cur.selEnd());
+       int const starty = text_.cursorY(cur.selBegin());
+       int const endy = text_.cursorY(cur.selEnd());
+       ParagraphList::iterator startpit = text_.getPar(cur.selBegin());
+       ParagraphList::iterator endpit = text_.getPar(cur.selEnd());
+       RowList::iterator startrow = startpit->getRow(cur.selBegin().pos());
+       RowList::iterator endrow = endpit->getRow(cur.selEnd().pos());
        int const h = row_.height();
 
        int const row_y = pit_->y + row_.y_offset();
@@ -412,19 +417,19 @@ void RowPainter::paintSelection()
                int w;
                if (sel_on_one_row) {
                        if (startx < endx) {
-                               x = int(xo_) + startx;
+                               x = startx;
                                w = endx - startx;
                        } else {
-                               x = int(xo_) + endx;
+                               x = endx;
                                w = startx - endx;
                        }
                        pain_.fillRectangle(x, yo_, w, h, LColor::selection);
                } else if (sel_starts_here) {
-                       int const x = is_rtl ? int(xo_) : int(xo_ + startx);
+                       int const x = is_rtl ? 0 : startx;
                        int const w = is_rtl ? startx : (width_ - startx);
                        pain_.fillRectangle(x, yo_, w, h, LColor::selection);
                } else if (sel_ends_here) {
-                       int const x = is_rtl ? int(xo_ + endx) : int(xo_);
+                       int const x = is_rtl ? endx : 0;
                        int const w = is_rtl ? (width_ - endx) : endx;
                        pain_.fillRectangle(x, yo_, w, h, LColor::selection);
                } else if (row_y > starty && row_y < endy) {
@@ -468,9 +473,9 @@ void RowPainter::paintSelection()
                }
 
                if (((startpit != pit_ && startrow != rit_)
-                               || bv_.selStart().pos() <= pos) &&
+                               || cur.selBegin().pos() <= pos) &&
                        ((endpit != pit_ && endrow != rit_)
-                               || pos < bv_.selEnd().pos())) {
+                               || pos < cur.selEnd().pos())) {
                        // Here we do not use x_ as xo_ was added to x_.
                        pain_.fillRectangle(int(old_tmpx), yo_,
                                int(tmpx - old_tmpx + 1), h, LColor::selection);
@@ -883,7 +888,9 @@ int paintPars(BufferView const & bv, LyXText const & text,
 int paintText(BufferView const & bv)
 {
        ParagraphList::iterator pit;
-       bv.text()->getRowNearY(bv.top_y(), pit);
+       bv.text()->updateParPositions();
+       bv.text()->getRowNearY(0, pit);
+       lyxerr << "top_y: " << bv.top_y() << " y: " << pit->y << endl;
        return paintPars(bv, *bv.text(), pit, 0, 0, pit->y);
 }