]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
small up/down tweaking
[lyx.git] / src / mathed / math_macroarg.C
index efd0e392e189b4324de2138fc7333e9c93a97a32..b73426d3798ad7b5f6db898e0a9b6c8142a7e22c 100644 (file)
@@ -4,19 +4,24 @@
 
 #include "math_macroarg.h"
 #include "math_macro.h"
-#include "math_defs.h"
-#include "mathed/support.h"
+#include "math_mathmlstream.h"
+#include "math_support.h"
 #include "debug.h"
 
 
+using std::endl;
+
 
 MathMacroArgument::MathMacroArgument(int n)
-       : number_(n)
+       : MathNestInset(1), number_(n), expanded_(false)
 {
        if (n < 1 || n > 9) {
                lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
-                       << n << std::endl;
+                       << n << endl;
        }
+       str_[0] = '#';
+       str_[1] = static_cast<unsigned char>('0' + n);
+       str_[2] = '\0';
 }
 
 
@@ -26,37 +31,38 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y)
+void MathMacroArgument::write(WriteStream & os) const
 {
-       char str[] = "#0";
-       str[1] += number_; 
-       drawStr(pain, LM_TC_TEX, size(), x, y, str);
+       os << str_;
 }
 
 
-void MathMacroArgument::metrics(MathStyles st)
+void MathMacroArgument::metrics(MathMetricsInfo & mi) const
 {
-       char str[] = "#0";
-       str[1] += number_; 
-       size_ = st;
-       mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
+       if (expanded_)
+               dim_ = cell(0).metrics(mi);
+       else
+               mathed_string_dim(mi.base.font, str_, dim_);
 }
 
 
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::draw(MathPainterInfo & pi, int x, int y) const
 {
-       os << '#' << number_ << ' ';
+       if (expanded_)
+               cell(0).draw(pi, x, y);
+       else
+               drawStrRed(pi, x, y, str_);
 }
 
 
-void MathMacroArgument::writeNormal(std::ostream & os) const
+void MathMacroArgument::normalize(NormalStream & os) const
 {
-       os << "[macroarg " << number_ << "] ";
+       os << "[macroarg " << str_ << "] ";
 }
 
 
-void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
+void MathMacroArgument::substitute(MathMacro const & m)
 {
-       array.push_back(m.cell(number_ - 1));
+       cell(0) = m.cell(number_ - 1);
+       expanded_ = true;
 }
-