From: Edwin Leuven Date: Tue, 16 Mar 2010 22:42:57 +0000 (+0000) Subject: correct cell line drawing for multirow cells X-Git-Tag: 2.0.0~3778 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=28c759e171b7b87375ed1c2cbbdd5be62eb4e405;p=features.git correct cell line drawing for multirow cells git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33781 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/insets/InsetTabular.cpp b/src/insets/InsetTabular.cpp index 2bcc0a8daa..13add83e6f 100644 --- a/src/insets/InsetTabular.cpp +++ b/src/insets/InsetTabular.cpp @@ -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); }