lyx_mirror/src/mathed/math_macroarg.C
Lars Gullik Bjønnes d5905fabf6 get rid of several friends small cleanup
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1519 a592a061-630c-0410-9148-cb99ea01b6c8
2001-02-15 12:22:01 +00:00

85 lines
1.4 KiB
C

#include <config.h>
#include "math_macroarg.h"
#include "mathed/support.h"
#include "debug.h"
MathMacroArgument::MathMacroArgument()
: expnd_mode_(false), number_(1)
{
SetType(LM_OT_MACRO_ARG);
}
MathMacroArgument::MathMacroArgument(int n)
: expnd_mode_(false), number_(n)
{
SetType(LM_OT_MACRO_ARG);
}
MathMacroArgument::~MathMacroArgument()
{
lyxerr << "help, destroyme!" << std::endl;
}
MathedInset * MathMacroArgument::Clone()
{
return this;
}
void MathMacroArgument::setNumber(int n)
{
number_ = n;
}
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);
} else {
std::ostringstream ost;
ost << '#' << number_;
drawStr(pain, LM_TC_TEX, size(), x, baseline, ost.str().c_str());
}
}
void MathMacroArgument::Metrics()
{
if (expnd_mode_) {
MathParInset::Metrics();
} else {
std::ostringstream ost;
ost << '#' << number_;
width = mathed_string_width(LM_TC_TEX, size(), ost.str().c_str());
mathed_string_height(LM_TC_TEX, size(), ost.str().c_str(),
ascent, descent);
}
}
void MathMacroArgument::Write(ostream & os, bool fragile)
{
if (expnd_mode_) {
MathParInset::Write(os, fragile);
} else {
os << '#' << number_ << ' ';
}
}