3 #include "math_accentinset.h"
4 #include "mathed/support.h"
5 #include "math_parser.h"
6 #include "support/LOstream.h"
10 MathAccentInset::MathAccentInset(byte cx, MathTextCodes f, int cd)
11 : MathInset("", LM_OT_ACCENT),
12 c(cx), fn(f), code(cd), inset(0)
16 MathAccentInset::MathAccentInset(MathInset * ins, int cd)
17 : MathInset("", LM_OT_ACCENT),
18 c(0), fn(LM_TC_MIN), code(cd), inset(ins)
22 MathAccentInset::~MathAccentInset()
28 MathInset * MathAccentInset::Clone() const
33 p = new MathAccentInset(inset->Clone(), code);
35 p = new MathAccentInset(c, fn, code);
41 void MathAccentInset::draw(Painter & pain, int x, int y)
43 int const dw = width() - 2;
46 inset->draw(pain, x, y);
48 drawChar(pain, fn, size(), x, y, c);
49 x += (code == LM_not) ? (width() - dw) / 2 : 2;
50 mathed_draw_deco(pain, x, y - dy, dw, dh, code);
54 void MathAccentInset::Metrics(MathStyles st)
58 ascent_ = inset->ascent();
59 descent_ = inset->descent();
60 width_ = inset->width();
63 mathed_char_dim(fn, size(), c, ascent_, descent_, width_);
74 // if (MathIsBinary(fn))
75 // width += 2*mathed_char_width(fn, size, ' ');
79 void MathAccentInset::Write(ostream & os, bool fragile) const
81 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
82 os << '\\' << l->name;
89 inset->Write(os, fragile);
91 if (fn>= LM_TC_RM && fn <= LM_TC_TEXTRM)
92 os << '\\' << math_font_name[fn - LM_TC_RM] << '{';
93 if (MathIsSymbol(fn)) {
94 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
96 os << '\\' << l->name << ' ';
100 if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
109 void MathAccentInset::WriteNormal(ostream & os) const
111 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
112 os << "[accent " << l->name << " ";
115 inset->WriteNormal(os);
117 if (fn >= LM_TC_RM && fn <= LM_TC_TEXTRM)
118 os << "[font " << math_font_name[fn - LM_TC_RM] << "]";
119 if (MathIsSymbol(fn)) {
120 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
122 os << "[symbol " << l->name << "] ";
124 os << "[char " << char(c) << "] ";
130 int MathAccentInset::getAccentCode() const