2 * \file InsetMathMBox.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 "InsetMathMBox.h"
15 #include "MathStream.h"
17 #include "BufferView.h"
19 #include "BufferParams.h"
22 #include "MetricsInfo.h"
23 #include "output_latex.h"
24 #include "OutputParams.h"
25 #include "Paragraph.h"
27 #include "TextMetrics.h"
35 InsetMathMBox::InsetMathMBox()
37 text_.paragraphs().clear();
38 text_.paragraphs().push_back(Paragraph());
42 InsetMathMBox::InsetMathMBox(LayoutPtr const & layout)
44 text_.paragraphs().clear();
45 text_.paragraphs().push_back(Paragraph());
46 text_.paragraphs().back().layout(layout);
50 Inset * InsetMathMBox::clone() const
52 return new InsetMathMBox(*this);
56 void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
58 TextMetrics & tm = mi.base.bv->textMetrics(&text_);
64 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
66 pi.base.bv->textMetrics(&text_).draw(pi, x + 1, y);
67 drawMarkers(pi, x, y);
71 void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const
76 OutputParams runparams(&buf.params().encoding());
77 latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams);
78 ws.addlines(texrow.rows());
82 std::ostringstream os;
84 ws.os() << from_utf8(os.str());
90 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
91 OutputParams const & runparams) const
95 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
101 void InsetMathMBox::doDispatch(Cursor & cur, FuncRequest & cmd)
103 text_.dispatch(cur, cmd);
107 Text * InsetMathMBox::getText(int) const
113 void InsetMathMBox::cursorPos(BufferView const & bv,
114 CursorSlice const & sl, bool boundary, int & x, int & y) const
116 x = bv.textMetrics(&text_).cursorX(sl, boundary);
117 y = bv.textMetrics(&text_).cursorY(sl, boundary);