5 #include "math_macroarg.h"
6 #include "math_macro.h"
8 #include "math_mathmlstream.h"
9 #include "math_support.h"
14 MathMacroArgument::MathMacroArgument(int n, MathTextCodes code)
15 : MathNestInset(1), number_(n), expanded_(false), code_(code)
18 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
22 str_[1] = static_cast<unsigned char>('0' + n);
27 MathInset * MathMacroArgument::clone() const
29 return new MathMacroArgument(*this);
33 void MathMacroArgument::write(WriteStream & os) const
35 if (code_ == LM_TC_MIN)
38 os << '\\' << math_font_name(code_) << '{' << str_ << '}';
42 void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
46 xcell(0).metrics(mi_);
47 width_ = xcell(0).width();
48 ascent_ = xcell(0).ascent();
49 descent_ = xcell(0).descent();
51 mathed_string_dim(LM_TC_TEX, mi_, str_, ascent_, descent_, width_);
55 void MathMacroArgument::draw(Painter & pain, int x, int y) const
58 xcell(0).draw(pain, x, y);
60 drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
64 void MathMacroArgument::normalize(NormalStream & os) const
66 os << "[macroarg " << str_ << "] ";
70 void MathMacroArgument::substitute(MathMacro const & m)
72 cell(0) = m.cell(number_ - 1);
73 if (code_ != LM_TC_MIN)
74 for (MathArray::iterator it = cell(0).begin(); it != cell(0).end(); ++it)
75 it->nucleus()->handleFont(code_);