2001-02-26 12:53:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-02-13 17:08:51 +00:00
|
|
|
#include "math_macrotemplate.h"
|
2001-04-24 16:13:38 +00:00
|
|
|
#include "Painter.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "debug.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate()
|
|
|
|
: MathInset(1), numargs_(0)
|
2001-04-24 16:13:38 +00:00
|
|
|
{}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs)
|
|
|
|
: MathInset(1, nm), numargs_(numargs)
|
2001-04-24 16:13:38 +00:00
|
|
|
{}
|
2001-02-26 12:53:35 +00:00
|
|
|
|
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathMacroTemplate::clone() const
|
2001-02-26 12:53:35 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
lyxerr << "cloning MacroTemplate!\n";
|
|
|
|
return new MathMacroTemplate(*this);
|
2001-02-26 12:53:35 +00:00
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int MathMacroTemplate::numargs() const
|
|
|
|
{
|
|
|
|
return numargs_;
|
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-06-27 15:33:55 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathMacroTemplate::numargs(int numargs)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
numargs_ = numargs;
|
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMacroTemplate::write(std::ostream & os, bool fragile) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
os << "\n\\newcommand{\\" << name_ << "}";
|
|
|
|
|
|
|
|
if (numargs_ > 0)
|
|
|
|
os << "[" << numargs_ << "]";
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
os << "{";
|
2001-07-26 06:56:43 +00:00
|
|
|
cell(0).write(os, fragile);
|
2001-02-13 17:08:51 +00:00
|
|
|
os << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMacroTemplate::metrics(MathStyles st)
|
2001-03-05 10:52:39 +00:00
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
xcell(0).metrics(st);
|
2001-06-25 00:06:33 +00:00
|
|
|
size_ = st;
|
|
|
|
width_ = xcell(0).width() + 4;
|
|
|
|
ascent_ = xcell(0).ascent() + 2;
|
|
|
|
descent_ = xcell(0).descent() + 2;
|
2001-03-05 10:52:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroTemplate::draw(Painter & pain, int x, int y)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xo(x);
|
|
|
|
yo(y);
|
|
|
|
xcell(0).draw(pain, x + 2, y + 1);
|
|
|
|
pain.rectangle(x, y - ascent(), width(), height(), LColor::blue);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|