8 #include "math_metricsinfo.h"
9 #include "math_support.h"
11 #include "frontends/Painter.h"
15 MathMetricsBase::MathMetricsBase()
16 : font(), style(LM_ST_TEXT), fontname("mathnormal"),
17 restrictwidth(false), textwidth(0)
23 MathMetricsInfo::MathMetricsInfo()
30 MathPainterInfo::MathPainterInfo(Painter & p)
35 void MathPainterInfo::draw(int x, int y, char c)
37 pain.text(x, y, c, base.font);
41 MathStyles smallerScriptStyle(MathStyles st)
48 case LM_ST_SCRIPTSCRIPT:
49 return LM_ST_SCRIPTSCRIPT;
52 lyxerr << "should not happen\n";
56 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
57 : MathStyleChanger(mb, smallerScriptStyle(mb.style))
62 MathStyles smallerFracStyle(MathStyles st)
70 case LM_ST_SCRIPTSCRIPT:
71 return LM_ST_SCRIPTSCRIPT;
74 lyxerr << "should not happen\n";
78 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
79 : MathStyleChanger(mb, smallerFracStyle(mb.style))
84 MathArrayChanger::MathArrayChanger(MathMetricsBase & mb)
85 : MathStyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
89 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
90 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
92 save_ = orig_.shape();
93 orig_.setShape(shape);
96 MathShapeChanger::~MathShapeChanger()
98 orig_.setShape(save_);
103 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
104 : MathChanger<MathMetricsBase>(mb)
106 static const int diff[4][4] = { { 0, 0, -3, -5 },
111 int t = diff[mb.style][style];
121 MathStyleChanger::~MathStyleChanger()
128 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
129 : MathChanger<MathMetricsBase>(mb)
133 augmentFont(mb.font, name);
136 MathFontSetChanger::~MathFontSetChanger()
142 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
143 : MathChanger<MathMetricsBase>(mb)
146 mb.restrictwidth = true;
151 MathWidthChanger::~MathWidthChanger()