]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_boxinset.C
small up/down tweaking
[lyx.git] / src / mathed / math_boxinset.C
index fa2a61909c3ad1acc9ab81cdbeec0bda9a4a1ddb..af3d117053c32e652ece47537c5d91fbbf4404e7 100644 (file)
@@ -1,37 +1,19 @@
+#include <config.h>
+
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
 #include "math_boxinset.h"
+#include "math_support.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
 #include "support/LOstream.h"
-#include "LColor.h"
-#include "debug.h"
-#include "Painter.h"
-#include "math_cursor.h"
-#include "insets/insettext.h"
 
 
 MathBoxInset::MathBoxInset(string const & name)
-       : MathDimInset(), name_(name), text_(new InsetText), buffer_(0)
-{
-       lyxerr << "creating new " << name << endl;
-}
-
-
-MathBoxInset::MathBoxInset(MathBoxInset const & m)
-       :       MathDimInset(*this), name_(m.name_), text_(0), buffer_(m.buffer_)
-{
-       if (!m.buffer_)
-               cerr << "no buffer\n";
-       else
-               text_ = static_cast<InsetText *>(m.text_->clone(*m.buffer_, false));
-}
-
-
-MathBoxInset::~MathBoxInset()
-{
-       delete text_;
-}
+       : MathNestInset(1), name_(name)
+{}
 
 
 MathInset * MathBoxInset::clone() const
@@ -40,42 +22,38 @@ MathInset * MathBoxInset::clone() const
 }
 
 
-void MathBoxInset::write(MathWriteInfo & os) const
+void MathBoxInset::write(WriteStream & os) const
 {
-       os << "\\" << name_ << "{" << cell(0) << "}";
+       os << '\\' << name_ << '{' << cell(0) << '}';
 }
 
 
-void MathBoxInset::writeNormal(std::ostream & os) const
+void MathBoxInset::normalize(NormalStream & os) const
 {
-       os << "[mbox ";
+       os << '[' << name_ << ' ';
        //text_->write(buffer(), os);
        os << "] ";
 }
 
 
-void MathBoxInset::metrics(MathMetricsInfo const & st) const
+void MathBoxInset::metrics(MathMetricsInfo & mi) const
 {
-       size_ = st;
-       if (text_ && st.view && st.font) {
-               ascent_  = text_->ascent(st.view, *st.font)  + 2;
-               descent_ = text_->descent(st.view, *st.font) + 2;
-               width_   = text_->width(st.view, *st.font)   + 4;
-       } else {
-               ascent_  = 10;
-               descent_ = 0;
-               width_   = 10;
-       }
+       MathFontSetChanger dummy(mi.base, "textnormal");
+       cell(0).metrics(mi);
+       dim_ = cell(0).dim();
+       metricsMarkers2();
 }
 
 
-void MathBoxInset::draw(Painter & pain, int x, int y) const
+void MathBoxInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       float fx = x + 2;
+       MathFontSetChanger dummy(pi.base, "textnormal");
+       cell(0).draw(pi, x, y);
+       drawMarkers2(pi, x + 1, y);
+}
+
 
-       if (text_ && size_.view && size_.font)
-               text_->draw(size_.view, *(size_.font), y, fx, false);
-       if (mathcursor && mathcursor->isInside(this))
-               pain.rectangle(x, y - ascent(), xcell(0).width(), height(),
-                       LColor::mathframe);
+void MathBoxInset::infoize(std::ostream & os) const
+{
+       os << "Box: " << name_;
 }