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";
53 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
54 : MathStyleChanger(mb, smallerScriptStyle(mb.style))
59 MathStyles smallerFracStyle(MathStyles st)
67 case LM_ST_SCRIPTSCRIPT:
68 return LM_ST_SCRIPTSCRIPT;
71 lyxerr << "should not happen\n";
76 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
77 : MathStyleChanger(mb, smallerFracStyle(mb.style))
82 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
83 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
85 save_ = orig_.shape();
86 orig_.setShape(shape);
89 MathShapeChanger::~MathShapeChanger()
91 orig_.setShape(save_);
97 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
98 : MathChanger<MathMetricsBase>(mb)
100 static const int diff[4][4] = { { 0, 0, -3, -5 },
105 int t = diff[mb.style][style];
116 MathStyleChanger::~MathStyleChanger()
124 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
125 : MathChanger<MathMetricsBase>(mb)
129 augmentFont(mb.font, name);
132 MathFontSetChanger::~MathFontSetChanger()
138 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
139 : MathChanger<MathMetricsBase>(mb)
142 mb.restrictwidth = true;
147 MathWidthChanger::~MathWidthChanger()