]> git.lyx.org Git - lyx.git/blob - src/mathed/math_charinset.C
cursor up/down; fix missing brace in write()
[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)
16 {
17         code(t);
18 }
19
20
21 MathInset * MathCharInset::clone() const
22 {   
23         return new MathCharInset(*this);
24 }
25
26
27 int MathCharInset::ascent() const
28 {
29         return mathed_char_ascent(code_, size(), char_);
30 }
31
32
33 int MathCharInset::descent() const
34 {
35         return mathed_char_descent(code_, size(), char_);
36 }
37
38
39 int MathCharInset::width() const
40 {
41         return mathed_char_width(code_, size(), char_);
42 }
43
44
45 void MathCharInset::metrics(MathStyles st) const
46 {
47         size_ = st;
48 }
49
50
51 void MathCharInset::draw(Painter & pain, int x, int y) const
52
53         xo(x);
54         yo(y);
55         drawChar(pain, code_, size_, x, y, char_);
56 }
57
58
59 void MathCharInset::write(std::ostream & os, bool) const
60 {
61         if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM) 
62                 os << '\\' << math_font_name[code_ - LM_TC_RM] << '{';
63
64         if ((code_ == LM_TC_TEX && char_ != '{' && char_ != '}') ||
65                         (code_ == LM_TC_SPECIAL))
66                 os << '\\';
67
68         os << char_;
69
70         if (code_ >= LM_TC_RM && code_ <= LM_TC_TEXTRM)
71                 os << '}';
72 }
73
74
75 void MathCharInset::writeNormal(std::ostream & os) const
76 {
77         os << char_;
78 }