]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macro.C
fix pullArg when pressing <Delete> at the end of an cell
[lyx.git] / src / mathed / math_macro.C
index fae542145cdbb9bec142edc2d02912d6046bb422..5085e783bf864957aff6bea102d2e7df514b0865 100644 (file)
@@ -14,8 +14,6 @@
  *  This code is under the GNU General Public Licence version 2 or later.
  */
 
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
@@ -30,6 +28,7 @@
 #include "math_macrotable.h"
 #include "math_macrotemplate.h"
 #include "Painter.h"
+#include "LaTeXFeatures.h"
 
 using std::endl;
 
@@ -38,13 +37,19 @@ MathMacro::MathMacro(MathMacroTemplate const & t)
 {}
 
 
+MathMacro::MathMacro(MathMacro const & t)
+       : MathInset(t), tmplate_(t.tmplate_) // don't copy 'expanded_'!
+{}
+
+
+
 MathInset * MathMacro::clone() const
 {
        return new MathMacro(*this);
 }
 
 
-void MathMacro::Metrics(MathStyles st)
+void MathMacro::Metrics(MathStyles st, int, int)
 {
        if (mathcursor && mathcursor->isInside(this)) {
                expanded_ = tmplate_->xcell(0);
@@ -85,6 +90,8 @@ void MathMacro::draw(Painter & pain, int x, int y)
        xo(x);
        yo(y);
 
+       Metrics(size());
+
        LColor::color col;
 
        if (mathcursor && mathcursor->isInside(this)) {
@@ -116,7 +123,8 @@ void MathMacro::draw(Painter & pain, int x, int y)
                col = LColor::black;
        }
 
-       pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, col);
+       if (nargs() > 0)
+               pain.rectangle(x + 1, y - ascent() + 1, width() - 2, height() - 2, col);
 }
 
 
@@ -176,3 +184,11 @@ bool MathMacro::idxRight(int &, int &) const
 {
        return false;
 }
+
+
+void MathMacro::Validate(LaTeXFeatures & features) const
+{
+       if (name_ == "binom")
+               features.binom = true;
+       MathInset::Validate(features);
+}