]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/InsetMathMBox.cpp
simplify GuiToc / TocWidget interaction. Much can still be simplified...
[lyx.git] / src / mathed / InsetMathMBox.cpp
index 1b009cf3e872361f0056eec1981c50f8d2cc979b..c3c41b194dc14fd8902e71760c57c393515f55e4 100644 (file)
@@ -18,7 +18,7 @@
 #include "Buffer.h"
 #include "BufferParams.h"
 #include "Cursor.h"
-#include "debug.h"
+#include "support/debug.h"
 #include "MetricsInfo.h"
 #include "output_latex.h"
 #include "OutputParams.h"
 #include "TexRow.h"
 #include "TextMetrics.h"
 
-namespace lyx {
-
-//using support::odocstream;
+using namespace std;
 
-using std::auto_ptr;
-using std::endl;
+namespace lyx {
 
 
 InsetMathMBox::InsetMathMBox()
@@ -41,7 +38,7 @@ InsetMathMBox::InsetMathMBox()
 }
 
 
-InsetMathMBox::InsetMathMBox(LyXLayout_ptr const & layout)
+InsetMathMBox::InsetMathMBox(LayoutPtr const & layout)
 {
        text_.paragraphs().clear();
        text_.paragraphs().push_back(Paragraph());
@@ -49,27 +46,23 @@ InsetMathMBox::InsetMathMBox(LyXLayout_ptr const & layout)
 }
 
 
-auto_ptr<Inset> InsetMathMBox::doClone() const
+Inset * InsetMathMBox::clone() const
 {
-       return auto_ptr<Inset>(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);
 }
 
@@ -80,12 +73,12 @@ void InsetMathMBox::write(Buffer const & buf, WriteStream & ws) const
                ws << "\\mbox{\n";
                TexRow texrow;
                OutputParams runparams(&buf.params().encoding());
-               latexParagraphs(buf, text_.paragraphs(), ws.os(), texrow, runparams);
+               latexParagraphs(buf, text_, ws.os(), texrow, runparams);
                ws.addlines(texrow.rows());
                ws << "}";
        } else {
                ws << "\\mbox{\n";
-               std::ostringstream os;
+               ostringstream os;
                text_.write(buf, os);
                ws.os() << from_utf8(os.str());
                ws << "}";
@@ -98,7 +91,7 @@ int InsetMathMBox::latex(Buffer const & buf, odocstream & os,
 {
        os << "\\mbox{\n";
        TexRow texrow;
-       latexParagraphs(buf, text_.paragraphs(), os, texrow, runparams);
+       latexParagraphs(buf, 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);
 }