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(1), c(cx), fn(f), code(cd), inset(0)
15 MathAccentInset::MathAccentInset(MathInset * ins, int cd)
16 : MathInset(0), c(0), fn(LM_TC_MIN), code(cd), inset(ins)
20 MathAccentInset::~MathAccentInset()
26 MathInset * MathAccentInset::clone() const
31 p = new MathAccentInset(inset->clone(), code);
33 p = new MathAccentInset(c, fn, code);
39 void MathAccentInset::draw(Painter & pain, int x, int y)
41 int const dw = width() - 2;
44 inset->draw(pain, x, y);
46 drawChar(pain, fn, size(), x, y, c);
47 x += (code == LM_not) ? (width() - dw) / 2 : 2;
48 mathed_draw_deco(pain, x, y - dy, dw, dh, code);
52 void MathAccentInset::Metrics(MathStyles st)
56 ascent_ = inset->ascent();
57 descent_ = inset->descent();
58 width_ = inset->width();
61 mathed_char_dim(fn, size(), c, ascent_, descent_, width_);
72 // if (MathIsBinary(fn))
73 // width += 2*mathed_char_width(fn, size, ' ');
77 void MathAccentInset::Write(ostream & os, bool fragile) const
79 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
80 os << '\\' << l->name;
87 inset->Write(os, fragile);
89 if (fn>= LM_TC_RM && fn <= LM_TC_TEXTRM)
90 os << '\\' << math_font_name[fn - LM_TC_RM] << '{';
91 if (MathIsSymbol(fn)) {
92 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
94 os << '\\' << l->name << ' ';
98 if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
107 void MathAccentInset::WriteNormal(ostream & os) const
109 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
110 os << "[accent " << l->name << " ";
113 inset->WriteNormal(os);
115 if (fn >= LM_TC_RM && fn <= LM_TC_TEXTRM)
116 os << "[font " << math_font_name[fn - LM_TC_RM] << "]";
117 if (MathIsSymbol(fn)) {
118 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
120 os << "[symbol " << l->name << "] ";
122 os << "[char " << char(c) << "] ";
128 int MathAccentInset::getAccentCode() const