X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathRoot.cpp;h=d48eeece0e3beb40c1b7442aa639109376447a26;hb=58ab972f714309aa87e7d956ceda00e18337875f;hp=5442fd1be4d1b41e6478c0d3c609eb25e3906045;hpb=96860ffe93637bd7698706c3bb85b65bd0d8a979;p=lyx.git diff --git a/src/mathed/InsetMathRoot.cpp b/src/mathed/InsetMathRoot.cpp index 5442fd1be4..d48eeece0e 100644 --- a/src/mathed/InsetMathRoot.cpp +++ b/src/mathed/InsetMathRoot.cpp @@ -22,48 +22,47 @@ namespace lyx { -using std::max; -using std::auto_ptr; - - InsetMathRoot::InsetMathRoot() : InsetMathNest(2) {} -auto_ptr InsetMathRoot::doClone() const +Inset * InsetMathRoot::clone() const { - return auto_ptr(new InsetMathRoot(*this)); + return new InsetMathRoot(*this); } -bool InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathRoot::metrics(MetricsInfo & mi, Dimension & dim) const { + using std::max; InsetMathNest::metrics(mi); - dim.asc = max(cell(0).ascent() + 5, cell(1).ascent()) + 2; - dim.des = max(cell(0).descent() - 5, cell(1).descent()) + 2; - dim.wid = cell(0).width() + cell(1).width() + 10; + Dimension const & dim0 = cell(0).dimension(*mi.base.bv); + Dimension const & dim1 = cell(1).dimension(*mi.base.bv); + dim.asc = max(dim0.ascent() + 5, dim1.ascent()) + 2; + dim.des = max(dim0.descent() - 5, dim1.descent()) + 2; + dim.wid = dim0.width() + dim1.width() + 10; metricsMarkers(dim); - if (dim_ == dim) - return false; - dim_ = dim; - return true; + // Cache the inset dimension. + setDimCache(mi, dim); } void InsetMathRoot::draw(PainterInfo & pi, int x, int y) const { - int const w = cell(0).width(); + Dimension const & dim0 = cell(0).dimension(*pi.base.bv); + int const w = dim0.width(); // the "exponent" - cell(0).draw(pi, x, y - 5 - cell(0).descent()); + cell(0).draw(pi, x, y - 5 - dim0.descent()); // the "base" cell(1).draw(pi, x + w + 8, y); - int const a = dim_.ascent(); - int const d = dim_.descent(); + Dimension const dim = dimension(*pi.base.bv); + int const a = dim.ascent(); + int const d = dim.descent(); int xp[4]; int yp[4]; - pi.pain.line(x + dim_.width(), y - a + 1, + pi.pain.line(x + dim.width(), y - a + 1, x + w + 4, y - a + 1, Color::math); xp[0] = x + w + 4; yp[0] = y - a + 1; xp[1] = x + w; yp[1] = y + d;