]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/math_macroarg.C
forward search in math insets. ugly. seems to work. don't ask why.
[lyx.git] / src / mathed / math_macroarg.C
index 22ff523059d5dd0fa7dfeff0fb2f556b248ef6a8..179b32fad681e3bf81d3122de3886a0934b750db 100644 (file)
@@ -5,13 +5,14 @@
 #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"
 
 
 
 MathMacroArgument::MathMacroArgument(int n)
-       : number_(n)
+       : MathNestInset(1), number_(n), expanded_(false)
 {
        if (n < 1 || n > 9) {
                lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
@@ -29,44 +30,43 @@ MathInset * MathMacroArgument::clone() const
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y)
+void MathMacroArgument::write(WriteStream & os) const
 {
-       drawStr(pain, LM_TC_TEX, size(), x, y, str_);
+       os << str_;
 }
 
 
-int MathMacroArgument::ascent() const
+void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
 {
-       return mathed_char_ascent(LM_TC_TEX, size(), 'I');
+       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_);
 }
 
 
-int MathMacroArgument::descent() const
+void MathMacroArgument::draw(Painter & pain, int x, int y) const
 {
-       return mathed_char_descent(LM_TC_TEX, size(), 'I');
+       if (expanded_)
+               xcell(0).draw(pain, x, y);
+       else
+               drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
 }
 
 
-int MathMacroArgument::width() const
+void MathMacroArgument::normalize(NormalStream & os) const
 {
-       return mathed_string_width(LM_TC_TEX, size(), str_);
+       os << "[macroarg " << str_ << "] ";
 }
 
 
-void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::substitute(MathMacro const & m)
 {
-       os << '#' << number_ << ' ';
-}
-
-
-void MathMacroArgument::writeNormal(std::ostream & os) const
-{
-       os << "[macroarg " << number_ << "] ";
-}
-
-
-void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
-{
-       array.push_back(m.cell(number_ - 1));
+       cell(0) = m.cell(number_ - 1);
+       expanded_ = true;
 }