X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fmath_metricsinfo.C;h=f0938619ff15993620301f04414a5f9f8a238772;hb=254272868f1d891b9d0a778f871afb23cce84081;hp=e69de29bb2d1d6434b8b29ae775ad8c2e48c5391;hpb=970f0247f7d3ebbabc1348549ef4bd8d9b335545;p=lyx.git diff --git a/src/mathed/math_metricsinfo.C b/src/mathed/math_metricsinfo.C index e69de29bb2..f0938619ff 100644 --- a/src/mathed/math_metricsinfo.C +++ b/src/mathed/math_metricsinfo.C @@ -0,0 +1,149 @@ + +#include + +#include "math_metricsinfo.h" +#include "math_support.h" +#include "frontends/Painter.h" + + + +MathMetricsBase::MathMetricsBase() + : font(), style(LM_ST_TEXT), fontname("mathnormal") +{} + + + + +MathMetricsInfo::MathMetricsInfo() + : view(0), inset(0), idx(0), fullredraw(false) +{} + + + + +MathPainterInfo::MathPainterInfo(Painter & p) + : pain(p) +{} + + +void MathPainterInfo::draw(int x, int y, char c) +{ + pain.text(x, y, c, base.font); +} + + + + +MathScriptChanger::MathScriptChanger(MathMetricsBase & mb) + : MathChanger(mb) +{ + save_ = mb; + switch (mb.style) { + case LM_ST_DISPLAY: + case LM_ST_TEXT: + mb.style = LM_ST_SCRIPT; + mb.font.decSize(); + mb.font.decSize(); + break; + case LM_ST_SCRIPT: + mb.style = LM_ST_SCRIPTSCRIPT; + mb.font.decSize(); + default: + break; + } +} + +MathScriptChanger::~MathScriptChanger() +{ + orig_ = save_; +} + + + + +// decrease math size for fractions +MathFracChanger::MathFracChanger(MathMetricsBase & mb) + : MathChanger(mb) +{ + save_ = mb; + switch (mb.style) { + case LM_ST_DISPLAY: + mb.style = LM_ST_TEXT; + break; + case LM_ST_TEXT: + mb.style = LM_ST_SCRIPT; + mb.font.decSize(); + mb.font.decSize(); + break; + case LM_ST_SCRIPT: + mb.style = LM_ST_SCRIPTSCRIPT; + mb.font.decSize(); + break; + default: + break; + } +} + +MathFracChanger::~MathFracChanger() +{ + orig_ = save_; +} + + + + +MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape) + : MathChanger(font) +{ + save_ = orig_.shape(); + orig_.setShape(shape); +} + +MathShapeChanger::~MathShapeChanger() +{ + orig_.setShape(save_); +} + + + + +void changeSize(LyXFont & font, int diff) +{ + if (diff < 0) { + font.decSize(); + changeSize(font, diff + 1); + } else if (diff > 0) { + font.incSize(); + changeSize(font, diff - 1); + } +} + +MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style) + : MathChanger(mb) +{ + save_ = mb; + changeSize(mb.font, mb.style - style); +} + + +MathStyleChanger::~MathStyleChanger() +{ + orig_ = save_; +} + + + + +MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name) + : MathChanger(mb) +{ + save_ = mb; + mb.fontname = name; + augmentFont(mb.font, name); +} + +MathFontSetChanger::~MathFontSetChanger() +{ + orig_ = save_; +} +