X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathFrameBox.cpp;h=90bcacdc5ee34165f5cc48ce57e20abb9e653ade;hb=58ab972f714309aa87e7d956ceda00e18337875f;hp=5bd9b9302e9e6e321c1e4bae668e4dd816a2c65f;hpb=5008ee540f84715cd10e87f3fa0cd5dc7b974784;p=lyx.git diff --git a/src/mathed/InsetMathFrameBox.cpp b/src/mathed/InsetMathFrameBox.cpp index 5bd9b9302e..90bcacdc5e 100644 --- a/src/mathed/InsetMathFrameBox.cpp +++ b/src/mathed/InsetMathFrameBox.cpp @@ -20,54 +20,51 @@ namespace lyx { -using std::auto_ptr; - - InsetMathFrameBox::InsetMathFrameBox() : InsetMathNest(3) {} -auto_ptr InsetMathFrameBox::doClone() const +Inset * InsetMathFrameBox::clone() const { - return auto_ptr(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, Color::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;