]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
Ensure all #warning statements are wrapped by #ifdef WITH_WARNINGS.
[lyx.git] / src / mathed / math_macroarg.C
1 /**
2  * \file math_macroarg.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "math_macroarg.h"
15 #include "math_macro.h"
16 #include "math_mathmlstream.h"
17 #include "math_support.h"
18 #include "debug.h"
19
20 using std::endl;
21 using std::auto_ptr;
22
23
24 MathMacroArgument::MathMacroArgument(int n)
25         : number_(n)
26 {
27         if (n < 1 || n > 9) {
28                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
29                         << n << endl;
30         }
31         str_[0] = '#';
32         str_[1] = static_cast<unsigned char>('0' + n);
33         str_[2] = '\0';
34 }
35
36
37 auto_ptr<InsetBase> MathMacroArgument::clone() const
38 {
39         return auto_ptr<InsetBase>(new MathMacroArgument(*this));
40 }
41
42
43 void MathMacroArgument::write(WriteStream & os) const
44 {
45         os << str_;
46 }
47
48
49 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51         mathed_string_dim(mi.base.font, str_, dim_);
52         dim = dim_;
53 }
54
55
56 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
57 {
58         drawStrRed(pi, x, y, str_);
59         setPosCache(pi, x, y);
60 }
61
62
63 void MathMacroArgument::normalize(NormalStream & os) const
64 {
65         os << "[macroarg " << str_ << "] ";
66 }