]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_boxinset.C
Change the color of the background widget to red.
[lyx.git] / src / mathed / math_boxinset.C
index fa2a61909c3ad1acc9ab81cdbeec0bda9a4a1ddb..10e070c8b75dc492f3a13e573db64790695eb6e1 100644 (file)
@@ -1,81 +1,68 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
+/**
+ * \file math_boxinset.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author André Pönitz
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
 
 #include "math_boxinset.h"
-#include "support/LOstream.h"
-#include "LColor.h"
-#include "debug.h"
-#include "Painter.h"
-#include "math_cursor.h"
-#include "insets/insettext.h"
+#include "math_data.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "support/std_ostream.h"
 
+using std::string;
+using std::auto_ptr;
 
-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(string const & name)
+       : MathNestInset(1), name_(name)
+{}
 
 
-MathBoxInset::~MathBoxInset()
+auto_ptr<InsetBase> MathBoxInset::clone() const
 {
-       delete text_;
+       return auto_ptr<InsetBase>(new MathBoxInset(*this));
 }
 
 
-MathInset * MathBoxInset::clone() const
+void MathBoxInset::write(WriteStream & os) const
 {
-       return new MathBoxInset(*this);
+       os << '\\' << name_ << '{' << cell(0) << '}';
 }
 
 
-void MathBoxInset::write(MathWriteInfo & os) const
+void MathBoxInset::normalize(NormalStream & os) const
 {
-       os << "\\" << name_ << "{" << cell(0) << "}";
+       os << '[' << name_ << ' ';
+       //text_->write(buffer(), os);
+       os << "] ";
 }
 
 
-void MathBoxInset::writeNormal(std::ostream & os) const
+void MathBoxInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       os << "[mbox ";
-       //text_->write(buffer(), os);
-       os << "] ";
+       FontSetChanger dummy(mi.base, "textnormal");
+       cell(0).metrics(mi, dim);
+       metricsMarkers(dim);
+       dim_ = dim;
 }
 
 
-void MathBoxInset::metrics(MathMetricsInfo const & st) const
+void MathBoxInset::draw(PainterInfo & pi, int x, int y) 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;
-       }
+       FontSetChanger dummy(pi.base, "textnormal");
+       cell(0).draw(pi, x, y);
+       drawMarkers(pi, x, y);
 }
 
 
-void MathBoxInset::draw(Painter & pain, int x, int y) const
+void MathBoxInset::infoize(std::ostream & os) const
 {
-       float fx = x + 2;
-
-       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);
+       os << "Box: " << name_;
 }