]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetSpace.cpp
getting rid of more superfluous lyx::support:: statements.
[lyx.git] / src / insets / InsetSpace.cpp
index aeb3dd697ed3cca8ebd80833e6eb265ea8594a0b..5a5b10521033272ca4be98f983b5ac6da041ee5e 100644 (file)
 
 #include "InsetSpace.h"
 
-#include "debug.h"
-#include "LColor.h"
-#include "lyxlex.h"
-#include "metricsinfo.h"
-#include "outputparams.h"
+#include "support/debug.h"
+#include "Dimension.h"
+#include "Lexer.h"
+#include "MetricsInfo.h"
+#include "OutputParams.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
+#include "support/docstream.h"
 
-namespace lyx {
+using namespace std;
 
-using std::string;
-using std::max;
-using std::auto_ptr;
-using std::ostream;
+namespace lyx {
 
 
 InsetSpace::InsetSpace()
@@ -48,21 +46,20 @@ InsetSpace::Kind InsetSpace::kind() const
 }
 
 
-bool InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       frontend::FontMetrics const & fm =
-               theFontMetrics(mi.base.font);
+       frontend::FontMetrics const & fm = theFontMetrics(mi.base.font);
        dim.asc = fm.maxAscent();
        dim.des = fm.maxDescent();
 
        switch (kind_) {
                case THIN:
                case NEGTHIN:
-                    dim.wid = fm.width(char_type('x')) / 3;
+                   dim.wid = fm.width(char_type('x')) / 3;
                        break;
                case PROTECTED:
                case NORMAL:
-                    dim.wid = fm.width(char_type('x'));
+                   dim.wid = fm.width(char_type('x'));
                        break;
                case QUAD:
                        dim.wid = 20;
@@ -75,15 +72,15 @@ bool InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
                        dim.wid = 10;
                        break;
        }
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
+       // Cache the inset dimension. 
+       setDimCache(mi, dim);
 }
 
 
 void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
-       int const w = width();
+       Dimension const dim = dimension(*pi.base.bv);
+       int const w = dim.wid;
        int const h = theFontMetrics(pi.base.font)
                .ascent('x');
        int xp[4], yp[4];
@@ -101,9 +98,9 @@ void InsetSpace::draw(PainterInfo & pi, int x, int y) const
        yp[3] = y - max(h / 4, 1);
 
        if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
-               pi.pain.lines(xp, yp, 4, LColor::latex);
+               pi.pain.lines(xp, yp, 4, Color_latex);
        else
-               pi.pain.lines(xp, yp, 4, LColor::special);
+               pi.pain.lines(xp, yp, 4, Color_special);
 }
 
 
@@ -140,7 +137,7 @@ void InsetSpace::write(Buffer const &, ostream & os) const
 }
 
 
-void InsetSpace::read(Buffer const &, LyXLex & lex)
+void InsetSpace::read(Buffer const &, Lexer & lex)
 {
        lex.next();
        string const command = lex.getString();
@@ -167,7 +164,7 @@ void InsetSpace::read(Buffer const &, LyXLex & lex)
 
 
 int InsetSpace::latex(Buffer const &, odocstream & os,
-                      OutputParams const & runparams) const
+                     OutputParams const & runparams) const
 {
        switch (kind_) {
        case NORMAL:
@@ -200,7 +197,7 @@ int InsetSpace::latex(Buffer const &, odocstream & os,
 
 
 int InsetSpace::plaintext(Buffer const &, odocstream & os,
-                          OutputParams const &) const
+                         OutputParams const &) const
 {
        os << ' ';
        return 1;
@@ -208,7 +205,7 @@ int InsetSpace::plaintext(Buffer const &, odocstream & os,
 
 
 int InsetSpace::docbook(Buffer const &, odocstream & os,
-                        OutputParams const &) const
+                       OutputParams const &) const
 {
        switch (kind_) {
        case NORMAL:
@@ -235,9 +232,9 @@ int InsetSpace::textString(Buffer const & buf, odocstream & os,
 }
 
 
-auto_ptr<InsetBase> InsetSpace::doClone() const
+Inset * InsetSpace::clone() const
 {
-       return auto_ptr<InsetBase>(new InsetSpace(kind_));
+       return new InsetSpace(kind_);
 }