4 #include "math_metricsinfo.h"
5 #include "math_support.h"
7 #include "frontends/Painter.h"
11 MathMetricsBase::MathMetricsBase()
12 : font(), style(LM_ST_TEXT), fontname("mathnormal"),
13 restrictwidth(false), textwidth(0)
19 MathMetricsInfo::MathMetricsInfo()
26 MathPainterInfo::MathPainterInfo(Painter & p)
31 void MathPainterInfo::draw(int x, int y, char c)
33 pain.text(x, y, c, base.font);
37 MathStyles smallerScriptStyle(MathStyles st)
44 case LM_ST_SCRIPTSCRIPT:
45 return LM_ST_SCRIPTSCRIPT;
48 lyxerr << "should not happen\n";
52 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
53 : MathStyleChanger(mb, smallerScriptStyle(mb.style))
58 MathStyles smallerFracStyle(MathStyles st)
66 case LM_ST_SCRIPTSCRIPT:
67 return LM_ST_SCRIPTSCRIPT;
70 lyxerr << "should not happen\n";
74 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
75 : MathStyleChanger(mb, smallerFracStyle(mb.style))
80 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
81 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
83 save_ = orig_.shape();
84 orig_.setShape(shape);
87 MathShapeChanger::~MathShapeChanger()
89 orig_.setShape(save_);
94 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
95 : MathChanger<MathMetricsBase>(mb)
97 static const int diff[4][4] = { { 0, 0, -3, -5 },
102 int t = diff[mb.style][style];
112 MathStyleChanger::~MathStyleChanger()
119 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
120 : MathChanger<MathMetricsBase>(mb)
124 augmentFont(mb.font, name);
127 MathFontSetChanger::~MathFontSetChanger()
133 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
134 : MathChanger<MathMetricsBase>(mb)
137 mb.restrictwidth = true;
142 MathWidthChanger::~MathWidthChanger()