]> git.lyx.org Git - lyx.git/blobdiff - src/text.C
redraw fix 1.
[lyx.git] / src / text.C
index 248919e886e86feb2180c058e42961e23738e5e6..d85417f577e32d3a5349ba28c337afb610982579 100644 (file)
@@ -2604,6 +2604,11 @@ void LyXText::changeRegionCase(BufferView * bview,
        Paragraph * par = from.par();
 
        while (par && (pos != to.pos() || par != to.par())) {
+               if (pos == par->size()) {
+                       par = par->next();
+                       pos = 0;
+                       continue;
+               }
                unsigned char c = par->getChar(pos);
                if (!IsInsetChar(c) && !IsHfillChar(c)) {
                        switch (action) {
@@ -2623,10 +2628,6 @@ void LyXText::changeRegionCase(BufferView * bview,
                checkParagraph(bview, par, pos);
 
                ++pos;
-               if (pos == par->size()) {
-                       par = par->next();
-                       pos = 0;
-               }
        }
        if (to.row() != from.row()) {
                refresh_y = from.y() - from.row()->baseline();
@@ -3307,9 +3308,7 @@ int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
 
        p.pain->rectText(leftx + 2 * arrow_size + 5,
                         start + ((end - start) / 2) + d,
-                        str, font,
-                        backgroundColor(),
-                        backgroundColor());
+                        str, font);
 
        // top arrow
        p.pain->line(leftx, ty1, midx, ty2, LColor::added_space);
@@ -3326,6 +3325,30 @@ int LyXText::drawLengthMarker(DrawRowParams & p, string const & prefix,
 }
 
 
+int LyXText::paintPageBreak(string const & label, int y, DrawRowParams & p)
+{
+       LyXFont pb_font;
+       pb_font.setColor(LColor::pagebreak).decSize();
+
+       int w = 0;
+       int a = 0;
+       int d = 0;
+       font_metrics::rectText(label, pb_font, w, a, d);
+
+       int const text_start = p.xo + ((p.width - w) / 2);
+       int const text_end = text_start + w;
+       p.pain->rectText(text_start, y + d, label, pb_font);
+       p.pain->line(p.xo, y, text_start, y,
+               LColor::pagebreak, Painter::line_onoffdash);
+       p.pain->line(text_end, y, p.xo + p.width, y,
+               LColor::pagebreak, Painter::line_onoffdash);
+
+       return 3 * defaultHeight();
+}
+
 void LyXText::paintFirstRow(DrawRowParams & p)
 {
        Paragraph * par = p.row->par();
@@ -3344,22 +3367,8 @@ void LyXText::paintFirstRow(DrawRowParams & p)
 
        // draw a top pagebreak
        if (parparams.pagebreakTop()) {
-               int const y = p.yo + y_top + 2*defaultHeight();
-               p.pain->line(p.xo, y, p.xo + p.width, y,
-                       LColor::pagebreak, Painter::line_onoffdash);
-
-               int w = 0;
-               int a = 0;
-               int d = 0;
-
-               LyXFont pb_font;
-               pb_font.setColor(LColor::pagebreak).decSize();
-               font_metrics::rectText(_("Page Break (top)"), pb_font, w, a, d);
-               p.pain->rectText((p.width - w)/2, y + d,
-                             _("Page Break (top)"), pb_font,
-                             backgroundColor(),
-                             backgroundColor());
-               y_top += 3 * defaultHeight();
+               y_top += paintPageBreak(_("Page Break (top)"),
+                       p.yo + y_top + 2 * defaultHeight(), p);
        }
 
        // draw the additional space if needed:
@@ -3522,22 +3531,8 @@ void LyXText::paintLastRow(DrawRowParams & p)
 
        // draw a bottom pagebreak
        if (parparams.pagebreakBottom()) {
-               LyXFont pb_font;
-               pb_font.setColor(LColor::pagebreak).decSize();
-               int const y = p.yo + y_bottom - 2 * defaultHeight();
-
-               p.pain->line(p.xo, y, p.xo + p.width, y, LColor::pagebreak,
-                            Painter::line_onoffdash);
-
-               int w = 0;
-               int a = 0;
-               int d = 0;
-               font_metrics::rectText(_("Page Break (bottom)"), pb_font, w, a, d);
-               p.pain->rectText((ww - w) / 2, y + d,
-                       _("Page Break (bottom)"),
-                       pb_font, backgroundColor(), backgroundColor());
-
-               y_bottom -= 3 * defaultHeight();
+               y_bottom -= paintPageBreak(_("Page Break (bottom)"),
+                       p.yo + y_bottom - 2 * defaultHeight(), p);
        }
 
        // draw the additional space if needed:
@@ -3610,6 +3605,7 @@ void LyXText::paintLastRow(DrawRowParams & p)
                break;
        }
 }
 
 void LyXText::paintRowText(DrawRowParams & p)
 {