]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathPhantom.cpp
add busy.gif to resources (in line with cmake)
[lyx.git] / src / mathed / InsetMathPhantom.cpp
index 4e18c7661e2d41ab8523d20057fcd46109727b46..d6cd1b24469fa1282ed66cc4eca9373fe0e27706 100644 (file)
 #include <config.h>
 
 #include "InsetMathPhantom.h"
-#include "MathStream.h"
-#include "MathStream.h"
-
-#include "Color.h"
 
+#include "MathStream.h"
 #include "frontends/Painter.h"
 
-#include "support/std_ostream.h"
-
+#include <ostream>
 
 namespace lyx {
 
 
-InsetMathPhantom::InsetMathPhantom(Kind k)
-       : InsetMathNest(1), kind_(k)
+InsetMathPhantom::InsetMathPhantom(Buffer * buf, Kind k)
+       : InsetMathNest(buf, 1), kind_(k)
 {}
 
 
-std::auto_ptr<Inset> InsetMathPhantom::doClone() const
+Inset * InsetMathPhantom::clone() const
 {
-       return std::auto_ptr<Inset>(new InsetMathPhantom(*this));
+       return new InsetMathPhantom(*this);
 }
 
 
-bool InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathPhantom::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        cell(0).metrics(mi, dim);
        metricsMarkers(dim);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
 }
 
 
@@ -51,10 +43,11 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
        static int const arrow_size = 4;
 
        // We first draw the text and then an arrow
-       Color_color const origcol = pi.base.font.color();
-       pi.base.font.setColor(Color::special);
+       ColorCode const origcol = pi.base.font.color();
+       pi.base.font.setColor(Color_special);
        cell(0).draw(pi, x + 1, y);
        pi.base.font.setColor(origcol);
+       Dimension const dim = dimension(*pi.base.bv);
 
        if (kind_ == phantom || kind_ == vphantom) {
                // y1---------
@@ -69,25 +62,25 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
                //         /  |  \.
                //        x1  x2 x3
 
-               int const x2 = x + dim_.wid / 2;
+               int const x2 = x + dim.wid / 2;
                int const x1 = x2 - arrow_size;
                int const x3 = x2 + arrow_size;
 
-               int const y1 = y - dim_.asc;
+               int const y1 = y - dim.asc;
                int const y2 = y1 + arrow_size;
-               int const y4 = y + dim_.des;
+               int const y4 = y + dim.des;
                int const y3 = y4 - arrow_size;
 
                // top arrow
-               pi.pain.line(x2, y1, x1, y2, Color::added_space);
-               pi.pain.line(x2, y1, x3, y2, Color::added_space);
+               pi.pain.line(x2, y1, x1, y2, Color_added_space);
+               pi.pain.line(x2, y1, x3, y2, Color_added_space);
 
                // bottom arrow
-               pi.pain.line(x2, y4, x1, y3, Color::added_space);
-               pi.pain.line(x2, y4, x3, y3, Color::added_space);
+               pi.pain.line(x2, y4, x1, y3, Color_added_space);
+               pi.pain.line(x2, y4, x3, y3, Color_added_space);
 
                // joining line
-               pi.pain.line(x2, y1, x2, y4, Color::added_space);
+               pi.pain.line(x2, y1, x2, y4, Color_added_space);
        }
 
        if (kind_ == phantom || kind_ == hphantom) {
@@ -101,23 +94,23 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
 
                int const x1 = x;
                int const x2 = x + arrow_size;
-               int const x4 = x + dim_.wid;
+               int const x4 = x + dim.wid;
                int const x3 = x4 - arrow_size;
 
-               int const y2 = y + (dim_.des - dim_.asc) / 2;
+               int const y2 = y + (dim.des - dim.asc) / 2;
                int const y1 = y2 - arrow_size;
                int const y3 = y2 + arrow_size;
 
                // left arrow
-               pi.pain.line(x1, y2, x2, y3, Color::added_space);
-               pi.pain.line(x1, y2, x2, y1, Color::added_space);
+               pi.pain.line(x1, y2, x2, y3, Color_added_space);
+               pi.pain.line(x1, y2, x2, y1, Color_added_space);
 
                // right arrow
-               pi.pain.line(x4, y2, x3, y3, Color::added_space);
-               pi.pain.line(x4, y2, x3, y1, Color::added_space);
+               pi.pain.line(x4, y2, x3, y3, Color_added_space);
+               pi.pain.line(x4, y2, x3, y1, Color_added_space);
 
                // joining line
-               pi.pain.line(x1, y2, x4, y2, Color::added_space);
+               pi.pain.line(x1, y2, x4, y2, Color_added_space);
        }
 
        drawMarkers(pi, x, y);
@@ -126,6 +119,7 @@ void InsetMathPhantom::draw(PainterInfo & pi, int x, int y) const
 
 void InsetMathPhantom::write(WriteStream & os) const
 {
+       MathEnsurer ensurer(os);
        switch (kind_) {
        case phantom:
                os << "\\phantom{";