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"
21 #include "MetricsInfo.h"
22 #include "output_latex.h"
23 #include "OutputParams.h"
24 #include "Paragraph.h"
26 #include "TextMetrics.h"
28 #include "support/debug.h"
35 InsetMathMBox::InsetMathMBox(Buffer
* buffer
) : InsetMath(buffer
), text_(buffer
)
37 text_
.paragraphs().clear();
38 text_
.paragraphs().push_back(Paragraph());
42 InsetMathMBox::InsetMathMBox(Buffer
* buffer
, Layout
const & layout
)
43 : InsetMath(buffer
), text_(buffer
)
45 text_
.paragraphs().clear();
46 text_
.paragraphs().push_back(Paragraph());
47 text_
.paragraphs().back().setLayout(layout
);
51 Inset
* InsetMathMBox::clone() const
53 return new InsetMathMBox(*this);
57 void InsetMathMBox::metrics(MetricsInfo
& mi
, Dimension
& dim
) const
59 TextMetrics
& tm
= mi
.base
.bv
->textMetrics(&text_
.text());
65 void InsetMathMBox::draw(PainterInfo
& pi
, int x
, int y
) const
67 pi
.base
.bv
->textMetrics(&text_
.text()).draw(pi
, x
+ 1, y
);
68 drawMarkers(pi
, x
, y
);
72 void InsetMathMBox::write(WriteStream
& ws
) const
77 OutputParams
runparams(&buffer().params().encoding());
78 latexParagraphs(buffer(), text_
.text(), ws
.os(), texrow
, runparams
);
79 ws
.addlines(texrow
.rows());
84 text_
.text().write(os
);
85 ws
.os() << from_utf8(os
.str());
91 int InsetMathMBox::latex(odocstream
& os
, OutputParams
const & runparams
) const
95 latexParagraphs(buffer(), text_
.text(), os
, texrow
, runparams
);
101 void InsetMathMBox::doDispatch(Cursor
& cur
, FuncRequest
& cmd
)
103 text_
.text().dispatch(cur
, cmd
);
107 Text
* InsetMathMBox::getText(int) const
109 return &text_
.text();
113 void InsetMathMBox::cursorPos(BufferView
const & bv
,
114 CursorSlice
const & sl
, bool boundary
, int & x
, int & y
) const
116 x
= bv
.textMetrics(&text_
.text()).cursorX(sl
, boundary
);
117 y
= bv
.textMetrics(&text_
.text()).cursorY(sl
, boundary
);