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"
31 //using support::odocstream;
37 InsetMathMBox::InsetMathMBox()
39 text_.paragraphs().clear();
40 text_.paragraphs().push_back(Paragraph());
44 InsetMathMBox::InsetMathMBox(LayoutPtr const & layout)
46 text_.paragraphs().clear();
47 text_.paragraphs().push_back(Paragraph());
48 text_.paragraphs().back().layout(layout);
52 auto_ptr<Inset> InsetMathMBox::doClone() const
54 return auto_ptr<Inset>(new InsetMathMBox(*this));
58 bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
60 TextMetrics & tm = mi.base.bv->textMetrics(&text_);
70 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
72 text_.draw(pi, x + 1, y);
73 drawMarkers(pi, x, y);
77 void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const
82 OutputParams runparams(&buf.params().encoding());
83 latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams);
84 ws.addlines(texrow.rows());
88 std::ostringstream os;
90 ws.os() << from_utf8(os.str());
96 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
97 OutputParams const & runparams) const
101 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
103 return texrow.rows();
107 void InsetMathMBox::doDispatch(Cursor & cur, FuncRequest & cmd)
109 text_.dispatch(cur, cmd);
113 Text * InsetMathMBox::getText(int) const
119 void InsetMathMBox::cursorPos(BufferView const & bv,
120 CursorSlice const & sl, bool boundary, int & x, int & y) const
122 x = text_.cursorX(bv, sl, boundary);
123 y = text_.cursorY(bv, sl, boundary);
127 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
129 text_.drawSelection(pi, x, y);