]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
* src/paragraph_funcs.cpp (breakParagraph): change parameter 'flag' to
[lyx.git] / src / insets / InsetVSpace.cpp
index fb0c8dbe875b27cf7bd626abbcd368ca02631f88..0d630b5cdbf2bdfc3167e5c71862ef6833a8f901 100644 (file)
@@ -20,7 +20,7 @@
 #include "gettext.h"
 #include "Color.h"
 #include "Lexer.h"
-#include "LyXText.h"
+#include "Text.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
 
@@ -57,9 +57,9 @@ InsetVSpace::~InsetVSpace()
 }
 
 
-std::auto_ptr<InsetBase> InsetVSpace::doClone() const
+Inset * InsetVSpace::clone() const
 {
-       return std::auto_ptr<InsetBase>(new InsetVSpace(*this));
+       return new InsetVSpace(*this);
 }
 
 
@@ -73,11 +73,12 @@ void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
        }
 
        case LFUN_MOUSE_RELEASE:
-               InsetVSpaceMailer(*this).showDialog(&cur.bv());
+               if (!cur.selection())
+                       InsetVSpaceMailer(*this).showDialog(&cur.bv());
                break;
 
        default:
-               InsetBase::doDispatch(cur, cmd);
+               Inset::doDispatch(cur, cmd);
                break;
        }
 }
@@ -117,13 +118,13 @@ int const arrow_size = 4;
 }
 
 
-bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        int height = 3 * arrow_size;
        if (space_.length().len().value() >= 0.0)
                height = max(height, space_.inPixels(*mi.base.bv));
 
-       LyXFont font;
+       Font font;
        font.decSize();
        font.decSize();
 
@@ -137,20 +138,17 @@ bool InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.asc = height / 2 + (a - d) / 2; // align cursor with the
        dim.des = height - dim.asc;         // label text
        dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w;
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
+       // Cache the inset dimension. 
+       setDimCache(mi, dim);
 }
 
 
 void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 {
-       setPosCache(pi, x, y);
-
+       Dimension const dim = dimension(*pi.base.bv);
        x += ADD_TO_VSPACE_WIDTH;
-
-       int const start = y - dim_.asc;
-       int const end   = y + dim_.des;
+       int const start = y - dim.asc;
+       int const end   = y + dim.des;
 
        // y-values for top arrow
        int ty1, ty2;
@@ -178,7 +176,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
        int a = 0;
        int d = 0;
 
-       LyXFont font;
+       Font font;
        font.setColor(Color::added_space);
        font.decSize();
        font.decSize();
@@ -203,7 +201,7 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 
 
 int InsetVSpace::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const &) const
+                      OutputParams const &) const
 {
        os << from_ascii(space_.asLatexCommand(buf.params())) << '\n';
        return 1;
@@ -211,7 +209,7 @@ int InsetVSpace::latex(Buffer const & buf, odocstream & os,
 
 
 int InsetVSpace::plaintext(Buffer const &, odocstream & os,
-                           OutputParams const &) const
+                          OutputParams const &) const
 {
        os << "\n\n";
        return PLAINTEXT_NEWLINE;
@@ -219,7 +217,7 @@ int InsetVSpace::plaintext(Buffer const &, odocstream & os,
 
 
 int InsetVSpace::docbook(Buffer const &, odocstream & os,
-                         OutputParams const &) const
+                        OutputParams const &) const
 {
        os << '\n';
        return 1;