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-04-24 16:13:38 +00:00
|
|
|
#include "math_macro.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
#include "math_macroarg.h"
|
|
|
|
#include "mathed/support.h"
|
2001-03-01 16:49:31 +00:00
|
|
|
#include "Lsstream.h"
|
2001-04-24 16:13:38 +00:00
|
|
|
#include "debug.h"
|
2001-02-13 17:08:51 +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
|
|
|
MathMacroArgument::MathMacroArgument(int n)
|
|
|
|
: MathedInset(string(), LM_OT_MACRO_ARG, LM_ST_TEXT),
|
|
|
|
number_(n)
|
|
|
|
{
|
|
|
|
if (n < 1 || n > 9) {
|
|
|
|
lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
|
|
|
|
<< n << endl;
|
|
|
|
lyx::Assert(0);
|
|
|
|
}
|
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
MathedInset * MathMacroArgument::Clone()
|
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
//return new MathMacroArgument(*this);
|
2001-02-13 17:08:51 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
int MathMacroArgument::number() const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
return number_;
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroArgument::substitute(MathMacro * /*m*/)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
lyxerr << "Calling MathMacroArgument::substitute!\n";
|
|
|
|
//return m->arg(number_)->Clone();
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroArgument::draw(Painter & pain, int x, int y)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
char str[] = "#0";
|
|
|
|
str[1] += number_;
|
|
|
|
drawStr(pain, LM_TC_TEX, size(), x, y, str);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
|
2001-02-13 17:08:51 +00:00
|
|
|
void MathMacroArgument::Metrics()
|
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
char str[] = "#0";
|
|
|
|
str[1] += number_;
|
|
|
|
width = mathed_string_width(LM_TC_TEX, size(), str);
|
|
|
|
mathed_string_height(LM_TC_TEX, size(), str, ascent, descent);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-04-24 16:13:38 +00:00
|
|
|
os << '#' << number_ << ' ';
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
2001-04-24 16:13:38 +00:00
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
|
|
|
|
void MathMacroArgument::WriteNormal(std::ostream & os)
|
|
|
|
{
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "[macroarg " << number_ << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|