"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
This commit is contained in:
Stefan Schimanski 2008-02-28 12:45:36 +00:00
parent 0cdf6c006b
commit a085842f14
2 changed files with 28 additions and 12 deletions

View File

@ -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);
}

View File

@ -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_;
};