]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_fboxinset.C
Fix.
[lyx.git] / src / mathed / math_fboxinset.C
index 138e2fe40709eae6f348baadc15892ebf810f48e..0b7f49d6690da6243093bd12455880dade76b121 100644 (file)
@@ -1,18 +1,17 @@
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include "math_fboxinset.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_parser.h"
 #include "frontends/Painter.h"
 
 
 
-MathFboxInset::MathFboxInset()
-       : MathNestInset(1)
+MathFboxInset::MathFboxInset(latexkeys const * key)
+       : MathNestInset(1), key_(key)
 {}
 
 
@@ -22,30 +21,47 @@ MathInset * MathFboxInset::clone() const
 }
 
 
+MathInset::mode_type MathFboxInset::currentMode() const
+{
+       if (key_->name == "fbox")
+               return TEXT_MODE;
+       return MATH_MODE;
+}
+
+
 void MathFboxInset::metrics(MathMetricsInfo & mi) const
 {
-       MathFontSetChanger dummy(mi.base, "textnormal");
-       dim_ = xcell(0).metrics(mi);
-       metricsMarkers2(5); // 5 pixels margin
+       if (key_->name == "fbox") {
+               MathFontSetChanger dummy(mi.base, "textnormal");
+               dim_ = cell(0).metrics(mi);
+               metricsMarkers2(5); // 5 pixels margin
+       } else {
+               dim_ = cell(0).metrics(mi);
+               metricsMarkers2(5); // 5 pixels margin
+       }
 }
 
 
 void MathFboxInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       MathFontSetChanger dummy(pi.base, "textnormal");
        pi.pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2,
                        LColor::black);
-       xcell(0).draw(pi, x + 5, y);
+       if (key_->name == "fbox") {
+               MathFontSetChanger dummy(pi.base, "textnormal");
+               cell(0).draw(pi, x + 5, y);
+       } else {
+               cell(0).draw(pi, x + 5, y);
+       }
 }
 
 
 void MathFboxInset::write(WriteStream & os) const
 {
-       os << "\\fbox{" << cell(0) << '}';
+       os << '\\' << key_->name << '{' << cell(0) << '}';
 }
 
 
 void MathFboxInset::normalize(NormalStream & os) const
 {
-       os << "[fbox " << cell(0) << ']';
+       os << '[' << key_->name << ' ' << cell(0) << ']';
 }