]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
Change string
[lyx.git] / src / insets / InsetVSpace.cpp
index 2e8d392a7a91b35c45a3a6b4cf9830b1b06678dc..42daae26750f32bfddb0eae6ca816beef3bd131f 100644 (file)
 #include "InsetVSpace.h"
 
 #include "Buffer.h"
-#include "LCursor.h"
+#include "Cursor.h"
+#include "Dimension.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
-#include "gettext.h"
-#include "LColor.h"
-#include "LyXLex.h"
-#include "LyXText.h"
+#include "support/gettext.h"
+#include "Lexer.h"
+#include "Text.h"
 #include "MetricsInfo.h"
 #include "OutputParams.h"
 
 
 #include <sstream>
 
+using namespace std;
 
 namespace lyx {
 
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-using std::string;
-using std::max;
-
-
 namespace {
 
 int const ADD_TO_VSPACE_WIDTH = 5;
@@ -57,13 +51,7 @@ InsetVSpace::~InsetVSpace()
 }
 
 
-std::auto_ptr<InsetBase> InsetVSpace::doClone() const
-{
-       return std::auto_ptr<InsetBase>(new InsetVSpace(*this));
-}
-
-
-void InsetVSpace::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetVSpace::doDispatch(Cursor & cur, FuncRequest & cmd)
 {
        switch (cmd.action) {
 
@@ -73,17 +61,18 @@ void InsetVSpace::doDispatch(LCursor & 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;
        }
 }
 
 
-void InsetVSpace::read(Buffer const &, LyXLex & lex)
+void InsetVSpace::read(Lexer & lex)
 {
        BOOST_ASSERT(lex.isOK());
        string vsp;
@@ -99,7 +88,7 @@ void InsetVSpace::read(Buffer const &, LyXLex & lex)
 }
 
 
-void InsetVSpace::write(Buffer const &, ostream & os) const
+void InsetVSpace::write(ostream & os) const
 {
        os << "VSpace " << space_.asLyXCommand();
 }
@@ -117,13 +106,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;
+       FontInfo font;
        font.decSize();
        font.decSize();
 
@@ -137,20 +126,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,8 +164,8 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
        int a = 0;
        int d = 0;
 
-       LyXFont font;
-       font.setColor(LColor::added_space);
+       FontInfo font;
+       font.setColor(Color_added_space);
        font.decSize();
        font.decSize();
        docstring const lab = label();
@@ -187,39 +173,36 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 
        pi.pain.rectText(x + 2 * arrow_size + 5,
                         start + (end - start) / 2 + (a - d) / 2,
-                        lab, font, LColor::none, LColor::none);
+                        lab, font, Color_none, Color_none);
 
        // top arrow
-       pi.pain.line(x, ty1, midx, ty2, LColor::added_space);
-       pi.pain.line(midx, ty2, rightx, ty1, LColor::added_space);
+       pi.pain.line(x, ty1, midx, ty2, Color_added_space);
+       pi.pain.line(midx, ty2, rightx, ty1, Color_added_space);
 
        // bottom arrow
-       pi.pain.line(x, by1, midx, by2, LColor::added_space);
-       pi.pain.line(midx, by2, rightx, by1, LColor::added_space);
+       pi.pain.line(x, by1, midx, by2, Color_added_space);
+       pi.pain.line(midx, by2, rightx, by1, Color_added_space);
 
        // joining line
-       pi.pain.line(midx, ty2, midx, by2, LColor::added_space);
+       pi.pain.line(midx, ty2, midx, by2, Color_added_space);
 }
 
 
-int InsetVSpace::latex(Buffer const & buf, odocstream & os,
-                       OutputParams const &) const
+int InsetVSpace::latex(odocstream & os, OutputParams const &) const
 {
-       os << from_ascii(space_.asLatexCommand(buf.params())) << '\n';
+       os << from_ascii(space_.asLatexCommand(buffer().params())) << '\n';
        return 1;
 }
 
 
-int InsetVSpace::plaintext(Buffer const &, odocstream & os,
-                           OutputParams const &) const
+int InsetVSpace::plaintext(odocstream & os, OutputParams const &) const
 {
        os << "\n\n";
        return PLAINTEXT_NEWLINE;
 }
 
 
-int InsetVSpace::docbook(Buffer const &, odocstream & os,
-                         OutputParams const &) const
+int InsetVSpace::docbook(odocstream & os, OutputParams const &) const
 {
        os << '\n';
        return 1;
@@ -247,7 +230,7 @@ void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
                return;
 
        istringstream data(in);
-       LyXLex lex(0,0);
+       Lexer lex(0,0);
        lex.setStream(data);
 
        string name;