]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
- fix nasty bug due to missing InsetFormula copy c'tor
[lyx.git] / src / mathed / math_macroarg.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_macroarg.h"
6 #include "math_macro.h"
7 #include "math_defs.h"
8 #include "mathed/support.h"
9 #include "debug.h"
10
11
12
13 MathMacroArgument::MathMacroArgument(int n)
14         : number_(n)
15 {
16         if (n < 1 || n > 9) {
17                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
18                         << n << std::endl;
19         }
20         str_[0] = '#';
21         str_[1] = '0' + n;
22         str_[2] = '\0';
23 }
24
25
26 MathInset * MathMacroArgument::clone() const
27 {
28         return new MathMacroArgument(*this);
29 }
30
31
32 void MathMacroArgument::draw(Painter & pain, int x, int y) const
33 {
34         drawStr(pain, LM_TC_TEX, size(), x, y, str_);
35 }
36
37
38 int MathMacroArgument::ascent() const
39 {
40         return mathed_char_ascent(LM_TC_TEX, size(), 'I');
41 }
42
43
44 int MathMacroArgument::descent() const
45 {
46         return mathed_char_descent(LM_TC_TEX, size(), 'I');
47 }
48
49
50 int MathMacroArgument::width() const
51 {
52         return mathed_string_width(LM_TC_TEX, size(), str_);
53 }
54
55
56 void MathMacroArgument::write(std::ostream & os, bool /*fragile*/) const
57 {
58         os << '#' << number_ << ' ';
59 }
60
61
62 void MathMacroArgument::writeNormal(std::ostream & os) const
63 {
64         os << "[macroarg " << number_ << "] ";
65 }
66
67
68 void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
69 {
70         array.push_back(m.cell(number_ - 1));
71 }
72