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, MathedTextCodes f, int cd, short st)
11 : MathedInset("", LM_OT_ACCENT, st),
12 c(cx), fn(f), code(cd), inset(0)
16 MathAccentInset::MathAccentInset(MathedInset * ins, int cd, short st)
17 : MathedInset("", LM_OT_ACCENT, st),
18 c(0), fn(LM_TC_MIN), code(cd), inset(ins)
22 MathAccentInset::~MathAccentInset()
28 MathedInset * MathAccentInset::Clone()
33 p = new MathAccentInset(inset->Clone(), code, GetStyle());
35 p = new MathAccentInset(c, fn, code, GetStyle());
42 MathAccentInset::draw(Painter & pain, int x, int y)
44 int const dw = width - 2;
47 inset->draw(pain, x, y);
51 drawStr(pain, fn, size(), x, y, s);
53 x += (code == LM_not) ? (width - dw) / 2 : 2;
54 mathed_draw_deco(pain, x, y - dy, dw, dh, code);
59 MathAccentInset::Metrics()
63 ascent = inset->Ascent();
64 descent = inset->Descent();
65 width = inset->Width();
68 mathed_char_height(fn, size(), c, ascent, descent);
69 width = mathed_char_width(fn, size(), c);
80 // if (MathIsBinary(fn))
81 // width += 2*mathed_char_width(fn, size, ' ');
85 void MathAccentInset::Write(ostream & os, bool fragile)
87 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
88 os << '\\' << l->name;
95 inset->Write(os, fragile);
97 if (fn>= LM_TC_RM && fn <= LM_TC_TEXTRM) {
99 << math_font_name[fn - LM_TC_RM]
102 if (MathIsSymbol(fn)) {
103 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
105 os << '\\' << l->name << ' ';
110 if (fn>= LM_TC_RM && fn<= LM_TC_TEXTRM)
119 void MathAccentInset::WriteNormal(ostream & os)
121 latexkeys const * l = lm_get_key_by_id(code, LM_TK_ACCENT);
122 os << "[accent " << l->name << " ";
125 inset->WriteNormal(os);
127 if (fn>= LM_TC_RM && fn <= LM_TC_TEXTRM) {
128 os << "[font " << math_font_name[fn - LM_TC_RM] << "]";
130 if (MathIsSymbol(fn)) {
131 latexkeys const * l = lm_get_key_by_id(c, LM_TK_SYM);
133 os << "[symbol " << l->name << "] ";
135 os << "[char " << char(c) << "] ";