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"
16 #include "BufferView.h"
18 #include "bufferparams.h"
21 #include "metricsinfo.h"
22 #include "output_latex.h"
23 #include "outputparams.h"
24 #include "paragraph.h"
36 InsetMathMBox::InsetMathMBox(BufferView & bv)
37 : text_(&bv), bv_(&bv)
39 text_.paragraphs().clear();
40 text_.paragraphs().push_back(Paragraph());
41 text_.paragraphs().back().
42 layout(bv.buffer()->params().getLyXTextClass().defaultLayout());
43 text_.redoParagraph(0);
47 auto_ptr<InsetBase> InsetMathMBox::doClone() const
49 return auto_ptr<InsetBase>(new InsetMathMBox(*this));
53 void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
55 text_.metrics(mi, dim);
61 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
63 text_.draw(pi, x + 1, y);
64 drawMarkers(pi, x, y);
68 void InsetMathMBox::write(WriteStream & ws) const
73 OutputParams runparams;
74 latexParagraphs(*bv_->buffer(), text_.paragraphs(),
75 ws.os(), texrow, runparams);
76 ws.addlines(texrow.rows());
80 std::ostringstream os;
81 text_.write(*bv_->buffer(), os);
82 ws.os() << from_utf8(os.str());
88 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
89 OutputParams const & runparams) const
93 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
99 void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
101 text_.dispatch(cur, cmd);
105 LyXText * InsetMathMBox::getText(int) const
111 void InsetMathMBox::cursorPos(BufferView const & bv,
112 CursorSlice const & sl, bool boundary, int & x, int & y) const
114 x = text_.cursorX(sl, boundary);
115 y = text_.cursorY(sl, boundary);
119 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
121 text_.drawSelection(pi, x, y);