2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "math_metricsinfo.h"
|
|
|
|
#include "math_support.h"
|
|
|
|
#include "frontends/Painter.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathMetricsBase::MathMetricsBase()
|
2002-07-08 11:29:51 +00:00
|
|
|
: font(), style(LM_ST_TEXT), fontname("mathnormal"),
|
|
|
|
restrictwidth(false), textwidth(0)
|
2002-05-30 07:09:54 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MathMetricsInfo::MathMetricsInfo()
|
2002-08-02 12:38:20 +00:00
|
|
|
: fullredraw(false)
|
2002-05-30 07:09:54 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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<MathMetricsBase>(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<MathMetricsBase>(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<LyXFont, LyXFont::FONT_SHAPE>(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<MathMetricsBase>(mb)
|
|
|
|
{
|
|
|
|
save_ = mb;
|
|
|
|
changeSize(mb.font, mb.style - style);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathStyleChanger::~MathStyleChanger()
|
|
|
|
{
|
|
|
|
orig_ = save_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-06-05 07:12:05 +00:00
|
|
|
MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
|
2002-05-30 07:09:54 +00:00
|
|
|
: MathChanger<MathMetricsBase>(mb)
|
|
|
|
{
|
|
|
|
save_ = mb;
|
2002-06-05 07:12:05 +00:00
|
|
|
mb.fontname = name;
|
|
|
|
augmentFont(mb.font, name);
|
2002-05-30 07:09:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MathFontSetChanger::~MathFontSetChanger()
|
|
|
|
{
|
|
|
|
orig_ = save_;
|
|
|
|
}
|
|
|
|
|
2002-07-08 11:29:51 +00:00
|
|
|
|
|
|
|
MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
|
|
|
|
: MathChanger<MathMetricsBase>(mb)
|
|
|
|
{
|
|
|
|
save_ = mb;
|
|
|
|
mb.restrictwidth = true;
|
|
|
|
mb.textwidth = w;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathWidthChanger::~MathWidthChanger()
|
|
|
|
{
|
|
|
|
orig_ = save_;
|
|
|
|
}
|
|
|
|
|