5 #include "math_macrotemplate.h"
10 MathMacroTemplate::MathMacroTemplate()
11 : MathNestInset(1), numargs_(0), name_()
15 MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs)
16 : MathNestInset(1), numargs_(numargs), name_(nm)
19 lyxerr << "MathMacroTemplate::MathMacroTemplate: wrong # of arguments: "
20 << numargs_ << std::endl;
25 MathInset * MathMacroTemplate::clone() const
27 //lyxerr << "cloning MacroTemplate!\n";
28 return new MathMacroTemplate(*this);
32 int MathMacroTemplate::numargs() const
38 void MathMacroTemplate::numargs(int numargs)
44 string const & MathMacroTemplate::name() const
50 void MathMacroTemplate::write(MathWriteInfo & os) const
52 os << "\n\\newcommand{\\" << name_ << '}';
54 os << '[' << numargs_ << ']';
55 os << '{' << cell(0) << "}\n";
59 void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const
62 width_ = xcell(0).width() + 4;
63 ascent_ = xcell(0).ascent() + 2;
64 descent_ = xcell(0).descent() + 2;
68 void MathMacroTemplate::draw(Painter & pain, int x, int y) const
72 xcell(0).draw(pain, x + 2, y + 1);
73 pain.rectangle(x, y - ascent(), width(), height(), LColor::blue);