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 bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const
55 text_.metrics(mi, dim);
64 void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const
66 text_.draw(pi, x + 1, y);
67 drawMarkers(pi, x, y);
71 void InsetMathMBox::write(WriteStream & ws) const
76 OutputParams runparams;
77 latexParagraphs(*bv_->buffer(), text_.paragraphs(),
78 ws.os(), texrow, runparams);
79 ws.addlines(texrow.rows());
83 std::ostringstream os;
84 text_.write(*bv_->buffer(), os);
85 ws.os() << from_utf8(os.str());
91 int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
92 OutputParams const & runparams) const
96 latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
102 void InsetMathMBox::doDispatch(LCursor & cur, FuncRequest & cmd)
104 text_.dispatch(cur, cmd);
108 LyXText * InsetMathMBox::getText(int) const
114 void InsetMathMBox::cursorPos(BufferView const & bv,
115 CursorSlice const & sl, bool boundary, int & x, int & y) const
117 x = text_.cursorX(sl, boundary);
118 y = text_.cursorY(sl, boundary);
122 void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const
124 text_.drawSelection(pi, x, y);