]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
more mathed cleanup
[lyx.git] / src / mathed / math_macroarg.C
1 #include <config.h>
2
3 #include "math_macroarg.h"
4 #include "mathed/support.h"
5 #include "debug.h"
6
7
8 MathMacroArgument::MathMacroArgument()
9         : expnd_mode_(false), number_(1)
10 {
11         SetType(LM_OT_MACRO_ARG);
12 }
13
14
15 MathMacroArgument::MathMacroArgument(int n)
16         : expnd_mode_(false), number_(n)
17 {
18         SetType(LM_OT_MACRO_ARG);
19 }
20
21
22 MathMacroArgument::~MathMacroArgument()
23 {
24         lyxerr << "help, destroyme!" << std::endl;
25 }
26
27
28 MathedInset * MathMacroArgument::Clone()
29 {
30         return this;
31 }
32
33
34 void MathMacroArgument::setNumber(int n)
35 {
36         number_ = n;
37 }
38
39
40 void MathMacroArgument::setExpand(bool e)
41 {
42         expnd_mode_ = e;
43 }
44
45
46 bool MathMacroArgument::getExpand() const
47 {
48         return expnd_mode_;
49 }
50
51
52 void MathMacroArgument::draw(Painter & pain, int x, int baseline)
53 {
54         if (expnd_mode_) {
55                 MathParInset::draw(pain, x, baseline);
56         }
57         else {
58                 std::ostringstream ost;
59                 ost << '#' << number_;
60                 drawStr(pain, LM_TC_TEX, size, x, baseline, ost.str().c_str());
61         }
62 }
63
64 void MathMacroArgument::Metrics()
65 {
66         if (expnd_mode_) {
67                 MathParInset::Metrics();
68         } else {
69                 std::ostringstream ost;
70                 ost << '#' << number_;
71                 width = mathed_string_width(LM_TC_TEX, size, ost.str().c_str());
72                 mathed_string_height(LM_TC_TEX, size, ost.str().c_str(),
73                                      ascent, descent);
74         }
75 }
76
77
78 void MathMacroArgument::Write(ostream & os, bool fragile)
79 {
80         if (expnd_mode_) {
81                 MathParInset::Write(os, fragile);
82         } else {
83                 os << '#' << number_ << ' ';
84         }
85 }