2 * \file InsetMathMBox.C
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(LyXLayout_ptr const & layout)
39 text_.paragraphs().clear();
40 text_.paragraphs().push_back(Paragraph());
41 text_.paragraphs().back().layout(layout);
45 auto_ptr<InsetBase> InsetMathMBox::doClone() const
47 return auto_ptr<InsetBase>(new InsetMathMBox(*this));
51 bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
53 TextMetrics & tm = mi.base.bv->textMetrics(&text_);
63 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
65 text_.draw(pi, x + 1, y);
66 drawMarkers(pi, x, y);
70 void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const
75 OutputParams runparams;
76 latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams);
77 ws.addlines(texrow.rows());
81 std::ostringstream os;
83 ws.os() << from_utf8(os.str());
89 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
90 OutputParams const & runparams) const
94 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
100 void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
102 text_.dispatch(cur, cmd);
106 LyXText * InsetMathMBox::getText(int) const
112 void InsetMathMBox::cursorPos(BufferView const & bv,
113 CursorSlice const & sl, bool boundary, int & x, int & y) const
115 x = text_.cursorX(bv, sl, boundary);
116 y = text_.cursorY(bv, sl, boundary);
120 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
122 text_.drawSelection(pi, x, y);