X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_mboxinset.C;h=c3f090db000e8d73283536517af0225100c483c9;hb=1ecc7b79cdf95de50f2683fb7a8f983b5dcdf0d2;hp=0b7fa1548539e2e5c2063824f84535290282bbe3;hpb=ec4ab8ce18418999b547368d1d2bbf546bec1e7b;p=lyx.git diff --git a/src/mathed/math_mboxinset.C b/src/mathed/math_mboxinset.C index 0b7fa15485..c3f090db00 100644 --- a/src/mathed/math_mboxinset.C +++ b/src/mathed/math_mboxinset.C @@ -17,21 +17,26 @@ #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" #include "paragraph.h" +#include "texrow.h" using std::auto_ptr; using std::endl; MathMBoxInset::MathMBoxInset(BufferView & bv) - : text_(&bv, true), bv_(&bv) + : text_(&bv), bv_(&bv) { + text_.paragraphs().clear(); text_.paragraphs().push_back(Paragraph()); text_.paragraphs().back(). layout(bv.buffer()->params().getLyXTextClass().defaultLayout()); - text_.redoParagraph(text_.paragraphs().begin()); + text_.redoParagraph(0); } @@ -51,20 +56,41 @@ void MathMBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const void MathMBoxInset::draw(PainterInfo & pi, int x, int y) const { - text_.draw(pi, x + 1, y); + text_.draw(pi, x + 1, y - text_.ascent()); drawMarkers(pi, x, y); } -void MathMBoxInset::write(WriteStream & os) const +void MathMBoxInset::write(WriteStream & ws) const +{ + if (ws.latex()) { + ws << "\\mbox{\n"; + TexRow texrow; + OutputParams runparams; + latexParagraphs(*bv_->buffer(), text_.paragraphs(), + ws.os(), texrow, runparams); + ws.addlines(texrow.rows()); + ws << "}"; + } else { + ws << "\\mbox{\n"; + text_.write(*bv_->buffer(), ws.os()); + ws << "}"; + } +} + + +int MathMBoxInset::latex(Buffer const & buf, std::ostream & os, + OutputParams const & runparams) const { os << "\\mbox{\n"; - text_.write(*bv_->buffer(), os.os()); + TexRow texrow; + latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams); os << "}"; + return texrow.rows(); } -void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest const & cmd) +void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd) { text_.dispatch(cur, cmd); } @@ -76,9 +102,8 @@ LyXText * MathMBoxInset::getText(int) const } -void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const +void MathMBoxInset::getCursorPos(LCursor const & cur, int & x, int & y) const { - x = text_.cursorX(cur); - //y = text_.cursorY(cur); - y = 100; + x = text_.cursorX(cur.top()); + y = text_.cursorY(cur.top()); }