2001-02-26 12:53:35 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma implementation
|
|
|
|
#endif
|
|
|
|
|
2001-02-13 17:08:51 +00:00
|
|
|
#include "math_macroarg.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "math_macro.h"
|
|
|
|
#include "math_defs.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
#include "mathed/support.h"
|
2001-04-24 16:13:38 +00:00
|
|
|
#include "debug.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
MathMacroArgument::MathMacroArgument(int n)
|
2001-06-25 00:06:33 +00:00
|
|
|
: number_(n)
|
2001-04-24 16:13:38 +00:00
|
|
|
{
|
|
|
|
if (n < 1 || n > 9) {
|
|
|
|
lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
|
2001-06-25 00:06:33 +00:00
|
|
|
<< n << std::endl;
|
2001-04-24 16:13:38 +00:00
|
|
|
}
|
2001-08-03 17:55:10 +00:00
|
|
|
str_[0] = '#';
|
|
|
|
str_[1] = '0' + n;
|
|
|
|
str_[2] = '\0';
|
2001-04-24 16:13:38 +00:00
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
|
2001-06-28 10:25:20 +00:00
|
|
|
MathInset * MathMacroArgument::clone() const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return new MathMacroArgument(*this);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathMacroArgument::draw(Painter & pain, int x, int y) const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-08-03 17:55:10 +00:00
|
|
|
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-08-03 17:55:10 +00:00
|
|
|
int MathMacroArgument::ascent() const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-08-03 17:55:10 +00:00
|
|
|
return mathed_char_ascent(LM_TC_TEX, size(), 'I');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathMacroArgument::descent() const
|
|
|
|
{
|
|
|
|
return mathed_char_descent(LM_TC_TEX, size(), 'I');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathMacroArgument::width() const
|
|
|
|
{
|
|
|
|
return mathed_string_width(LM_TC_TEX, size(), str_);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
|
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
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathMacroArgument::writeNormal(std::ostream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
{
|
2001-04-27 12:35:55 +00:00
|
|
|
os << "[macroarg " << number_ << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
2001-07-04 17:20:46 +00:00
|
|
|
void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-07-04 17:20:46 +00:00
|
|
|
array.push_back(m.cell(number_ - 1));
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|