]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
split super/subscript handling in new base class MathUpDownInset and
[lyx.git] / src / mathed / math_macroarg.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_macroarg.h"
8 #include "math_macro.h"
9 #include "math_defs.h"
10 #include "mathed/support.h"
11 #include "support/LAssert.h"
12 #include "debug.h"
13
14
15
16 MathMacroArgument::MathMacroArgument(int n)
17         : number_(n)
18 {
19         if (n < 1 || n > 9) {
20                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
21                         << n << std::endl;
22                 lyx::Assert(0);
23         }
24 }
25
26
27 MathInset * MathMacroArgument::clone() const
28 {
29         return new MathMacroArgument(*this);
30 }
31
32
33 void MathMacroArgument::draw(Painter & pain, int x, int y)
34 {
35         char str[] = "#0";
36         str[1] += number_; 
37         drawStr(pain, LM_TC_TEX, size(), x, y, str);
38 }
39
40
41 void MathMacroArgument::Metrics(MathStyles st, int, int)
42 {
43         char str[] = "#0";
44         str[1] += number_; 
45         size_ = st;
46         mathed_string_dim(LM_TC_TEX, size(), str, ascent_, descent_, width_);
47 }
48
49
50 void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/) const
51 {
52         os << '#' << number_ << ' ';
53 }
54
55
56 void MathMacroArgument::WriteNormal(std::ostream & os) const
57 {
58         os << "[macroarg " << number_ << "] ";
59 }
60
61
62 void MathMacroArgument::substitute(MathArray & array, MathMacro const & m) const
63 {
64         array.push_back(m.cell(number_ - 1));
65 }
66