3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
8 * Full author contact details are available in file CREDITS.
13 #include "metricsinfo.h"
14 #include "mathed/math_support.h"
15 #include "frontends/Painter.h"
16 #include "BufferView.h"
20 MetricsBase::MetricsBase()
21 : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
27 MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w)
28 : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
34 MetricsInfo::MetricsInfo()
38 MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
39 : base(bv, font, textwidth)
44 PainterInfo::PainterInfo(BufferView * bv)
51 void PainterInfo::draw(int x, int y, char c)
53 pain.text(x, y, c, base.font);
57 Styles smallerScriptStyle(Styles st)
64 case LM_ST_SCRIPTSCRIPT:
65 default: // shut up compiler
66 return LM_ST_SCRIPTSCRIPT;
70 ScriptChanger::ScriptChanger(MetricsBase & mb)
71 : StyleChanger(mb, smallerScriptStyle(mb.style))
76 Styles smallerFracStyle(Styles st)
84 case LM_ST_SCRIPTSCRIPT:
85 default: // shut up compiler
86 return LM_ST_SCRIPTSCRIPT;
91 FracChanger::FracChanger(MetricsBase & mb)
92 : StyleChanger(mb, smallerFracStyle(mb.style))
97 ArrayChanger::ArrayChanger(MetricsBase & mb)
98 : StyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
102 ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
103 : Changer<LyXFont, LyXFont::FONT_SHAPE>(font)
105 save_ = orig_.shape();
106 orig_.setShape(shape);
109 ShapeChanger::~ShapeChanger()
111 orig_.setShape(save_);
116 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
117 : Changer<MetricsBase>(mb)
119 static const int diff[4][4] = { { 0, 0, -3, -5 },
124 int t = diff[mb.style][style];
135 StyleChanger::~StyleChanger()
142 FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
143 : Changer<MetricsBase>(mb)
147 augmentFont(mb.font, name);
150 FontSetChanger::~FontSetChanger()
156 WidthChanger::WidthChanger(MetricsBase & mb, int w)
157 : Changer<MetricsBase>(mb)
164 WidthChanger::~WidthChanger()