]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
mathed108.diff
[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 }
21
22
23 MathInset * MathMacroArgument::clone() const
24 {
25         return new MathMacroArgument(*this);
26 }
27
28
29 void MathMacroArgument::draw(Painter & pain, int x, int y)
30 {
31         char str[] = "#0";
32         str[1] += number_; 
33         drawStr(pain, LM_TC_TEX, size(), x, y, str);
34 }
35
36
37 void MathMacroArgument::Metrics(MathStyles st)
38 {
39         char str[] = "#0";
40         str[1] += number_; 
41         size_ = st;
42         mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
43 }
44
45
46 void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/) const
47 {
48         os << '#' << number_ << ' ';
49 }
50
51
52 void MathMacroArgument::WriteNormal(std::ostream & os) const
53 {
54         os << "[macroarg " << number_ << "] ";
55 }
56
57
58 void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
59 {
60         array.push_back(m.cell(number_ - 1));
61 }
62