]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
mathed67.diff
[lyx.git] / src / mathed / math_macroarg.C
1 #include <config.h>
2
3 #ifdef __GNUG__
4 #pragma implementation
5 #endif
6
7 #include "math_macro.h"
8 #include "math_macroarg.h"
9 #include "mathed/support.h"
10 #include "Lsstream.h"
11 #include "debug.h"
12
13
14 using namespace std;
15
16 MathMacroArgument::MathMacroArgument(int n)
17         : MathedInset(string(), LM_OT_MACRO_ARG, LM_ST_TEXT),
18                 number_(n)
19 {
20         if (n < 1 || n > 9) {
21                 lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
22                         << n << endl;
23                 lyx::Assert(0);
24         }
25 }
26
27 MathedInset * MathMacroArgument::Clone()
28 {
29         //return new MathMacroArgument(*this);
30         return this;
31 }
32
33 int MathMacroArgument::number() const
34 {
35         return number_;
36 }
37
38 void MathMacroArgument::substitute(MathMacro * /*m*/)
39 {
40         lyxerr << "Calling MathMacroArgument::substitute!\n";
41         //return m->arg(number_)->Clone();
42 }
43
44
45 void MathMacroArgument::draw(Painter & pain, int x, int y)
46 {
47         char str[] = "#0";
48         str[1] += number_; 
49         drawStr(pain, LM_TC_TEX, size(), x, y, str);
50 }
51
52
53 void MathMacroArgument::Metrics()
54 {
55         char str[] = "#0";
56         str[1] += number_; 
57         width = mathed_string_width(LM_TC_TEX, size(), str);
58         mathed_string_height(LM_TC_TEX, size(), str, ascent, descent);
59 }
60
61
62 void MathMacroArgument::Write(std::ostream & os, bool /*fragile*/)
63 {
64         os << '#' << number_ << ' ';
65 }
66
67
68 void MathMacroArgument::WriteNormal(std::ostream & os)
69 {
70         os << "[macroarg " << number_ << "] ";
71 }