-#include <config.h>
-
#ifdef __GNUG__
#pragma implementation
#endif
#include "math_macroarg.h"
#include "math_macro.h"
-#include "math_defs.h"
-#include "mathed/support.h"
-#include "support/LAssert.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;
- lyx::Assert(0);
+ << n << endl;
}
+ str_[0] = '#';
+ str_[1] = static_cast<unsigned char>('0' + n);
+ str_[2] = '\0';
}
}
-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;
}
-