]> 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 87670660746fa44c82aaf1ccdaad534706921c3d..c64f750c77dab189abf72ca85c5f4da5a6715cdb 100644 (file)
@@ -1,82 +1,62 @@
-#include <config.h>
-
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
 #include "math_macroarg.h"
+#include "math_macro.h"
+#include "math_defs.h"
 #include "mathed/support.h"
 #include "debug.h"
 
 
-MathMacroArgument::MathMacroArgument()
-       : expnd_mode_(false), number_(1)
-{
-       SetType(LM_OT_MACRO_ARG);
-}
-
 
 MathMacroArgument::MathMacroArgument(int n)
-       : expnd_mode_(false), number_(n)
+       : number_(n)
 {
-       SetType(LM_OT_MACRO_ARG);
+       if (n < 1 || n > 9) {
+               lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
+                       << n << std::endl;
+       }
 }
 
 
-MathedInset * MathMacroArgument::Clone()
+MathInset * MathMacroArgument::clone() const
 {
-       return this;
+       return new MathMacroArgument(*this);
 }
 
 
-void MathMacroArgument::setNumber(int n)
+void MathMacroArgument::draw(Painter & pain, int x, int y)
 {
-       number_ = n;
+       char str[] = "#0";
+       str[1] += number_; 
+       drawStr(pain, LM_TC_TEX, size(), x, y, str);
 }
 
 
-void MathMacroArgument::setExpand(bool e)
+void MathMacroArgument::Metrics(MathStyles st, int, int)
 {
-       expnd_mode_ = e;
+       char str[] = "#0";
+       str[1] += number_; 
+       size_ = st;
+       mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
 }
 
 
-bool MathMacroArgument::getExpand() const
+void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/) const
 {
-       return expnd_mode_;
+       os << '#' << number_ << ' ';
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int baseline)
-{
-       if (expnd_mode_) {
-               MathParInset::draw(pain, x, baseline);
-       } else {
-               std::ostringstream ost;
-               ost << '#' << number_;
-               drawStr(pain, LM_TC_TEX, size(), x, baseline, ost.str().c_str());
-       }
-}
-
-void MathMacroArgument::Metrics()
+void MathMacroArgument::WriteNormal(std::ostream & os) const
 {
-       if (expnd_mode_) {
-               MathParInset::Metrics();
-       } else {
-               std::ostringstream ost;
-               ost << '#' << number_;
-               width = mathed_string_width(LM_TC_TEX, size(), ost.str().c_str());
-               mathed_string_height(LM_TC_TEX, size(), ost.str().c_str(),
-                                    ascent, descent);
-       }
+       os << "[macroarg " << number_ << "] ";
 }
 
 
-void MathMacroArgument::Write(ostream & os, bool fragile)
+void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
 {
-       if (expnd_mode_) {
-               MathParInset::Write(os, fragile);
-       } else {
-               os << '#' << number_ << ' ';
-       }
+       array.push_back(m.cell(number_ - 1));
 }
+