2 * \file math_mboxinset.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 "math_mboxinset.h"
14 #include "math_data.h"
15 #include "math_mathmlstream.h"
17 #include "BufferView.h"
19 #include "bufferparams.h"
21 #include "metricsinfo.h"
22 #include "output_latex.h"
23 #include "outputparams.h"
24 #include "paragraph.h"
31 MathMBoxInset::MathMBoxInset(BufferView & bv)
32 : text_(&bv), bv_(&bv)
34 text_.paragraphs().clear();
35 text_.paragraphs().push_back(Paragraph());
36 text_.paragraphs().back().
37 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
38 text_.redoParagraph(0);
42 auto_ptr<InsetBase> MathMBoxInset::clone() const
44 return auto_ptr<InsetBase>(new MathMBoxInset(*this));
48 void MathMBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const
50 text_.metrics(mi, dim);
56 void MathMBoxInset::draw(PainterInfo & pi, int x, int y) const
58 text_.draw(pi, x + 1, y - text_.ascent());
59 drawMarkers(pi, x, y);
63 void MathMBoxInset::write(WriteStream & ws) const
68 OutputParams runparams;
69 latexParagraphs(*bv_->buffer(), text_.paragraphs(),
70 ws.os(), texrow, runparams);
71 ws.addlines(texrow.rows());
75 text_.write(*bv_->buffer(), ws.os());
81 int MathMBoxInset::latex(Buffer const & buf, std::ostream & os,
82 OutputParams const & runparams) const
86 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
92 void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
94 text_.dispatch(cur, cmd);
98 LyXText * MathMBoxInset::getText(int) const
104 void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
106 x = text_.cursorX(cur);
107 y = text_.cursorY(cur);