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"
18 #include "frontends/Painter.h"
23 InsetMathFrameBox::InsetMathFrameBox()
28 Inset * InsetMathFrameBox::clone() const
30 return new InsetMathFrameBox(*this);
34 void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const
36 FontSetChanger dummy(mi.base, "textnormal");
37 w_ = mathed_char_width(mi.base.font, '[');
38 InsetMathNest::metrics(mi);
39 dim = cell(0).dimension(*mi.base.bv);
40 dim += cell(1).dimension(*mi.base.bv);
41 dim += cell(2).dimension(*mi.base.bv);
43 // Cache the inset dimension.
48 void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const
50 FontSetChanger dummy(pi.base, "textnormal");
51 Dimension const dim = dimension(*pi.base.bv);
52 pi.pain.rectangle(x + 1, y - dim.ascent() + 1,
53 dim.width() - 2, dim.height() - 2, Color::foreground);
55 BufferView const & bv = *pi.base.bv;
57 drawStrBlack(pi, x, y, from_ascii("["));
59 cell(0).draw(pi, x, y);
60 x += cell(0).dimension(bv).wid;
61 drawStrBlack(pi, x, y, from_ascii("]"));
64 drawStrBlack(pi, x, y, from_ascii("["));
66 cell(1).draw(pi, x, y);
67 x += cell(1).dimension(bv).wid;
68 drawStrBlack(pi, x, y, from_ascii("]"));
71 cell(2).draw(pi, x, y);
72 drawMarkers(pi, x, y);
76 void InsetMathFrameBox::write(WriteStream & os) const
79 os << '[' << cell(0) << ']';
81 os << '[' << cell(1) << ']';
82 os << '{' << cell(2) << '}';
86 void InsetMathFrameBox::normalize(NormalStream & os) const
88 os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';