mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-10 20:04:46 +00:00
* 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
This commit is contained in:
parent
0cdf6c006b
commit
a085842f14
@ -138,40 +138,58 @@ InsetMathFrameBox::InsetMathFrameBox()
|
|||||||
void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||||
{
|
{
|
||||||
FontSetChanger dummy(mi.base, "textnormal");
|
FontSetChanger dummy(mi.base, "textnormal");
|
||||||
w_ = mathed_char_width(mi.base.font, '[');
|
|
||||||
InsetMathNest::metrics(mi);
|
Dimension wdim;
|
||||||
dim = cell(0).dimension(*mi.base.bv);
|
static docstring bracket = from_ascii("[");
|
||||||
dim += cell(1).dimension(*mi.base.bv);
|
mathed_string_dim(mi.base.font, bracket, wdim);
|
||||||
dim += cell(2).dimension(*mi.base.bv);
|
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);
|
metricsMarkers(dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
|
void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
|
||||||
{
|
{
|
||||||
|
drawMarkers(pi, x, y);
|
||||||
|
|
||||||
FontSetChanger dummy(pi.base, "textnormal");
|
FontSetChanger dummy(pi.base, "textnormal");
|
||||||
Dimension const dim = dimension(*pi.base.bv);
|
Dimension const dim = dimension(*pi.base.bv);
|
||||||
|
int w = mathed_char_width(pi.base.font, '[');
|
||||||
|
|
||||||
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
|
||||||
dim.width() - 2, dim.height() - 2, Color_foreground);
|
dim.width() - 2, dim.height() - 2, Color_foreground);
|
||||||
|
|
||||||
x += 5;
|
x += 5;
|
||||||
BufferView const & bv = *pi.base.bv;
|
BufferView const & bv = *pi.base.bv;
|
||||||
|
|
||||||
drawStrBlack(pi, x, y, from_ascii("["));
|
drawStrBlack(pi, x, y, from_ascii("["));
|
||||||
x += w_;
|
x += w;
|
||||||
cell(0).draw(pi, x, y);
|
cell(0).draw(pi, x, y);
|
||||||
x += cell(0).dimension(bv).wid;
|
x += cell(0).dimension(bv).wid;
|
||||||
drawStrBlack(pi, x, y, from_ascii("]"));
|
drawStrBlack(pi, x, y, from_ascii("]"));
|
||||||
x += w_ + 4;
|
x += w + 4;
|
||||||
|
|
||||||
drawStrBlack(pi, x, y, from_ascii("["));
|
drawStrBlack(pi, x, y, from_ascii("["));
|
||||||
x += w_;
|
x += w;
|
||||||
cell(1).draw(pi, x, y);
|
cell(1).draw(pi, x, y);
|
||||||
x += cell(1).dimension(bv).wid;
|
x += cell(1).dimension(bv).wid;
|
||||||
drawStrBlack(pi, x, y, from_ascii("]"));
|
drawStrBlack(pi, x, y, from_ascii("]"));
|
||||||
x += w_ + 4;
|
x += w + 4;
|
||||||
|
|
||||||
cell(2).draw(pi, x, y);
|
cell(2).draw(pi, x, y);
|
||||||
drawMarkers(pi, x, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,8 +84,6 @@ public:
|
|||||||
mode_type currentMode() const { return TEXT_MODE; }
|
mode_type currentMode() const { return TEXT_MODE; }
|
||||||
private:
|
private:
|
||||||
Inset * clone() const { return new InsetMathFrameBox(*this); }
|
Inset * clone() const { return new InsetMathFrameBox(*this); }
|
||||||
/// width of '[' in current font
|
|
||||||
mutable int w_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user