2001-02-13 17:08:51 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
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"
|
|
|
|
#include "math_macro.h"
|
|
|
|
#include "macro_support.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
#include "support/LOstream.h"
|
2001-02-28 17:51:28 +00:00
|
|
|
#include "support/LAssert.h"
|
2001-04-24 16:13:38 +00:00
|
|
|
#include "debug.h"
|
|
|
|
#include "Painter.h"
|
2001-02-14 15:00:50 +00:00
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
using namespace std;
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate() :
|
|
|
|
MathParInset(LM_ST_TEXT, "undefined", LM_OT_MACRO),
|
|
|
|
na_(0), users_()
|
|
|
|
{}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
MathMacroTemplate::MathMacroTemplate(string const & nm, int na) :
|
|
|
|
MathParInset(LM_ST_TEXT, nm, LM_OT_MACRO),
|
|
|
|
na_(na), users_()
|
|
|
|
{}
|
2001-02-26 12:53:35 +00:00
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
int MathMacroTemplate::nargs() const
|
2001-02-26 12:53:35 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
return na_;
|
2001-02-26 12:53:35 +00:00
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroTemplate::WriteDef(ostream & os, bool fragile) const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
|
|
|
os << "\n\\newcommand{\\" << name << "}";
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
if (na_ > 0)
|
2001-04-24 16:13:38 +00:00
|
|
|
os << "[" << na_ << "]";
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
os << "{";
|
2001-04-24 16:13:38 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
|
|
|
#warning stupid cast
|
|
|
|
#endif
|
|
|
|
const_cast<MathMacroTemplate *>(this)->Write(os, fragile);
|
2001-02-13 17:08:51 +00:00
|
|
|
os << "}\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroTemplate::Metrics()
|
2001-03-05 10:52:39 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
MathParInset::Metrics();
|
|
|
|
width += 4;
|
|
|
|
ascent += 2;
|
|
|
|
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-04-24 16:13:38 +00:00
|
|
|
MathParInset::draw(pain, x + 2, y + 1);
|
|
|
|
int w = Width();
|
|
|
|
int a = Ascent();
|
|
|
|
int h = Height();
|
|
|
|
pain.rectangle(x, y - a, w, h, LColor::blue);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
2001-04-25 15:43:57 +00:00
|
|
|
|