4 #include "metricsinfo.h"
5 #include "mathed/math_support.h"
6 #include "frontends/Painter.h"
8 #include "BufferView.h"
12 MetricsBase::MetricsBase()
13 : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
14 restrictwidth(false), textwidth(0)
19 MetricsBase::MetricsBase(BufferView * b, LyXFont const & f)
20 : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
21 restrictwidth(false), textwidth(0)
26 MetricsInfo::MetricsInfo()
30 MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font)
36 PainterInfo::PainterInfo(BufferView * bv)
43 void PainterInfo::draw(int x, int y, char c)
45 pain.text(x, y, c, base.font);
49 Styles smallerScriptStyle(Styles st)
56 case LM_ST_SCRIPTSCRIPT:
57 default: // shut up compiler
58 return LM_ST_SCRIPTSCRIPT;
62 ScriptChanger::ScriptChanger(MetricsBase & mb)
63 : StyleChanger(mb, smallerScriptStyle(mb.style))
68 Styles smallerFracStyle(Styles st)
76 case LM_ST_SCRIPTSCRIPT:
77 default: // shut up compiler
78 return LM_ST_SCRIPTSCRIPT;
83 FracChanger::FracChanger(MetricsBase & mb)
84 : StyleChanger(mb, smallerFracStyle(mb.style))
89 ArrayChanger::ArrayChanger(MetricsBase & mb)
90 : StyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
94 ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
95 : Changer<LyXFont, LyXFont::FONT_SHAPE>(font)
97 save_ = orig_.shape();
98 orig_.setShape(shape);
101 ShapeChanger::~ShapeChanger()
103 orig_.setShape(save_);
108 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
109 : Changer<MetricsBase>(mb)
111 static const int diff[4][4] = { { 0, 0, -3, -5 },
116 int t = diff[mb.style][style];
127 StyleChanger::~StyleChanger()
134 FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
135 : Changer<MetricsBase>(mb)
139 augmentFont(mb.font, name);
142 FontSetChanger::~FontSetChanger()
148 WidthChanger::WidthChanger(MetricsBase & mb, int w)
149 : Changer<MetricsBase>(mb)
152 mb.restrictwidth = true;
157 WidthChanger::~WidthChanger()