2 * \file InsetMathFrameBox.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "InsetMathFrameBox.h"
16 #include "MathStream.h"
17 #include "MathSupport.h"
18 #include "MetricsInfo.h"
20 #include "frontends/Painter.h"
25 InsetMathFrameBox::InsetMathFrameBox()
30 Inset * InsetMathFrameBox::clone() const
32 return new InsetMathFrameBox(*this);
36 void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
38 FontSetChanger dummy(mi.base, "textnormal");
39 w_ = mathed_char_width(mi.base.font, '[');
40 InsetMathNest::metrics(mi);
41 dim = cell(0).dimension(*mi.base.bv);
42 dim += cell(1).dimension(*mi.base.bv);
43 dim += cell(2).dimension(*mi.base.bv);
45 // Cache the inset dimension.
50 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
52 FontSetChanger dummy(pi.base, "textnormal");
53 Dimension const dim = dimension(*pi.base.bv);
54 pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
55 dim.width() - 2, dim.height() - 2, Color_foreground);
57 BufferView const & bv = *pi.base.bv;
59 drawStrBlack(pi, x, y, from_ascii("["));
61 cell(0).draw(pi, x, y);
62 x += cell(0).dimension(bv).wid;
63 drawStrBlack(pi, x, y, from_ascii("]"));
66 drawStrBlack(pi, x, y, from_ascii("["));
68 cell(1).draw(pi, x, y);
69 x += cell(1).dimension(bv).wid;
70 drawStrBlack(pi, x, y, from_ascii("]"));
73 cell(2).draw(pi, x, y);
74 drawMarkers(pi, x, y);
78 void InsetMathFrameBox::write(WriteStream & os) const
81 os << '[' << cell(0) << ']';
83 os << '[' << cell(1) << ']';
84 os << '{' << cell(2) << '}';
88 void InsetMathFrameBox::normalize(NormalStream & os) const
90 os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';