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()
20 : view(0), fullredraw(false)
26 MathPainterInfo::MathPainterInfo(Painter & p)
31 void MathPainterInfo::draw(int x, int y, char c)
33 pain.text(x, y, c, base.font);
39 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
40 : MathChanger<MathMetricsBase>(mb)
46 mb.style = LM_ST_SCRIPT;
51 mb.style = LM_ST_SCRIPTSCRIPT;
58 MathScriptChanger::~MathScriptChanger()
66 // decrease math size for fractions
67 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
68 : MathChanger<MathMetricsBase>(mb)
73 mb.style = LM_ST_TEXT;
76 mb.style = LM_ST_SCRIPT;
81 mb.style = LM_ST_SCRIPTSCRIPT;
89 MathFracChanger::~MathFracChanger()
97 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
98 : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
100 save_ = orig_.shape();
101 orig_.setShape(shape);
104 MathShapeChanger::~MathShapeChanger()
106 orig_.setShape(save_);
112 void changeSize(LyXFont & font, int diff)
116 changeSize(font, diff + 1);
117 } else if (diff > 0) {
119 changeSize(font, diff - 1);
123 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
124 : MathChanger<MathMetricsBase>(mb)
127 changeSize(mb.font, mb.style - style);
131 MathStyleChanger::~MathStyleChanger()
139 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
140 : MathChanger<MathMetricsBase>(mb)
144 augmentFont(mb.font, name);
147 MathFontSetChanger::~MathFontSetChanger()
153 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
154 : MathChanger<MathMetricsBase>(mb)
157 mb.restrictwidth = true;
162 MathWidthChanger::~MathWidthChanger()