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 MathArrayChanger::MathArrayChanger(MathMetricsBase & mb)
81 : MathStyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
85 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
86 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
88 save_ = orig_.shape();
89 orig_.setShape(shape);
92 MathShapeChanger::~MathShapeChanger()
94 orig_.setShape(save_);
99 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
100 : MathChanger<MathMetricsBase>(mb)
102 static const int diff[4][4] = { { 0, 0, -3, -5 },
107 int t = diff[mb.style][style];
117 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()