X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2FInsetMathMBox.cpp;h=8facb40d68d65ee852e3eb31e69063d67d44e1a3;hb=5e0121cf5854a2a0039e6cb4970aeddb18bd4b23;hp=23f5453515aa75fe74e40bb8afdef7b8e51e71c5;hpb=42123ab8a71080b6d15fca4e0c43ae76abf00a1e;p=lyx.git diff --git a/src/mathed/InsetMathMBox.cpp b/src/mathed/InsetMathMBox.cpp index 23f5453515..8facb40d68 100644 --- a/src/mathed/InsetMathMBox.cpp +++ b/src/mathed/InsetMathMBox.cpp @@ -11,14 +11,13 @@ #include #include "InsetMathMBox.h" -#include "MathArray.h" +#include "MathData.h" #include "MathStream.h" #include "BufferView.h" #include "Buffer.h" #include "BufferParams.h" #include "Cursor.h" -#include "debug.h" #include "MetricsInfo.h" #include "output_latex.h" #include "OutputParams.h" @@ -26,12 +25,11 @@ #include "TexRow.h" #include "TextMetrics.h" -namespace lyx { +#include "support/debug.h" -//using support::odocstream; +using namespace std; -using std::auto_ptr; -using std::endl; +namespace lyx { InsetMathMBox::InsetMathMBox() @@ -41,64 +39,59 @@ InsetMathMBox::InsetMathMBox() } -InsetMathMBox::InsetMathMBox(LyXLayout_ptr const & layout) +InsetMathMBox::InsetMathMBox(Layout const & layout) { text_.paragraphs().clear(); text_.paragraphs().push_back(Paragraph()); - text_.paragraphs().back().layout(layout); + text_.paragraphs().back().setLayout(layout); } -auto_ptr InsetMathMBox::doClone() const +Inset * InsetMathMBox::clone() const { - return auto_ptr(new InsetMathMBox(*this)); + return new InsetMathMBox(*this); } -bool InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const +void InsetMathMBox::metrics(MetricsInfo & mi, Dimension & dim) const { TextMetrics & tm = mi.base.bv->textMetrics(&text_); tm.metrics(mi, dim); metricsMarkers2(dim); - if (dim_ == dim) - return false; - dim_ = dim; - return true; } void InsetMathMBox::draw(PainterInfo & pi, int x, int y) const { - text_.draw(pi, x + 1, y); + pi.base.bv->textMetrics(&text_).draw(pi, x + 1, y); drawMarkers(pi, x, y); } -void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const +void InsetMathMBox::write(WriteStream & ws) const { if (ws.latex()) { ws << "\\mbox{\n"; TexRow texrow; - OutputParams runparams(&buf.params().encoding()); - latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams); + OutputParams runparams(&buffer().params().encoding()); + latexParagraphs(buffer(), text_, ws.os(), texrow, runparams); ws.addlines(texrow.rows()); ws << "}"; } else { ws << "\\mbox{\n"; - std::ostringstream os; - text_.write(buf, os); + ostringstream os; + text_.write(buffer(), os); ws.os() << from_utf8(os.str()); ws << "}"; } } -int InsetMathMBox::latex(Buffer const & buf, odocstream & os, - OutputParams const & runparams) const +int InsetMathMBox::latex(odocstream & os, OutputParams const & runparams) const { os << "\\mbox{\n"; TexRow texrow; - latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams); + latexParagraphs(buffer(), text_, os, texrow, runparams); os << "}"; return texrow.rows(); } @@ -110,7 +103,7 @@ void InsetMathMBox::doDispatch(Cursor & cur, FuncRequest & cmd) } -LyXText * InsetMathMBox::getText(int) const +Text * InsetMathMBox::getText(int) const { return &text_; } @@ -119,14 +112,8 @@ LyXText * InsetMathMBox::getText(int) const void InsetMathMBox::cursorPos(BufferView const & bv, CursorSlice const & sl, bool boundary, int & x, int & y) const { - x = text_.cursorX(bv, sl, boundary); - y = text_.cursorY(bv, sl, boundary); -} - - -void InsetMathMBox::drawSelection(PainterInfo & pi, int x, int y) const -{ - text_.drawSelection(pi, x, y); + x = bv.textMetrics(&text_).cursorX(sl, boundary); + y = bv.textMetrics(&text_).cursorY(sl, boundary); }