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 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
85 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
87 save_ = orig_.shape();
88 orig_.setShape(shape);
91 MathShapeChanger::~MathShapeChanger()
93 orig_.setShape(save_);
98 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
99 : MathChanger<MathMetricsBase>(mb)
101 static const int diff[4][4] = { { 0, 0, -3, -5 },
106 int t = diff[mb.style][style];
116 MathStyleChanger::~MathStyleChanger()
123 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
124 : MathChanger<MathMetricsBase>(mb)
128 augmentFont(mb.font, name);
131 MathFontSetChanger::~MathFontSetChanger()
137 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
138 : MathChanger<MathMetricsBase>(mb)
141 mb.restrictwidth = true;
146 MathWidthChanger::~MathWidthChanger()