]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpace.cpp
Move isMultiCell() to Cursor, and use it.
[lyx.git] / src / insets / InsetSpace.cpp
index c80fe6c2b4640ed8e8693fd5a93a8feaa49dd786..c84e3d6f21fd911d1bae0ee0a93ccddb41b97779 100644 (file)
@@ -173,6 +173,11 @@ void InsetSpace::edit(Cursor & cur, bool, EntryDirection)
 }
 
 
+namespace {
+int const arrow_size = 8;
+}
+
+
 void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        if (isStretchableSpace()) {
@@ -207,10 +212,9 @@ void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
                        break;
                case InsetSpaceParams::CUSTOM:
                case InsetSpaceParams::CUSTOM_PROTECTED: {
-                       int length = params_.length.inBP();
-                       if (length < 0)
-                               length = -1 * length;
-                       dim.wid = length;
+                       int const minwidth = (params_.length.inBP() < 0)
+                               ? 3 * arrow_size : 4;
+                       dim.wid = max(minwidth, abs(params_.length.inBP()));
                        break;
                }
                case InsetSpaceParams::HFILL:
@@ -233,10 +237,10 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
        Dimension const dim = dimension(*pi.base.bv);
 
-       if (isStretchableSpace()) {
+       if (isStretchableSpace() || params_.length.inBP() < 0) {
                int const asc = theFontMetrics(pi.base.font).ascent('M');
                int const desc = theFontMetrics(pi.base.font).descent('M');
-               //Pixel height divisible by 2 for prettier fill graphics:
+               // Pixel height divisible by 2 for prettier fill graphics:
                int const oddheight = (asc ^ desc) & 1;
                int const x0 = x + 1;
                int const x1 = x + dim.wid - 2;
@@ -245,7 +249,7 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
                int const y2 = (y0 + y1) / 2;
                int xoffset = (y0 - y1) / 2;
 
-               //Two tests for very narrow insets
+               // Two tests for very narrow insets
                if (xoffset > x1 - x0
                     && (params_.kind == InsetSpaceParams::LEFTARROWFILL
                         || params_.kind == InsetSpaceParams::RIGHTARROWFILL))
@@ -302,6 +306,18 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
                        pi.pain.line(xm + 1, y1 + 1 , xmr, y2, Color_special);
                        pi.pain.line(xmr, y2 , x3, y2, Color_special);
                        pi.pain.line(x3 + 1, y2 + 1 , x1, y0, Color_special);
+               } else if (params_.kind == InsetSpaceParams::CUSTOM) {
+                       pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_special);
+                       pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_special);
+                       pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_special);
+                       pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_special);
+                       pi.pain.line(x2, y2 , x3, y2, Color_special);
+               } else if (params_.kind == InsetSpaceParams::CUSTOM_PROTECTED) {
+                       pi.pain.line(x0, y1 + 1 , x2 + 1, y2, Color_latex);
+                       pi.pain.line(x2 + 1, y2 + 1 , x0, y0, Color_latex);
+                       pi.pain.line(x1 + 1, y1 + 1 , x3, y2, Color_latex);
+                       pi.pain.line(x3, y2 + 1 , x1 + 1, y0, Color_latex);
+                       pi.pain.line(x2, y2 , x3, y2, Color_latex);
                }
                return;
        }