2003-08-19 13:00:56 +00:00
|
|
|
/**
|
2017-07-05 12:31:28 +00:00
|
|
|
* \file InsetMathMacroArgument.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
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
#include "InsetMathMacroArgument.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
|
|
|
|
2007-11-29 07:04:28 +00:00
|
|
|
#include "support/debug.h"
|
2017-01-03 19:17:20 +00:00
|
|
|
#include "support/lassert.h"
|
2001-02-13 17:08:51 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2017-01-03 19:17:20 +00:00
|
|
|
|
|
|
|
Inset * InsetMathHash::clone() const
|
|
|
|
{
|
|
|
|
return new InsetMathHash(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathHash::write(WriteStream & os) const
|
|
|
|
{
|
|
|
|
os << str_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathHash::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
|
|
{
|
|
|
|
metricsStrRedBlack(mi, dim, str_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathHash::draw(PainterInfo & pi, int x, int y) const
|
|
|
|
{
|
|
|
|
drawStrRed(pi, x, y, str_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InsetMathHash::normalize(NormalStream & os) const
|
|
|
|
{
|
|
|
|
os << "[hash " << str_ << "] ";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
InsetMathMacroArgument::InsetMathMacroArgument(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) {
|
2017-07-05 12:31:28 +00:00
|
|
|
LYXERR0("InsetMathMacroArgument::InsetMathMacroArgument: wrong Argument id: "
|
2017-01-03 19:17:20 +00:00
|
|
|
<< n);
|
|
|
|
LASSERT(false, n = 1);
|
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_[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
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
Inset * InsetMathMacroArgument::clone() const
|
2001-02-13 17:08:51 +00:00
|
|
|
{
|
2017-07-05 12:31:28 +00:00
|
|
|
return new InsetMathMacroArgument(*this);
|
2001-02-13 17:08:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
void InsetMathMacroArgument::setNumber(int n)
|
2007-11-01 11:13:07 +00:00
|
|
|
{
|
|
|
|
if (n < 1 || n > 9) {
|
2017-07-05 12:31:28 +00:00
|
|
|
LYXERR0("InsetMathMacroArgument::setNumber: wrong Argument id: " << n);
|
2017-01-03 19:17:20 +00:00
|
|
|
LASSERT(false, return);
|
2007-11-01 11:13:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
number_ = n;
|
|
|
|
str_[1] = '0' + n;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-05 12:31:28 +00:00
|
|
|
void InsetMathMacroArgument::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
|