]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
small up/down tweaking
[lyx.git] / src / mathed / math_macroarg.C
index 22ff523059d5dd0fa7dfeff0fb2f556b248ef6a8..b73426d3798ad7b5f6db898e0a9b6c8142a7e22c 100644 (file)
@@ -4,21 +4,23 @@
 
 #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] = '0' + n;
+       str_[1] = static_cast<unsigned char>('0' + n);
        str_[2] = '\0';
 }
 
@@ -29,44 +31,38 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y)
-{
-       drawStr(pain, LM_TC_TEX, size(), x, y, str_);
-}
-
-
-int MathMacroArgument::ascent() const
+void MathMacroArgument::write(WriteStream & os) const
 {
-       return mathed_char_ascent(LM_TC_TEX, size(), 'I');
+       os << str_;
 }
 
 
-int MathMacroArgument::descent() const
+void MathMacroArgument::metrics(MathMetricsInfo & mi) const
 {
-       return mathed_char_descent(LM_TC_TEX, size(), 'I');
+       if (expanded_)
+               dim_ = cell(0).metrics(mi);
+       else
+               mathed_string_dim(mi.base.font, str_, dim_);
 }
 
 
-int MathMacroArgument::width() const
+void MathMacroArgument::draw(MathPainterInfo & pi, int x, int y) const
 {
-       return mathed_string_width(LM_TC_TEX, size(), str_);
+       if (expanded_)
+               cell(0).draw(pi, x, y);
+       else
+               drawStrRed(pi, x, y, str_);
 }
 
 
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::normalize(NormalStream & os) const
 {
-       os << '#' << number_ << ' ';
+       os << "[macroarg " << str_ << "] ";
 }
 
 
-void MathMacroArgument::writeNormal(std::ostream & os) const
+void MathMacroArgument::substitute(MathMacro const & m)
 {
-       os << "[macroarg " << number_ << "] ";
+       cell(0) = m.cell(number_ - 1);
+       expanded_ = true;
 }
-
-
-void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
-{
-       array.push_back(m.cell(number_ - 1));
-}
-