2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file MathMacroArgument.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* 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>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathMacroArgument.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathSupport.h"
|
2007-11-01 11:13:07 +00:00
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
|
#include "debug.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2004-07-23 22:31:14 +00:00
|
|
|
|
MathMacroArgument::MathMacroArgument(size_t n)
|
2004-04-13 06:27:29 +00:00
|
|
|
|
: number_(n)
|
2001-04-24 16:13:38 +00:00
|
|
|
|
{
|
|
|
|
|
if (n < 1 || n > 9) {
|
2007-11-28 22:12:03 +00:00
|
|
|
|
LYXERR0("MathMacroArgument::MathMacroArgument: wrong Argument id: " << n);
|
2001-04-24 16:13:38 +00:00
|
|
|
|
}
|
2007-11-01 11:13:07 +00:00
|
|
|
|
|
2007-05-28 22:27:45 +00:00
|
|
|
|
// The profiler tells us not to use
|
2006-11-20 14:07:30 +00:00
|
|
|
|
// str_ = '#' + convert<docstring>(n);
|
|
|
|
|
// so we do the conversion of n to ASCII manually.
|
|
|
|
|
// This works because 1 <= n <= 9.
|
|
|
|
|
str_.resize(2);
|
|
|
|
|
str_[0] = '#';
|
|
|
|
|
str_[1] = '0' + n;
|
2001-04-24 16:13:38 +00:00
|
|
|
|
}
|
2001-02-13 17:08:51 +00:00
|
|
|
|
|
2001-05-08 10:50:09 +00:00
|
|
|
|
|
2007-08-30 18:03:17 +00:00
|
|
|
|
Inset * MathMacroArgument::clone() const
|
2001-02-13 17:08:51 +00:00
|
|
|
|
{
|
2007-08-30 22:30:31 +00:00
|
|
|
|
return new MathMacroArgument(*this);
|
2001-02-13 17:08:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-11-28 22:12:03 +00:00
|
|
|
|
void MathMacroArgument::setNumber(size_t n)
|
2007-11-01 11:13:07 +00:00
|
|
|
|
{
|
|
|
|
|
if (n < 1 || n > 9) {
|
2007-11-28 22:12:03 +00:00
|
|
|
|
LYXERR0("MathMacroArgument::setNumber: wrong Argument id: " << n);
|
2007-11-01 11:13:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
number_ = n;
|
|
|
|
|
str_[1] = '0' + n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-02-13 17:08:51 +00:00
|
|
|
|
{
|
2006-11-28 15:15:49 +00:00
|
|
|
|
mathed_string_dim(mi.base.font, str_, 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
|
|
|
|
{
|
2006-10-22 10:15:23 +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
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|