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-04-24 16:13:38 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate() :
|
2001-07-20 10:57:22 +00:00
|
|
|
MathInset(1, "undefined", LM_OT_MACRO), 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-06-25 00:06:33 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) :
|
2001-07-20 10:57:22 +00:00
|
|
|
MathInset(1, nm, LM_OT_MACRO), 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-06-27 15:33:55 +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-06-25 00:06:33 +00:00
|
|
|
cell(0).Write(os, fragile);
|
2001-02-13 17:08:51 +00:00
|
|
|
os << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-12 07:18:29 +00:00
|
|
|
void MathMacroTemplate::Metrics(MathStyles st, int, int)
|
2001-03-05 10:52:39 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
xcell(0).Metrics(st);
|
|
|
|
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
|
|
|
}
|