2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_macroarg.C
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2003-09-05 16:18:57 +00:00
|
|
|
|
#include "math_macroarg.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#include "math_macro.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
|
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
|
using std::endl;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-02-16 15:59:55 +00:00
|
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
MathMacroArgument::MathMacroArgument(int n)
|
2004-04-13 06:27:29 +00:00
|
|
|
|
: number_(n)
|
2001-04-24 16:13:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (n < 1 || n > 9) {
|
|
|
|
|
lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
|
2002-02-16 15:59:55 +00:00
|
|
|
|
<< n << endl;
|
2001-04-24 16:13:38 +00:00
|
|
|
|
}
|
2001-08-03 17:55:10 +00:00
|
|
|
|
str_[0] = '#';
|
2002-01-08 15:13:31 +00:00
|
|
|
|
str_[1] = static_cast<unsigned char>('0' + 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
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathMacroArgument::clone() const
|
2001-02-13 17:08:51 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(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
|
|
|
|
{
|
2002-05-30 07:09:54 +00:00
|
|
|
|
os << str_;
|
2001-02-13 17:08:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-02-13 17:08:51 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
mathed_string_dim(mi.base.font, str_, dim_);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2001-02-13 17:08:51 +00:00
|
|
|
|
}
|
2001-04-24 16:13:38 +00:00
|
|
|
|
|
2001-04-25 15:43:57 +00:00
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
|
2001-08-07 05:37:18 +00:00
|
|
|
|
{
|
2004-04-13 06:27:29 +00:00
|
|
|
|
drawStrRed(pi, x, y, str_);
|
2004-04-07 16:54:15 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
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
|
|
|
|
}
|