A bit more re-organization.
[lyx.git] / src / mathed / MathMacroArgument.cpp
blob68f4f98452ede5482bc22278af1863aa023d691f
1 /**
2 * \file MathMacroArgument.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
7 * \author André Pönitz
9 * Full author contact details are available in file CREDITS.
12 #include <config.h>
14 #include "MathMacroArgument.h"
15 #include "MathStream.h"
16 #include "MathSupport.h"
18 #include "support/debug.h"
21 namespace lyx {
23 MathMacroArgument::MathMacroArgument(int n)
24 : number_(n)
26 if (n < 1 || n > 9) {
27 LYXERR0("MathMacroArgument::MathMacroArgument: wrong Argument id: " << n);
30 // The profiler tells us not to use
31 // str_ = '#' + convert<docstring>(n);
32 // so we do the conversion of n to ASCII manually.
33 // This works because 1 <= n <= 9.
34 str_.resize(2);
35 str_[0] = '#';
36 str_[1] = '0' + n;
40 Inset * MathMacroArgument::clone() const
42 return new MathMacroArgument(*this);
46 void MathMacroArgument::setNumber(int n)
48 if (n < 1 || n > 9) {
49 LYXERR0("MathMacroArgument::setNumber: wrong Argument id: " << n);
52 number_ = n;
53 str_[1] = '0' + n;
57 void MathMacroArgument::write(WriteStream & os) const
59 os << str_;
63 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
65 mathed_string_dim(mi.base.font, str_, dim);
69 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
71 drawStrRed(pi, x, y, str_);
72 setPosCache(pi, x, y);
76 void MathMacroArgument::normalize(NormalStream & os) const
78 os << "[macroarg " << str_ << "] ";
82 } // namespace lyx