]> git.lyx.org Git - lyx.git/blob - src/mathed/math_charinset.C
small stuff
[lyx.git] / src / mathed / math_charinset.C
1 #ifdef __GNUG__
2 #pragma implementation
3 #endif
4
5 #include "math_charinset.h"
6 #include "LColor.h"
7 #include "Painter.h"
8 #include "support/LOstream.h"
9 #include "mathed/support.h"
10 #include "math_parser.h"
11 #include "debug.h"
12
13
14 MathCharInset::MathCharInset(char c, MathTextCodes t)
15         : char_(c), code_(t)
16 {}
17
18
19 MathInset * MathCharInset::clone() const
20 {   
21         return new MathCharInset(*this);
22 }
23
24
25 int MathCharInset::ascent() const
26 {
27         return mathed_char_ascent(code_, size(), char_);
28 }
29
30
31 int MathCharInset::descent() const
32 {
33         return mathed_char_descent(code_, size(), char_);
34 }
35
36
37 int MathCharInset::width() const
38 {
39         return mathed_char_width(code_, size(), char_);
40 }
41
42
43 void MathCharInset::metrics(MathStyles st) const
44 {
45         size_ = st;
46 }
47
48
49 void MathCharInset::draw(Painter & pain, int x, int y) const
50
51         xo(x);
52         yo(y);
53         drawChar(pain, code_, size_, x, y, char_);
54 }
55
56
57 void MathCharInset::write(std::ostream & os, bool) const
58 {
59         if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM) 
60                 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
61
62         if ((code_ == LM_TC_TEX && char_ != '{' && char_ != '}') ||
63                         (code_ == LM_TC_SPECIAL))
64                 os << '\\';
65
66         os << char_;
67
68         if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
69                 os << '}';
70 }
71
72
73 void MathCharInset::writeNormal(std::ostream & os) const
74 {
75         os << char_;
76 }
77
78
79 bool MathCharInset::isRelOp() const
80 {
81         return char_ == '=' || char_ == '<' || char_ == '>';
82 }
83
84
85 void MathCharInset::handleFont(MathTextCodes t)
86 {
87         code_ = (code_ == t) ? LM_TC_VAR : t;
88 }