]> git.lyx.org Git - features.git/commitdiff
correct cell line drawing for multirow cells
authorEdwin Leuven <e.leuven@gmail.com>
Tue, 16 Mar 2010 22:42:57 +0000 (22:42 +0000)
committerEdwin Leuven <e.leuven@gmail.com>
Tue, 16 Mar 2010 22:42:57 +0000 (22:42 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33781 a592a061-630c-0410-9148-cb99ea01b6c8

src/insets/InsetTabular.cpp

index 2bcc0a8daa76290f0ec1d090dea6a7655b23c111..13add83e6fe506ceb5039a9e8bb026dbeaaee25c 100644 (file)
@@ -3495,49 +3495,42 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
 
 
 void InsetTabular::drawCellLines(Painter & pain, int x, int y,
-                                row_type row, idx_type cell, Change const & change) const
+                                                                row_type row, idx_type cell, Change const & change) const
 {
-       y = y - tabular.rowAscent(row);
+       y -= tabular.rowAscent(row);
        int const w = tabular.columnWidth(cell);
        int const h = tabular.cellHeight(cell);
-       bool on_off = false;
-       Color col = Color_tabularline;
-       Color onoffcol = Color_tabularonoffline;
+       Color linecolor = change.changed() ? change.color() : Color_tabularline;
+       Color gridcolor = change.changed() ? change.color() : Color_tabularonoffline;
 
-       if (change.changed()) {
-               col = change.color();
-               onoffcol = change.color();
-       }
-
-       bool topalreadydrawn = row > 0 && !tabular.rowTopLine(row) 
+       // Top
+       bool drawline = tabular.topLine(cell) || row > 0
                && tabular.bottomLine(tabular.cellAbove(cell));
+       pain.line(x, y, x + w, y,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 
-       if (!topalreadydrawn) {
-               on_off = !tabular.topLine(cell);
-               pain.line(x, y, x + w, y,
-                       on_off ? onoffcol : col,
-                       on_off ? Painter::line_onoffdash : Painter::line_solid);
-       }
-       on_off = !tabular.bottomLine(cell);
+       // Bottom
+       drawline = tabular.bottomLine(cell);
        pain.line(x, y + h, x + w, y + h,
-               on_off ? onoffcol : col,
-               on_off ? Painter::line_onoffdash : Painter::line_solid);
-
-       col_type const column = tabular.cellColumn(cell);
-       bool leftalreadydrawn = column > 0  && !tabular.leftLine(cell)
-               && tabular.rightLine(tabular.cellIndex(row, column - 1));
-
-       if (!leftalreadydrawn) {
-               on_off = !tabular.leftLine(cell);
-               pain.line(x, y, x, y + h,
-                       on_off ? onoffcol : col,
-                       on_off ? Painter::line_onoffdash : Painter::line_solid);
-       }
-       on_off = !tabular.rightLine(cell);
-       pain.line(x + w - tabular.interColumnSpace(cell), y,
-               x + w - tabular.interColumnSpace(cell), y + h,
-               on_off ? onoffcol : col,
-               on_off ? Painter::line_onoffdash : Painter::line_solid);
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
+
+       // Left
+       col_type const col = tabular.cellColumn(cell);
+       drawline = tabular.leftLine(cell) || col > 0
+               && tabular.rightLine(tabular.cellIndex(row, col - 1));
+       pain.line(x, y, x, y + h,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
+
+       // Right
+       x -= tabular.interColumnSpace(cell);
+       drawline = tabular.rightLine(cell) || col + 1 < tabular.ncols() 
+               && tabular.leftLine(tabular.cellIndex(row, col + 1));
+       pain.line(x + w, y, x + w, y + h,
+               drawline ? linecolor : gridcolor,
+               drawline ? Painter::line_solid : Painter::line_onoffdash);
 }