]> git.lyx.org Git - lyx.git/blob - src/mathed/math_accentinset.C
fix drawing glitch (\vec was almost invisible on screen)
[lyx.git] / src / mathed / math_accentinset.C
1 #include <config.h>
2
3 #include "math_accentinset.h"
4 #include "mathed/support.h"
5 #include "math_parser.h"
6 #include "support/LOstream.h"
7
8 using std::ostream;
9
10 MathAccentInset::MathAccentInset(int f)
11         : MathInset(1), code(f)
12 {}
13
14
15 MathInset * MathAccentInset::clone() const
16 {   
17         return new MathAccentInset(*this);
18 }
19
20 void MathAccentInset::Metrics(MathStyles st, int, int)
21 {
22         xcell(0).Metrics(st);
23         ascent_  = xcell(0).ascent();
24         descent_ = xcell(0).descent();
25         width_   = xcell(0).width();
26         dh = 5;
27
28         if (code == LM_not) {
29                 ascent_  += dh;
30                 descent_ += dh;
31                 dh = height();
32         } else 
33                 ascent_ += dh + 2;
34         
35         dy = ascent_;
36 }
37
38 void MathAccentInset::draw(Painter & pain, int x, int y)
39 {
40         xcell(0).draw(pain, x, y);
41         mathed_draw_deco(pain, x, y - dy, width(), dh, code);
42 }
43
44
45 void MathAccentInset::Write(ostream & os, bool fragile) const
46 {
47         latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
48         os << '\\' << l->name;
49         if (code == LM_not)
50                 os << ' ';
51         else
52                 os << '{';
53         
54         cell(0).Write(os, fragile);
55         
56         if (code != LM_not)
57                 os << '}';
58 }
59
60
61 void MathAccentInset::WriteNormal(ostream & os) const
62 {
63         latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
64         os << "[accent " << l->name << " ";
65
66         cell(0).WriteNormal(os);
67
68         os << "] ";
69 }