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"
17 #include "BufferView.h"
21 MetricsBase::MetricsBase()
22 : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
28 MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w)
29 : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
35 MetricsInfo::MetricsInfo()
39 MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
40 : base(bv, font, textwidth)
45 PainterInfo::PainterInfo(BufferView * bv)
52 void PainterInfo::draw(int x, int y, char c)
54 pain.text(x, y, c, base.font);
58 Styles smallerScriptStyle(Styles st)
65 case LM_ST_SCRIPTSCRIPT:
66 default: // shut up compiler
67 return LM_ST_SCRIPTSCRIPT;
71 ScriptChanger::ScriptChanger(MetricsBase & mb)
72 : StyleChanger(mb, smallerScriptStyle(mb.style))
77 Styles smallerFracStyle(Styles st)
85 case LM_ST_SCRIPTSCRIPT:
86 default: // shut up compiler
87 return LM_ST_SCRIPTSCRIPT;
92 FracChanger::FracChanger(MetricsBase & mb)
93 : StyleChanger(mb, smallerFracStyle(mb.style))
98 ArrayChanger::ArrayChanger(MetricsBase & mb)
99 : StyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
103 ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
104 : Changer<LyXFont, LyXFont::FONT_SHAPE>(font)
106 save_ = orig_.shape();
107 orig_.setShape(shape);
110 ShapeChanger::~ShapeChanger()
112 orig_.setShape(save_);
117 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
118 : Changer<MetricsBase>(mb)
120 static const int diff[4][4] = { { 0, 0, -3, -5 },
125 int t = diff[mb.style][style];
136 StyleChanger::~StyleChanger()
143 FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
144 : Changer<MetricsBase>(mb)
148 augmentFont(mb.font, name);
151 FontSetChanger::~FontSetChanger()
157 WidthChanger::WidthChanger(MetricsBase & mb, int w)
158 : Changer<MetricsBase>(mb)
165 WidthChanger::~WidthChanger()