]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathBrace.cpp
Change the interface to a paragraph's layout. We still store a LayoutPtr, but now...
[lyx.git] / src / mathed / InsetMathBrace.cpp
index e096c7a3ce3bf6fff03e084d72b147a55fc72617..d5b6da44dc768f3cb3f09a8fea6a8ba4570eaff4 100644 (file)
 #include <config.h>
 
 #include "InsetMathBrace.h"
+
 #include "MathData.h"
 #include "MathStream.h"
 #include "MathSupport.h"
-#include "LColor.h"
+#include "MetricsInfo.h"
 
 #include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
-#include "support/std_ostream.h"
-
-namespace lyx {
+#include <ostream>
 
-using std::max;
-using std::auto_ptr;
+using namespace std;
 
+namespace lyx {
 
 InsetMathBrace::InsetMathBrace()
        : InsetMathNest(1)
@@ -39,35 +38,33 @@ InsetMathBrace::InsetMathBrace(MathData const & ar)
 }
 
 
-auto_ptr<InsetBase> InsetMathBrace::doClone() const
+Inset * InsetMathBrace::clone() const
 {
-       return auto_ptr<InsetBase>(new InsetMathBrace(*this));
+       return new InsetMathBrace(*this);
 }
 
 
-bool InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathBrace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       cell(0).metrics(mi);
+       Dimension dim0;
+       cell(0).metrics(mi, dim0);
        Dimension t = theFontMetrics(mi.base.font).dimension('{');
-       dim.asc = max(cell(0).ascent(), t.asc);
-       dim.des = max(cell(0).descent(), t.des);
-       dim.wid = cell(0).width() + 2 * t.wid;
+       dim.asc = max(dim0.asc, t.asc);
+       dim.des = max(dim0.des, t.des);
+       dim.wid = dim0.width() + 2 * t.wid;
        metricsMarkers(dim);
-       if (dim_ == dim)
-               return false;
-       dim_ = dim;
-       return true;
 }
 
 
 void InsetMathBrace::draw(PainterInfo & pi, int x, int y) const
 {
-       LyXFont font = pi.base.font;
-       font.setColor(LColor::latex);
+       FontInfo font = pi.base.font;
+       font.setColor(Color_latex);
        Dimension t = theFontMetrics(font).dimension('{');
        pi.pain.text(x, y, '{', font);
        cell(0).draw(pi, x + t.wid, y);
-       pi.pain.text(x + t.wid + cell(0).width(), y, '}', font);
+       Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
+       pi.pain.text(x + t.wid + dim0.width(), y, '}', font);
        drawMarkers(pi, x, y);
 }