]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
small up/down tweaking
[lyx.git] / src / mathed / math_macroarg.C
index 4a9bf76ce12c0f0160deab6cb8f2e03da4678092..b73426d3798ad7b5f6db898e0a9b6c8142a7e22c 100644 (file)
@@ -4,22 +4,23 @@
 
 #include "math_macroarg.h"
 #include "math_macro.h"
-#include "math_defs.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
 #include "debug.h"
 
 
+using std::endl;
+
 
 MathMacroArgument::MathMacroArgument(int 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';
 }
 
@@ -30,37 +31,33 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::write(MathWriteInfo & os) const
+void MathMacroArgument::write(WriteStream & os) const
 {
-       os << '#' << number_;
+       os << str_;
 }
 
 
-void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
+void MathMacroArgument::metrics(MathMetricsInfo & mi) const
 {
-       mi_ = mi;
-       if (expanded_) {
-               xcell(0).metrics(mi_);
-               width_   = xcell(0).width();
-               ascent_  = xcell(0).ascent();
-               descent_ = xcell(0).descent();
-       } else
-               mathed_string_dim(LM_TC_TEX, mi_, str_, ascent_, descent_, width_);
+       if (expanded_)
+               dim_ = cell(0).metrics(mi);
+       else
+               mathed_string_dim(mi.base.font, str_, dim_);
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y) const
+void MathMacroArgument::draw(MathPainterInfo & pi, int x, int y) const
 {
        if (expanded_)
-               xcell(0).draw(pain, x, y);
+               cell(0).draw(pi, x, y);
        else
-               drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
+               drawStrRed(pi, x, y, str_);
 }
 
 
-void MathMacroArgument::writeNormal(NormalStream & os) const
+void MathMacroArgument::normalize(NormalStream & os) const
 {
-       os << "[macroarg " << number_ << "] ";
+       os << "[macroarg " << str_ << "] ";
 }
 
 
@@ -69,4 +66,3 @@ void MathMacroArgument::substitute(MathMacro const & m)
        cell(0) = m.cell(number_ - 1);
        expanded_ = true;
 }
-