]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
use stream-like syntax for LaTeX output
[lyx.git] / src / mathed / math_macroarg.C
index 8e003ecf0d06d10cbff8e96f0a60667300ae04ab..ab1b2179572793dac30320d6fb229ec08110ea1a 100644 (file)
@@ -11,7 +11,7 @@
 
 
 MathMacroArgument::MathMacroArgument(int n)
-       : number_(n)
+       : MathNestInset(1), number_(n), expanded_(false)
 {
        if (n < 1 || n > 9) {
                lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
@@ -29,33 +29,30 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y) const
-{
-       drawStr(pain, LM_TC_TEX, size(), x, y, str_);
-}
-
-
-int MathMacroArgument::ascent() const
+void MathMacroArgument::write(MathWriteInfo & os) const
 {
-       return mathed_char_ascent(LM_TC_TEX, size(), 'I');
+       os << '#' << number_;
 }
 
 
-int MathMacroArgument::descent() const
+void MathMacroArgument::metrics(MathMetricsInfo const & st) const
 {
-       return mathed_char_descent(LM_TC_TEX, size(), 'I');
+       if (expanded_) {
+               xcell(0).metrics(st);
+               width_   = xcell(0).width();
+               ascent_  = xcell(0).ascent();
+               descent_ = xcell(0).descent();
+       } else
+               mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
 }
 
 
-int MathMacroArgument::width() const
-{
-       return mathed_string_width(LM_TC_TEX, size(), str_);
-}
-
-
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::draw(Painter & pain, int x, int y) const
 {
-       os << '#' << number_ << ' ';
+       if (expanded_)
+               xcell(0).draw(pain, x, y);
+       else
+               drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
 }
 
 
@@ -65,8 +62,9 @@ void MathMacroArgument::writeNormal(std::ostream & os) const
 }
 
 
-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;
 }