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"
22 MetricsBase::MetricsBase()
23 : bv(0), font(), style(LM_ST_TEXT), fontname("mathnormal"),
29 MetricsBase::MetricsBase(BufferView * b, LyXFont const & f, int w)
30 : bv(b), font(f), style(LM_ST_TEXT), fontname("mathnormal"),
36 MetricsInfo::MetricsInfo()
40 MetricsInfo::MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth)
41 : base(bv, font, textwidth)
46 PainterInfo::PainterInfo(BufferView * bv)
53 void PainterInfo::draw(int x, int y, char c)
55 pain.text(x, y, c, base.font);
59 Styles smallerScriptStyle(Styles st)
66 case LM_ST_SCRIPTSCRIPT:
67 default: // shut up compiler
68 return LM_ST_SCRIPTSCRIPT;
72 ScriptChanger::ScriptChanger(MetricsBase & mb)
73 : StyleChanger(mb, smallerScriptStyle(mb.style))
78 Styles smallerFracStyle(Styles st)
86 case LM_ST_SCRIPTSCRIPT:
87 default: // shut up compiler
88 return LM_ST_SCRIPTSCRIPT;
93 FracChanger::FracChanger(MetricsBase & mb)
94 : StyleChanger(mb, smallerFracStyle(mb.style))
99 ArrayChanger::ArrayChanger(MetricsBase & mb)
100 : StyleChanger(mb, mb.style == LM_ST_DISPLAY ? LM_ST_TEXT : mb.style)
104 ShapeChanger::ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
105 : Changer<LyXFont, LyXFont::FONT_SHAPE>(font)
107 save_ = orig_.shape();
108 orig_.setShape(shape);
111 ShapeChanger::~ShapeChanger()
113 orig_.setShape(save_);
118 StyleChanger::StyleChanger(MetricsBase & mb, Styles style)
119 : Changer<MetricsBase>(mb)
121 static const int diff[4][4] = { { 0, 0, -3, -5 },
126 int t = diff[mb.style][style];
137 StyleChanger::~StyleChanger()
144 FontSetChanger::FontSetChanger(MetricsBase & mb, char const * name)
145 : Changer<MetricsBase>(mb)
150 augmentFont(mb.font, name);
154 FontSetChanger::~FontSetChanger()
160 WidthChanger::WidthChanger(MetricsBase & mb, int w)
161 : Changer<MetricsBase>(mb)
168 WidthChanger::~WidthChanger()
176 ColorChanger::ColorChanger(LyXFont & font, string const & color)
177 : Changer<LyXFont, string>(font)
179 save_ = lcolor.getFromLyXName(color);
180 font.setColor(lcolor.getFromLyXName(color));
184 ColorChanger::~ColorChanger()
186 orig_.setColor(lcolor.getFromLyXName(save_));