#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: "
}
-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;
}