]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macroarg.C
get rid of several friends small 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         } else {
57                 std::ostringstream ost;
58                 ost << '#' << number_;
59                 drawStr(pain, LM_TC_TEX, size(), x, baseline, ost.str().c_str());
60         }
61 }
62
63 void MathMacroArgument::Metrics()
64 {
65         if (expnd_mode_) {
66                 MathParInset::Metrics();
67         } else {
68                 std::ostringstream ost;
69                 ost << '#' << number_;
70                 width = mathed_string_width(LM_TC_TEX, size(), ost.str().c_str());
71                 mathed_string_height(LM_TC_TEX, size(), ost.str().c_str(),
72                                      ascent, descent);
73         }
74 }
75
76
77 void MathMacroArgument::Write(ostream & os, bool fragile)
78 {
79         if (expnd_mode_) {
80                 MathParInset::Write(os, fragile);
81         } else {
82                 os << '#' << number_ << ' ';
83         }
84 }