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-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2001-11-08 12:15:12 +00:00
|
|
|
#include "math_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-09-11 15:46:51 +00:00
|
|
|
: MathNestInset(1), number_(n), expanded_(false)
|
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] = '#';
|
2002-01-08 11:39:24 +00:00
|
|
|
str_[1] = '0' + static_cast<unsigned char>(n);
|
2001-08-03 17:55:10 +00:00
|
|
|
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-11-09 08:35:57 +00:00
|
|
|
void MathMacroArgument::write(WriteStream & os) const
|
2001-08-03 17:55:10 +00:00
|
|
|
{
|
2001-11-09 13:40:48 +00:00
|
|
|
os << str_;
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-10-22 15:37:49 +00:00
|
|
|
void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2001-10-22 15:37:49 +00:00
|
|
|
mi_ = mi;
|
2001-09-11 15:46:51 +00:00
|
|
|
if (expanded_) {
|
2001-10-22 15:37:49 +00:00
|
|
|
xcell(0).metrics(mi_);
|
2001-09-11 15:46:51 +00:00
|
|
|
width_ = xcell(0).width();
|
|
|
|
ascent_ = xcell(0).ascent();
|
|
|
|
descent_ = xcell(0).descent();
|
|
|
|
} else
|
2001-10-22 15:37:49 +00:00
|
|
|
mathed_string_dim(LM_TC_TEX, mi_, str_, ascent_, descent_, width_);
|
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-09-11 15:46:51 +00:00
|
|
|
void MathMacroArgument::draw(Painter & pain, int x, int y) const
|
2001-08-07 05:37:18 +00:00
|
|
|
{
|
2001-09-11 15:46:51 +00:00
|
|
|
if (expanded_)
|
|
|
|
xcell(0).draw(pain, x, y);
|
|
|
|
else
|
2001-10-22 15:37:49 +00:00
|
|
|
drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
|
2001-08-07 05:37:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
void MathMacroArgument::normalize(NormalStream & os) const
|
2001-04-25 15:43:57 +00:00
|
|
|
{
|
2001-11-09 13:40:48 +00:00
|
|
|
os << "[macroarg " << str_ << "] ";
|
2001-04-25 15:43:57 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
2001-09-11 15:46:51 +00:00
|
|
|
void MathMacroArgument::substitute(MathMacro const & m)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-09-11 15:46:51 +00:00
|
|
|
cell(0) = m.cell(number_ - 1);
|
|
|
|
expanded_ = true;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|