5 #include "math_macroarg.h"
6 #include "math_macro.h"
8 #include "math_mathmlstream.h"
9 #include "math_support.h"
16 MathMacroArgument::MathMacroArgument(int n, MathTextCodes code)
17 : MathNestInset(1), number_(n), expanded_(false), code_(code)
20 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
24 str_[1] = static_cast<unsigned char>('0' + n);
29 MathInset * MathMacroArgument::clone() const
31 return new MathMacroArgument(*this);
35 void MathMacroArgument::write(WriteStream & os) const
37 if (code_ == LM_TC_MIN)
40 os << '\\' << math_font_name(code_) << '{' << str_ << '}';
44 void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
46 whichFont(font_, LM_TC_TEX, mi);
49 width_ = xcell(0).width();
50 ascent_ = xcell(0).ascent();
51 descent_ = xcell(0).descent();
53 mathed_string_dim(font_, str_, ascent_, descent_, width_);
57 void MathMacroArgument::draw(Painter & pain, int x, int y) const
60 xcell(0).draw(pain, x, y);
62 drawStr(pain, font_, x, y, str_);
66 void MathMacroArgument::normalize(NormalStream & os) const
68 os << "[macroarg " << str_ << "] ";
72 void MathMacroArgument::substitute(MathMacro const & m)
74 cell(0) = m.cell(number_ - 1);
75 if (code_ != LM_TC_MIN)
76 for (MathArray::iterator it = cell(0).begin(); it != cell(0).end(); ++it)
77 it->nucleus()->handleFont(code_);