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;
}
+ str_[0] = '#';
+ str_[1] = '0' + n;
+ str_[2] = '\0';
}
}
-void MathMacroArgument::draw(Painter & pain, int x, int y)
+void MathMacroArgument::write(MathWriteInfo & os) const
{
- char str[] = "#0";
- str[1] += number_;
- drawStr(pain, LM_TC_TEX, size(), x, y, str);
+ os << '#' << number_;
}
-void MathMacroArgument::Metrics(MathStyles st)
+void MathMacroArgument::metrics(MathMetricsInfo const & st) const
{
- char str[] = "#0";
- str[1] += number_;
- size_ = st;
- mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
+ if (expanded_) {
+ xcell(0).metrics(st);
+ width_ = xcell(0).width();
+ ascent_ = xcell(0).ascent();
+ descent_ = xcell(0).descent();
+ } else
+ mathed_string_dim(LM_TC_TEX, size_.size, str_, ascent_, descent_, width_);
}
-void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/) const
+void MathMacroArgument::draw(Painter & pain, int x, int y) const
{
- os << '#' << number_ << ' ';
+ if (expanded_)
+ xcell(0).draw(pain, x, y);
+ else
+ drawStr(pain, LM_TC_TEX, size_.size, x, y, str_);
}
-void MathMacroArgument::WriteNormal(std::ostream & os) const
+void MathMacroArgument::writeNormal(std::ostream & os) const
{
os << "[macroarg " << number_ << "] ";
}
-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;
}