]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_fboxinset.C
Andreas' patch to prevent crash on click on previewd inset
[lyx.git] / src / mathed / math_fboxinset.C
index f8e5889348b91466c97060614f7f90d01621712e..6fbbb38c8b5d0d185578b011f87a2fbed30ad083 100644 (file)
@@ -1,43 +1,51 @@
+/**
+ * \file math_fboxinset.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_fboxinset.h"
-#include "math_support.h"
+#include "math_data.h"
 #include "math_mathmlstream.h"
-#include "math_streamstr.h"
 #include "math_parser.h"
+#include "math_streamstr.h"
+#include "LColor.h"
+
+#include "support/std_ostream.h"
 #include "frontends/Painter.h"
 
+using std::auto_ptr;
 
 
-MathFboxInset::MathFboxInset(latexkeys const * key)
-       : MathNestInset(1), key_(key)
+MathFboxInset::MathFboxInset()
+       : MathNestInset(1)
 {}
 
 
-InsetBase * MathFboxInset::clone() const
+auto_ptr<InsetBase> MathFboxInset::doClone() const
 {
-       return new MathFboxInset(*this);
+       return auto_ptr<InsetBase>(new MathFboxInset(*this));
 }
 
 
 MathInset::mode_type MathFboxInset::currentMode() const
 {
-       if (key_->name == "fbox")
-               return TEXT_MODE;
-       return MATH_MODE;
+       return TEXT_MODE;
 }
 
 
 void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       if (key_->name == "fbox") {
-               FontSetChanger dummy(mi.base, "textnormal");
-               cell(0).metrics(mi, dim_);
-       } else {
-               cell(0).metrics(mi, dim_);
-       }
-       metricsMarkers(5); // 5 pixels margin
-       dim = dim_;
+       FontSetChanger dummy(mi.base, "textnormal");
+       cell(0).metrics(mi, dim);
+       metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space
+       dim_ = dim;
 }
 
 
@@ -45,22 +53,25 @@ void MathFboxInset::draw(PainterInfo & pi, int x, int y) const
 {
        pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
                dim_.width() - 2, dim_.height() - 2, LColor::foreground);
-       if (key_->name == "fbox") {
-               FontSetChanger dummy(pi.base, "textnormal");
-               cell(0).draw(pi, x + 5, y);
-       } else {
-               cell(0).draw(pi, x + 5, y);
-       }
+       FontSetChanger dummy(pi.base, "textnormal");
+       cell(0).draw(pi, x + 3, y);
+       setPosCache(pi, x, y);
 }
 
 
 void MathFboxInset::write(WriteStream & os) const
 {
-       os << '\\' << key_->name << '{' << cell(0) << '}';
+       os << "\\fbox{" << cell(0) << '}';
 }
 
 
 void MathFboxInset::normalize(NormalStream & os) const
 {
-       os << '[' << key_->name << ' ' << cell(0) << ']';
+       os << "[fbox " << cell(0) << ']';
+}
+
+
+void MathFboxInset::infoize(std::ostream & os) const
+{
+       os << "FBox: ";
 }