]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_fontinset.C
no special treatment for scriptinsets
[lyx.git] / src / mathed / math_fontinset.C
index 380cc73099f0b48f964db05949d6d4f720e87925..ef7cdb7393ce2889ff2c5348f1c7c6a71c03ff01 100644 (file)
@@ -9,16 +9,17 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "math_support.h"
+#include "math_parser.h"
 #include "LaTeXFeatures.h"
 #include "textpainter.h"
+#include "frontends/Painter.h"
 
 
 
-
-MathFontInset::MathFontInset(string const & name)
-       : MathNestInset(1), name_(name)
+MathFontInset::MathFontInset(latexkeys const * key)
+       : MathNestInset(1), key_(key)
 {
-       lock(true);
+       //lock(true);
 }
 
 
@@ -28,30 +29,37 @@ MathInset * MathFontInset::clone() const
 }
 
 
+MathInset::mode_type MathFontInset::currentMode() const
+{
+       if (key_->extra == "mathmode")
+               return MATH_MODE;
+       if (key_->extra == "textmode")
+               return TEXT_MODE;
+       return UNDECIDED_MODE;
+}
+
+
 void MathFontInset::metrics(MathMetricsInfo & mi) const
 {
-       MathFontSetChanger dummy(mi.base, name_.c_str());
-       xcell(0).metrics(mi);
-       width_   = xcell(0).width();
-       ascent_  = xcell(0).ascent();
-       descent_ = xcell(0).descent();
+       MathFontSetChanger dummy(mi.base, key_->name.c_str());
+       dim_ = xcell(0).metrics(mi);
+       metricsMarkers();
 }
 
 
 void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "MathFontInset::draw\n";
-       MathFontSetChanger dummy(pi.base, name_.c_str());
-       xcell(0).draw(pi, x, y);
+       //MathNestInset::draw(pi, x, y);
+       MathFontSetChanger dummy(pi.base, key_->name.c_str());
+       xcell(0).draw(pi, x + 1, y);
+       drawMarkers(pi, x, y);
 }
 
 
 void MathFontInset::metricsT(TextMetricsInfo const & mi) const
 {
-       xcell(0).metricsT(mi);
-       width_   = xcell(0).width();
-       ascent_  = xcell(0).ascent();
-       descent_ = xcell(0).descent();
+       dim_ = xcell(0).metricsT(mi);
 }
 
 
@@ -64,13 +72,13 @@ void MathFontInset::drawT(TextPainter & pain, int x, int y) const
 
 void MathFontInset::write(WriteStream & os) const
 {
-       os << '\\' << name_ << '{' << cell(0) << '}';
+       os << '\\' << key_->name << '{' << cell(0) << '}';
 }
 
 
 void MathFontInset::normalize(NormalStream & os) const
 {
-       os << "[font_ " << name_ << " " << cell(0) << "]";
+       os << "[font " << key_->name << " " << cell(0) << "]";
 }
 
 
@@ -78,12 +86,12 @@ void MathFontInset::validate(LaTeXFeatures & features) const
 {
        // Make sure amssymb is put in preamble if Blackboard Bold or
        // Fraktur used:
-       if (name_ == "mathfrak" || name_ == "mathbb")
+       if (key_->name == "mathfrak" || key_->name == "mathbb")
                features.require("amssymb");
 }
 
 
 void MathFontInset::infoize(std::ostream & os) const
 {
-       os << "Font: " << name_;
+       os << "Font: " << key_->name;
 }