]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroArgument.C
Fix comment according to Enricos explanation
[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 "MathStream.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 using std::vector;
27
28
29 MathMacroArgument::MathMacroArgument(size_t n)
30         : number_(n)
31 {
32         if (n < 1 || n > 9) {
33                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
34                         << n << endl;
35         }
36         str_.resize(3);
37         str_[0] = '#';
38         str_[1] = static_cast<char_type>('0' + n);
39         str_[2] = '\0';
40 }
41
42
43 auto_ptr<InsetBase> MathMacroArgument::doClone() const
44 {
45         return auto_ptr<InsetBase>(new MathMacroArgument(*this));
46 }
47
48
49 void MathMacroArgument::write(WriteStream & os) const
50 {
51         os << str_;
52 }
53
54
55 void MathMacroArgument::metrics(MetricsInfo & mi, Dimension & dim) const
56 {
57         mathed_string_dim(mi.base.font, str_, dim_);
58         dim = dim_;
59 }
60
61
62 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
63 {
64         drawStrRed(pi, x, y, str_);
65         setPosCache(pi, x, y);
66 }
67
68
69 void MathMacroArgument::normalize(NormalStream & os) const
70 {
71         os << "[macroarg " << str_ << "] ";
72 }
73
74
75 } // namespace lyx