]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_decorationinset.C
remove symbol_def.h
[lyx.git] / src / mathed / math_decorationinset.C
index dd87a10ec530a141d780a12cff92d1e0a267d7d4..8d3d3501e8b70a631a0a9157d855174771f0e2d4 100644 (file)
 using std::ostream;
 
 
-MathDecorationInset::MathDecorationInset(latexkeys const * key)
-       : MathInset(1), key_(key)
-{
-       upper_ = key_->id != LM_underline && key_->id != LM_underbrace;
-}
+MathDecorationInset::MathDecorationInset(string const & name)
+       : MathNestInset(1), name_(name)
+{}
 
 
 MathInset * MathDecorationInset::clone() const
@@ -24,8 +22,23 @@ MathInset * MathDecorationInset::clone() const
 }
 
 
+bool MathDecorationInset::upper() const
+{
+       return name_ != "underline" && name_ != "underbrace";
+}
+
+
+bool MathDecorationInset::protect() const
+{
+       return
+                       name_ == "overbrace" ||
+                       name_ == "underbrace" ||
+                       name_ == "overleftarrow" ||
+                       name_ == "overrightarrow";
+}
+
 
-void MathDecorationInset::metrics(MathStyles st)
+void MathDecorationInset::metrics(MathStyles st) const
 {
        xcell(0).metrics(st);
        size_    = st;
@@ -35,56 +48,38 @@ void MathDecorationInset::metrics(MathStyles st)
 
        dh_ = 5; //mathed_char_height(LM_TC_VAR, size(), 'I', ascent_, descent_);  
 
-       if (upper_) {
+       if (upper()) {
                dy_ = -ascent_ - dh_;
                ascent_ += dh_ + 1;
        } else {
                dy_ = descent_ + 1;
                descent_ += dh_ + 2;
        }
-
-       if (key_->id == LM_not) {
-               ascent_  += dh_;
-               descent_ += dh_;
-               dh_ = height();
-               dy_ = - ascent_;
-       }
 }
 
-void MathDecorationInset::draw(Painter & pain, int x, int y)
+
+void MathDecorationInset::draw(Painter & pain, int x, int y) const
 { 
        xo(x);
        yo(x);
        xcell(0).draw(pain, x, y);
-       mathed_draw_deco(pain, x, y + dy_, width_, dh_, key_->id);
+       mathed_draw_deco(pain, x, y + dy_, width_, dh_, name_);
 }
 
 
 void MathDecorationInset::write(ostream & os, bool fragile) const
 {
-       string name = key_->name;
-       if (fragile &&
-                       (name == "overbrace" ||
-                        name == "underbrace" ||
-                        name == "overleftarrow" ||
-                        name == "overrightarrow"))
+       if (fragile && protect())
                os << "\\protect";
-       os << '\\' << name;
-
-       if (key_->id == LM_not)
-               os << ' ';
-       else
-               os << '{';
-
+       os << '\\' << name_ << '{';
        cell(0).write(os, fragile);  
-
-       if (key_->id != LM_not)
-               os << '}';
+       os << '}';
 }
 
+
 void MathDecorationInset::writeNormal(ostream & os) const
 {
-       os << "[" << key_->name << " ";
+       os << "[" << name_ << " ";
        cell(0).writeNormal(os);
        os << "] ";
 }