]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathFrameBox.cpp
last commit was incomplete... not sure how I managed this..
[lyx.git] / src / mathed / InsetMathFrameBox.cpp
index e77fe38fc6dd276fca4a7916d77eefe43700a382..90bcacdc5ee34165f5cc48ce57e20abb9e653ade 100644 (file)
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathSupport.h"
-#include "LColor.h"
+#include "Color.h"
 #include "frontends/Painter.h"
 
 
 namespace lyx {
 
-using std::auto_ptr;
-
-
 InsetMathFrameBox::InsetMathFrameBox()
        : InsetMathNest(3)
 {}
 
 
-auto_ptr<InsetBase> InsetMathFrameBox::doClone() const
+Inset * InsetMathFrameBox::clone() const
 {
-       return auto_ptr<InsetBase>(new InsetMathFrameBox(*this));
+       return new InsetMathFrameBox(*this);
 }
 
 
-bool InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        FontSetChanger dummy(mi.base, "textnormal");
        w_ = mathed_char_width(mi.base.font, '[');
        InsetMathNest::metrics(mi);
-       dim  = cell(0).dim();
-       dim += cell(1).dim();
-       dim += cell(2).dim();
+       dim  = cell(0).dimension(*mi.base.bv);
+       dim += cell(1).dimension(*mi.base.bv);
+       dim += cell(2).dimension(*mi.base.bv);
        metricsMarkers(dim);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
+       // Cache the inset dimension. 
+       setDimCache(mi, dim);
 }
 
 
 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
 {
        FontSetChanger dummy(pi.base, "textnormal");
-       pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
-               dim_.width() - 2, dim_.height() - 2, LColor::foreground);
+       Dimension const dim = dimension(*pi.base.bv);
+       pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
+               dim.width() - 2, dim.height() - 2, Color::foreground);
        x += 5;
+       BufferView const & bv = *pi.base.bv;
 
        drawStrBlack(pi, x, y, from_ascii("["));
        x += w_;
        cell(0).draw(pi, x, y);
-       x += cell(0).width();
+       x += cell(0).dimension(bv).wid;
        drawStrBlack(pi, x, y, from_ascii("]"));
        x += w_ + 4;
 
        drawStrBlack(pi, x, y, from_ascii("["));
        x += w_;
        cell(1).draw(pi, x, y);
-       x += cell(1).width();
+       x += cell(1).dimension(bv).wid;
        drawStrBlack(pi, x, y, from_ascii("]"));
        x += w_ + 4;