]> git.lyx.org Git - features.git/blobdiff - src/insets/InsetTabular.cpp
Use new display() values to remove some inset hardcoding.
[features.git] / src / insets / InsetTabular.cpp
index 86718b0b87aabfe8ba4e4c3cedecd7aa0195f472..0680d93be8a7e60702400c2ee8030d602b82a926 100644 (file)
@@ -4214,12 +4214,12 @@ void InsetTabular::drawSelection(PainterInfo & pi, int x, int y) const
 namespace {
 
 void tabline(PainterInfo const & pi, int x1, int y1, int x2, int y2,
-             bool drawline, int thickness = 1)
+             bool drawline, bool heavy = false)
 {
        ColorCode const col = drawline ? Color_tabularline : Color_tabularonoffline;
        pi.pain.line(x1, y1, x2, y2, pi.textColor(col),
                                 drawline ? Painter::line_solid : Painter::line_onoffdash,
-                                thickness * Painter::thin_line);
+                                (heavy ? 2 : 1) * Painter::thin_line);
 }
 
 }
@@ -4235,17 +4235,14 @@ void InsetTabular::drawCellLines(PainterInfo & pi, int x, int y,
        // Top
        bool drawline = tabular.topLine(cell)
                || (row > 0 && tabular.bottomLine(tabular.cellAbove(cell)));
-       int thickness = 1;
-       if (drawline && tabular.use_booktabs && tabular.rowTopLine(row))
-               thickness = (row == 0) ? 3 : 2;
-       tabline(pi, x, y, x + w, y, drawline, thickness);
+       bool heavy = tabular.use_booktabs && row == 0 && tabular.rowTopLine(row);
+       tabline(pi, x, y, x + w, y, drawline, heavy);
 
        // Bottom
        drawline = tabular.bottomLine(cell);
-       thickness = 1;
-       if (drawline && tabular.use_booktabs && tabular.rowBottomLine(row))
-               thickness = (row == tabular.nrows() - 1) ? 3 : 2;
-       tabline(pi, x, y + h, x + w, y + h, drawline, thickness);
+       heavy = tabular.use_booktabs && row == tabular.nrows() - 1
+               && tabular.rowBottomLine(row);
+       tabline(pi, x, y + h, x + w, y + h, drawline, heavy);
 
        // Left
        col_type const col = tabular.cellColumn(cell);
@@ -5399,13 +5396,13 @@ Inset::DisplayType InsetTabular::display() const
                if (tabular.is_long_tabular) {
                        switch (tabular.longtabular_alignment) {
                        case Tabular::LYX_LONGTABULAR_ALIGN_LEFT:
-                               return AlignLeft;
+                               return Display | AlignLeft;
                        case Tabular::LYX_LONGTABULAR_ALIGN_CENTER:
-                               return AlignCenter;
+                               return Display;
                        case Tabular::LYX_LONGTABULAR_ALIGN_RIGHT:
-                               return AlignRight;
+                               return Display | AlignRight;
                        default:
-                               return AlignCenter;
+                               return Display;
                        }
                } else
                        return Inline;
@@ -6575,12 +6572,12 @@ void InsetTabular::getSelection(Cursor & cur,
        cs = tabular.cellColumn(beg.idx());
        ce = tabular.cellColumn(end.idx());
        if (cs > ce)
-               swap(cs, ce);
+               std::swap(cs, ce);
 
        rs = tabular.cellRow(beg.idx());
        re = tabular.cellRow(end.idx());
        if (rs > re)
-               swap(rs, re);
+               std::swap(rs, re);
 }