]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
updates to latexfeatures stuff; allow empty \document_path
[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 "math_mathmlstream.h"
9 #include "math_support.h"
10 #include "debug.h"
11
12
13
14 MathMacroArgument::MathMacroArgument(int n)
15         : MathNestInset(1), number_(n), expanded_(false)
16 {
17         if (n < 1 || n > 9) {
18                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
19                         << n << std::endl;
20         }
21         str_[0] = '#';
22         str_[1] = static_cast<unsigned char>('0' + n);
23         str_[2] = '\0';
24 }
25
26
27 MathInset * MathMacroArgument::clone() const
28 {
29         return new MathMacroArgument(*this);
30 }
31
32
33 void MathMacroArgument::write(WriteStream & os) const
34 {
35         os << str_;
36 }
37
38
39 void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
40 {
41         mi_ = mi;
42         if (expanded_) {
43                 xcell(0).metrics(mi_);
44                 width_   = xcell(0).width();
45                 ascent_  = xcell(0).ascent();
46                 descent_ = xcell(0).descent();
47         } else
48                 mathed_string_dim(LM_TC_TEX, mi_, str_, ascent_, descent_, width_);
49 }
50
51
52 void MathMacroArgument::draw(Painter & pain, int x, int y) const
53 {
54         if (expanded_)
55                 xcell(0).draw(pain, x, y);
56         else
57                 drawStr(pain, LM_TC_TEX, mi_, x, y, str_);
58 }
59
60
61 void MathMacroArgument::normalize(NormalStream & os) const
62 {
63         os << "[macroarg " << str_ << "] ";
64 }
65
66
67 void MathMacroArgument::substitute(MathMacro const & m)
68 {
69         cell(0) = m.cell(number_ - 1);
70         expanded_ = true;
71 }
72