]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroArgument.C
move everything into namespace lyx
[lyx.git] / src / mathed / MathMacroArgument.C
1 /**
2  * \file MathMacroArgument.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 "MathMacroArgument.h"
15 #include "InsetMathMacro.h"
16 #include "MathMLStream.h"
17 #include "MathSupport.h"
18 #include "debug.h"
19
20
21 namespace lyx {
22
23 using std::endl;
24 using std::auto_ptr;
25 using std::size_t;
26
27
28 MathMacroArgument::MathMacroArgument(size_t n)
29         : number_(n)
30 {
31         if (n < 1 || n > 9) {
32                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
33                         << n << endl;
34         }
35         str_[0] = '#';
36         str_[1] = static_cast<unsigned char>('0' + n);
37         str_[2] = '\0';
38 }
39
40
41 auto_ptr<InsetBase> MathMacroArgument::doClone() const
42 {
43         return auto_ptr<InsetBase>(new MathMacroArgument(*this));
44 }
45
46
47 void MathMacroArgument::write(WriteStream & os) const
48 {
49         os << str_;
50 }
51
52
53 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
54 {
55         mathed_string_dim(mi.base.font, from_utf8(str_), dim_);
56         dim = dim_;
57 }
58
59
60 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
61 {
62         // FIXME UNICODE
63         drawStrRed(pi, x, y, from_utf8(str_));
64         setPosCache(pi, x, y);
65 }
66
67
68 void MathMacroArgument::normalize(NormalStream & os) const
69 {
70         os << "[macroarg " << str_ << "] ";
71 }
72
73
74 } // namespace lyx