]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
fix pullArg when pressing <Delete> at the end of an cell
[lyx.git] / src / mathed / math_macroarg.C
index cbcad44b00a34fdb964dd25acabf40e887d308c1..c64f750c77dab189abf72ca85c5f4da5a6715cdb 100644 (file)
@@ -1,44 +1,28 @@
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include "math_macro.h"
 #include "math_macroarg.h"
+#include "math_macro.h"
+#include "math_defs.h"
 #include "mathed/support.h"
-#include "Lsstream.h"
 #include "debug.h"
 
 
-using namespace std;
 
 MathMacroArgument::MathMacroArgument(int n)
-       : MathedInset(string(), LM_OT_MACRO_ARG, LM_ST_TEXT),
-               number_(n)
+       : number_(n)
 {
        if (n < 1 || n > 9) {
                lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
-                       << n << endl;
-               lyx::Assert(0);
+                       << n << std::endl;
        }
 }
 
-MathedInset * MathMacroArgument::Clone()
-{
-       //return new MathMacroArgument(*this);
-       return this;
-}
-
-int MathMacroArgument::number() const
-{
-       return number_;
-}
 
-void MathMacroArgument::substitute(MathMacro * /*m*/)
+MathInset * MathMacroArgument::clone() const
 {
-       lyxerr << "Calling MathMacroArgument::substitute!\n";
-       //return m->arg(number_)->Clone();
+       return new MathMacroArgument(*this);
 }
 
 
@@ -50,17 +34,29 @@ void MathMacroArgument::draw(Painter & pain, int x, int y)
 }
 
 
-void MathMacroArgument::Metrics()
+void MathMacroArgument::Metrics(MathStyles st, int, int)
 {
        char str[] = "#0";
        str[1] += number_; 
-       width = mathed_string_width(LM_TC_TEX, size(), str);
-       mathed_string_height(LM_TC_TEX, size(), str, ascent, descent);
+       size_ = st;
+       mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
 }
 
 
-void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/)
+void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/) const
 {
        os << '#' << number_ << ' ';
 }
 
+
+void MathMacroArgument::WriteNormal(std::ostream & os) const
+{
+       os << "[macroarg " << number_ << "] ";
+}
+
+
+void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
+{
+       array.push_back(m.cell(number_ - 1));
+}
+