]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
More fixes to the autocollapsing of paragraphs.
[lyx.git] / src / text.C
index 3ff2676f674c226e2328ae22d3af720f9291db10..2c626a6a220f696a48f1d53cc46ed42f792652d2 100644 (file)
@@ -69,17 +69,26 @@ int LyXText::workWidth(BufferView * bview) const
 int LyXText::workWidth(BufferView * bview, Inset * inset) const
 {
        Paragraph * par = 0;
-       pos_type pos = 0;
-
-       Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
-
-       for (; it != bview->buffer()->inset_iterator_end(); ++it) {
-               if (*it == inset) {
-                       par = it.getPar();
-                       pos = it.getPos();
-                       break;
+       pos_type pos = -1;
+
+       par = inset->parOwner();
+       if (par)
+               pos = par->getPositionOfInset(inset);
+
+       if (!par || pos == -1) {
+               lyxerr << "LyXText::workWidth: something is wrong,"
+                       " fall back to the brute force method" << endl;
+               Buffer::inset_iterator it = bview->buffer()->inset_iterator_begin();
+               Buffer::inset_iterator end = bview->buffer()->inset_iterator_end();
+               for ( ; it != end; ++it) {
+                       if (*it == inset) {
+                               par = it.getPar();
+                               pos = it.getPos();
+                               break;
+                       }
                }
        }
+       
        if (!par) {
                return workWidth(bview);
        }
@@ -3160,12 +3169,12 @@ void LyXText::paintRowDepthBar(DrawRowParams & p)
 
 int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const
 {
+       int const arrow_size = 4;
+       int const space_size = int(vsp.inPixels(bv));
+
        if (vsp.kind() != VSpace::LENGTH) {
-               return int(vsp.inPixels(bv));
+               return space_size;
        }
-
-       int const space_size = int(vsp.inPixels(bv));
-       int const arrow_size = 4;
  
        LyXFont font;
        font.decSize();
@@ -3173,7 +3182,10 @@ int LyXText::getLengthMarkerHeight(BufferView * bv, VSpace const & vsp) const
                                      lyxfont::maxAscent(font)
                                      + lyxfont::maxDescent(font));
 
-       return std::max(min_size, space_size);
+       if (vsp.length().len().value() < 0.0)
+               return min_size;
+       else 
+               return std::max(min_size, space_size);
 }
 
  
@@ -3321,8 +3333,8 @@ void LyXText::paintFirstRow(DrawRowParams & p)
                y_top += asc;
  
                int const w = (inset_owner ?  inset_owner->width(p.bv, font) : ww);
-               int const xp = static_cast<int>(inset_owner ? p.x : 0);
-               p.pain->line(xp, p.yo + y_top, w, p.yo + y_top,
+               int const xp = static_cast<int>(inset_owner ? p.xo : 0);
+               p.pain->line(xp, p.yo + y_top, xp + w, p.yo + y_top,
                        LColor::topline, Painter::line_solid,
                        Painter::line_thick);
                
@@ -3481,9 +3493,9 @@ void LyXText::paintLastRow(DrawRowParams & p)
                y_bottom -= asc;
  
                int const w = (inset_owner ?  inset_owner->width(p.bv, font) : ww);
-               int const xp = static_cast<int>(inset_owner ? p.x : 0);
+               int const xp = static_cast<int>(inset_owner ? p.xo : 0);
                int const y = p.yo + y_bottom; 
-               p.pain->line(xp, y, w, y, LColor::topline, Painter::line_solid,
+               p.pain->line(xp, y, xp + w, y, LColor::topline, Painter::line_solid,
                          Painter::line_thick);
  
                y_bottom -= asc;