]> git.lyx.org Git - lyx.git/blobdiff - src/rowpainter.C
move some selection related stuff over to textcursor.C
[lyx.git] / src / rowpainter.C
index 708059be9dcedfc81190bf28f63c9eea5791a460..500c2293fc747793eb87fde2a73947670317a266 100644 (file)
@@ -33,6 +33,7 @@
 #include "rowpainter.h"
 #include "lyxrc.h"
 #include "lyxrow_funcs.h"
+#include "metricsinfo.h"
 
 using std::max;
 using lyx::pos_type;
@@ -81,7 +82,7 @@ int RowPainter::singleWidth(lyx::pos_type pos, char c) const
 
 LyXFont const RowPainter::getLabelFont() const
 {
-       return text_.getLabelFont(bv_.buffer(), &*pit_);
+       return text_.getLabelFont(bv_.buffer(), pit_);
 }
 
 
@@ -103,12 +104,14 @@ void RowPainter::paintInset(pos_type const pos)
 
        lyx::Assert(inset);
 
-       LyXFont const & font = getFont(pos);
-
 #warning inset->update FIXME
        inset->update(perv(bv_), false);
 
-       inset->draw(perv(bv_), font, yo_ + row_->baseline(), x_);
+       PainterInfo pi(perv(bv_));
+       pi.base.font = getFont(pos);
+       int const w = inset->width(perv(bv_), pi.base.font);
+       inset->draw(pi, int(x_), yo_ + row_->baseline());
+       x_ += w;
 }
 
 
@@ -311,8 +314,8 @@ void RowPainter::paintSelection()
        int const endx = text_.selection.end.x();
        int const starty = text_.selection.start.y();
        int const endy = text_.selection.end.y();
-       RowList::iterator startrow = text_.selection.start.row();
-       RowList::iterator endrow = text_.selection.end.row();
+       RowList::iterator startrow = text_.getRow(text_.selection.start);
+       RowList::iterator endrow = text_.getRow(text_.selection.end);
 
        if (text_.bidi_same_direction) {
                int x;
@@ -449,8 +452,10 @@ void RowPainter::paintDepthBar()
        if (row_ != text_.rows().begin())
                prev_depth = boost::prior(row_)->par()->getDepth();
        Paragraph::depth_type next_depth = 0;
-       if (boost::next(row_) != text_.rows().end())
-               next_depth = boost::next(row_)->par()->getDepth();
+
+       RowList::iterator next_row = boost::next(row_);
+       if (next_row != text_.rows().end())
+               next_depth = next_row->par()->getDepth();
 
        for (Paragraph::depth_type i = 1; i <= depth; ++i) {
                int x = (PAPER_MARGIN / 5) * i + xo_;
@@ -634,7 +639,7 @@ void RowPainter::paintFirst()
        LyXLayout_ptr const & layout = pit_->layout();
 
        if (buffer->params.paragraph_separation == BufferParams::PARSEP_SKIP) {
-               if (pit_->previous()) {
+               if (pit_ != text_.ownerParagraphs().begin()) {
                        if (layout->latextype == LATEX_PARAGRAPH
                                && !pit_->getDepth()) {
                                y_top += buffer->params.getDefSkip().inPixels(bv_);