]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_mboxinset.C
some (yet unfinished) up/down work
[lyx.git] / src / mathed / math_mboxinset.C
index 11ed0a796881e66bbbdcefe1a4212a66425da57e..bd3c93b54c21554986b5b7ef089e282034cc6282 100644 (file)
 #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"
 
@@ -38,7 +40,7 @@ MathMBoxInset::MathMBoxInset(BufferView & bv)
 }
 
 
-auto_ptr<InsetBase> MathMBoxInset::clone() const
+auto_ptr<InsetBase> MathMBoxInset::doClone() const
 {
        return auto_ptr<InsetBase>(new MathMBoxInset(*this));
 }
@@ -54,16 +56,26 @@ 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_.ascent());
+       text_.draw(pi, x + 1, y);
        drawMarkers(pi, x, y);
 }
 
 
-void MathMBoxInset::write(WriteStream & os) const
+void MathMBoxInset::write(WriteStream & ws) const
 {
-       os << "\\mbox{\n";
-       text_.write(*bv_->buffer(), os.os());
-       os << "}";
+       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 << "}";
+       }
 }
 
 
@@ -78,7 +90,7 @@ int MathMBoxInset::latex(Buffer const & buf, std::ostream & os,
 }
 
 
-void MathMBoxInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
+void MathMBoxInset::doDispatch(LCursor & cur, FuncRequest & cmd)
 {
        text_.dispatch(cur, cmd);
 }
@@ -90,8 +102,16 @@ LyXText * MathMBoxInset::getText(int) const
 }
 
 
-void MathMBoxInset::getCursorPos(CursorSlice const & cur, int & x, int & y) const
+void MathMBoxInset::cursorPos
+       (CursorSlice const & sl, bool boundary, int & x, int & y) const
 {
-       x = text_.cursorX(cur);
-       y = text_.cursorY(cur);
+       x = text_.cursorX(sl, boundary);
+       y = text_.cursorY(sl, boundary);
 }
+
+
+void MathMBoxInset::drawSelection(PainterInfo & pi, int x, int y) const
+{
+       text_.drawSelection(pi, x, y);
+}
+