]> git.lyx.org Git - lyx.git/blob - src/mathed/MathMacroArgument.C
we rely on Windows and maybe Linux on a Qt bug
[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 "support/convert.h"
19 #include "debug.h"
20
21
22 namespace lyx {
23
24 using std::endl;
25 using std::auto_ptr;
26 using std::size_t;
27 using std::vector;
28
29
30 MathMacroArgument::MathMacroArgument(size_t n)
31         : number_(n)
32 {
33         if (n < 1 || n > 9) {
34                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
35                         << n << endl;
36         }
37         str_ = '#' + convert<docstring>(n);
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, str_, dim_);
56         dim = dim_;
57 }
58
59
60 void MathMacroArgument::draw(PainterInfo & pi, int x, int y) const
61 {
62         drawStrRed(pi, x, y, str_);
63         setPosCache(pi, x, y);
64 }
65
66
67 void MathMacroArgument::normalize(NormalStream & os) const
68 {
69         os << "[macroarg " << str_ << "] ";
70 }
71
72
73 } // namespace lyx