From a085842f14c47e3c222ed2d887595d6cc6a61dd6 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Thu, 28 Feb 2008 12:45:36 +0000 Subject: [PATCH] * fixing the framebox part of http://bugzilla.lyx.org/show_bug.cgi?id=2461: "wrong cursor position in \framebox and \makebox environment" The drawing and metrics calculations were totally broken. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23319 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/InsetMathBox.cpp | 38 +++++++++++++++++++++++++++---------- src/mathed/InsetMathBox.h | 2 -- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index 641f50e370..e8fed0dd53 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -138,40 +138,58 @@ InsetMathFrameBox::InsetMathFrameBox() 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).dimension(*mi.base.bv); - dim += cell(1).dimension(*mi.base.bv); - dim += cell(2).dimension(*mi.base.bv); + + Dimension wdim; + static docstring bracket = from_ascii("["); + mathed_string_dim(mi.base.font, bracket, wdim); + int w = wdim.wid; + + Dimension dim0; + Dimension dim1; + Dimension dim2; + cell(0).metrics(mi, dim0); + cell(1).metrics(mi, dim1); + cell(2).metrics(mi, dim2); + + dim.wid = 5 + w + dim0.wid + w + 4 + w + dim1.wid + w + 4 + dim2.wid + 5; + dim.asc = std::max(std::max(wdim.asc, dim0.asc), std::max(dim1.asc, dim2.asc)); + dim.des = std::max(std::max(wdim.des, dim0.des), std::max(dim1.des, dim2.des)); + dim.asc += 3; + dim.des += 3; + metricsMarkers(dim); } void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const { + drawMarkers(pi, x, y); + FontSetChanger dummy(pi.base, "textnormal"); Dimension const dim = dimension(*pi.base.bv); + int w = mathed_char_width(pi.base.font, '['); + 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_; + x += w; cell(0).draw(pi, x, y); x += cell(0).dimension(bv).wid; drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 4; + x += w + 4; drawStrBlack(pi, x, y, from_ascii("[")); - x += w_; + x += w; cell(1).draw(pi, x, y); x += cell(1).dimension(bv).wid; drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 4; + x += w + 4; cell(2).draw(pi, x, y); - drawMarkers(pi, x, y); } diff --git a/src/mathed/InsetMathBox.h b/src/mathed/InsetMathBox.h index 9b40ba0951..b68280aaac 100644 --- a/src/mathed/InsetMathBox.h +++ b/src/mathed/InsetMathBox.h @@ -84,8 +84,6 @@ public: mode_type currentMode() const { return TEXT_MODE; } private: Inset * clone() const { return new InsetMathFrameBox(*this); } - /// width of '[' in current font - mutable int w_; };