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_macroarg.h"
|
|
|
|
#include "mathed/support.h"
|
2001-03-01 16:49:31 +00:00
|
|
|
#include "Lsstream.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathMacroArgument::MathMacroArgument(int n)
|
2001-03-01 16:49:31 +00:00
|
|
|
: MathParInset(LM_ST_TEXT, "", LM_OT_MACRO_ARG),
|
|
|
|
expnd_mode_(false), number_(n)
|
|
|
|
{}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathedInset * MathMacroArgument::Clone()
|
|
|
|
{
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMacroArgument::setExpand(bool e)
|
|
|
|
{
|
|
|
|
expnd_mode_ = e;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathMacroArgument::getExpand() const
|
|
|
|
{
|
|
|
|
return expnd_mode_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathMacroArgument::draw(Painter & pain, int x, int baseline)
|
|
|
|
{
|
|
|
|
if (expnd_mode_) {
|
|
|
|
MathParInset::draw(pain, x, baseline);
|
2001-02-15 12:22:01 +00:00
|
|
|
} else {
|
2001-02-13 17:08:51 +00:00
|
|
|
std::ostringstream ost;
|
|
|
|
ost << '#' << number_;
|
2001-02-15 12:22:01 +00:00
|
|
|
drawStr(pain, LM_TC_TEX, size(), x, baseline, ost.str().c_str());
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MathMacroArgument::Metrics()
|
|
|
|
{
|
|
|
|
if (expnd_mode_) {
|
|
|
|
MathParInset::Metrics();
|
|
|
|
} else {
|
|
|
|
std::ostringstream ost;
|
|
|
|
ost << '#' << number_;
|
2001-03-01 16:49:31 +00:00
|
|
|
width = mathed_string_width(LM_TC_TEX, size(),
|
|
|
|
ost.str().c_str());
|
2001-02-15 12:22:01 +00:00
|
|
|
mathed_string_height(LM_TC_TEX, size(), ost.str().c_str(),
|
2001-02-13 17:08:51 +00:00
|
|
|
ascent, descent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-03-01 16:49:31 +00:00
|
|
|
void MathMacroArgument::Write(std::ostream & os, bool fragile)
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
|
|
|
if (expnd_mode_) {
|
|
|
|
MathParInset::Write(os, fragile);
|
|
|
|
} else {
|
|
|
|
os << '#' << number_ << ' ';
|
|
|
|
}
|
|
|
|
}
|