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"
15 #include "MathStream.h"
16 #include "MathSupport.h"
17 #include "frontends/Painter.h"
22 InsetMathFrameBox::InsetMathFrameBox()
27 Inset * InsetMathFrameBox::clone() const
29 return new InsetMathFrameBox(*this);
33 void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
35 FontSetChanger dummy(mi.base, "textnormal");
36 w_ = mathed_char_width(mi.base.font, '[');
37 InsetMathNest::metrics(mi);
38 dim = cell(0).dimension(*mi.base.bv);
39 dim += cell(1).dimension(*mi.base.bv);
40 dim += cell(2).dimension(*mi.base.bv);
42 // Cache the inset dimension.
47 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
49 FontSetChanger dummy(pi.base, "textnormal");
50 Dimension const dim = dimension(*pi.base.bv);
51 pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
52 dim.width() - 2, dim.height() - 2, Color_foreground);
54 BufferView const & bv = *pi.base.bv;
56 drawStrBlack(pi, x, y, from_ascii("["));
58 cell(0).draw(pi, x, y);
59 x += cell(0).dimension(bv).wid;
60 drawStrBlack(pi, x, y, from_ascii("]"));
63 drawStrBlack(pi, x, y, from_ascii("["));
65 cell(1).draw(pi, x, y);
66 x += cell(1).dimension(bv).wid;
67 drawStrBlack(pi, x, y, from_ascii("]"));
70 cell(2).draw(pi, x, y);
71 drawMarkers(pi, x, y);
75 void InsetMathFrameBox::write(WriteStream & os) const
78 os << '[' << cell(0) << ']';
80 os << '[' << cell(1) << ']';
81 os << '{' << cell(2) << '}';
85 void InsetMathFrameBox::normalize(NormalStream & os) const
87 os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';