7 #include "math_metricsinfo.h"
8 #include "math_support.h"
10 #include "frontends/Painter.h"
14 MathMetricsBase::MathMetricsBase()
15 : font(), style(LM_ST_TEXT), fontname("mathnormal"),
16 restrictwidth(false), textwidth(0)
22 MathMetricsInfo::MathMetricsInfo()
29 MathPainterInfo::MathPainterInfo(Painter & p)
34 void MathPainterInfo::draw(int x, int y, char c)
36 pain.text(x, y, c, base.font);
40 MathStyles smallerScriptStyle(MathStyles st)
47 case LM_ST_SCRIPTSCRIPT:
48 return LM_ST_SCRIPTSCRIPT;
51 lyxerr << "should not happen\n";
55 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
56 : MathStyleChanger(mb, smallerScriptStyle(mb.style))
61 MathStyles smallerFracStyle(MathStyles st)
69 case LM_ST_SCRIPTSCRIPT:
70 return LM_ST_SCRIPTSCRIPT;
73 lyxerr << "should not happen\n";
77 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
78 : MathStyleChanger(mb, smallerFracStyle(mb.style))
83 MathArrayChanger::MathArrayChanger(MathMetricsBase & mb)
84 : MathStyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
88 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
89 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
91 save_ = orig_.shape();
92 orig_.setShape(shape);
95 MathShapeChanger::~MathShapeChanger()
97 orig_.setShape(save_);
102 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
103 : MathChanger<MathMetricsBase>(mb)
105 static const int diff[4][4] = { { 0, 0, -3, -5 },
110 int t = diff[mb.style][style];
120 MathStyleChanger::~MathStyleChanger()
127 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
128 : MathChanger<MathMetricsBase>(mb)
132 augmentFont(mb.font, name);
135 MathFontSetChanger::~MathFontSetChanger()
141 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
142 : MathChanger<MathMetricsBase>(mb)
145 mb.restrictwidth = true;
150 MathWidthChanger::~MathWidthChanger()