class MathSpaceInset;
class MathSymbolInset;
class MathUnknownInset;
-class MathXYMatrixInset;
-class MathXYMatrixInset;
class InsetRef;
virtual MathSymbolInset const * asSymbolInset() const { return 0; }
virtual MathUnknownInset * asUnknownInset() { return 0; }
virtual MathUnknownInset const * asUnknownInset() const { return 0; }
- virtual MathXYMatrixInset const* asXYMatrixInset() const{ return 0; }
virtual InsetRef * asInsetRef() { return 0; }
/// identifies things that can get scripts
#include "math_metricsinfo.h"
#include "math_support.h"
+#include "debug.h"
#include "frontends/Painter.h"
}
-
-
-MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
- : MathChanger<MathMetricsBase>(mb)
+MathStyles smallerScriptStyle(MathStyles st)
{
- save_ = mb;
- switch (mb.style) {
+ switch (st) {
case LM_ST_DISPLAY:
case LM_ST_TEXT:
- mb.style = LM_ST_SCRIPT;
- mb.font.decSize();
- mb.font.decSize();
- break;
+ return LM_ST_SCRIPT;
case LM_ST_SCRIPT:
- mb.style = LM_ST_SCRIPTSCRIPT;
- mb.font.decSize();
- default:
- break;
+ case LM_ST_SCRIPTSCRIPT:
+ return LM_ST_SCRIPTSCRIPT;
}
+ // shut up compiler
+ lyxerr << "should not happen\n";
+ return LM_ST_DISPLAY;
}
-MathScriptChanger::~MathScriptChanger()
-{
- orig_ = save_;
-}
+MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
+ : MathStyleChanger(mb, smallerScriptStyle(mb.style))
+{}
-// decrease math size for fractions
-MathFracChanger::MathFracChanger(MathMetricsBase & mb)
- : MathChanger<MathMetricsBase>(mb)
+MathStyles smallerFracStyle(MathStyles st)
{
- save_ = mb;
- switch (mb.style) {
+ switch (st) {
case LM_ST_DISPLAY:
- mb.style = LM_ST_TEXT;
- break;
+ return LM_ST_TEXT;
case LM_ST_TEXT:
- mb.style = LM_ST_SCRIPT;
- mb.font.decSize();
- mb.font.decSize();
- break;
+ return LM_ST_SCRIPT;
case LM_ST_SCRIPT:
- mb.style = LM_ST_SCRIPTSCRIPT;
- mb.font.decSize();
- break;
- default:
- break;
+ case LM_ST_SCRIPTSCRIPT:
+ return LM_ST_SCRIPTSCRIPT;
}
+ // shut up compiler
+ lyxerr << "should not happen\n";
+ return LM_ST_DISPLAY;
}
-MathFracChanger::~MathFracChanger()
-{
- orig_ = save_;
-}
+MathFracChanger::MathFracChanger(MathMetricsBase & mb)
+ : MathStyleChanger(mb, smallerFracStyle(mb.style))
+{}
-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)
{
+ static const int diff[4][4] = { { 0, 0, -3, -5 },
+ { 0, 0, -3, -5 },
+ { 3, 3, 0, -2 },
+ { 5, 5, 2, 0 } };
save_ = mb;
- changeSize(mb.font, mb.style - style);
+ int t = diff[mb.style][style];
+ if (t > 0)
+ while (t--)
+ mb.font.incSize();
+ else
+ while (t++)
+ mb.font.decSize();
+ mb.style = style;
}
-struct MathScriptChanger : public MathChanger<MathMetricsBase> {
- ///
- MathScriptChanger(MathMetricsBase & orig);
- ///
- ~MathScriptChanger();
-};
-
-
-struct MathFracChanger : public MathChanger<MathMetricsBase> {
- ///
- MathFracChanger(MathMetricsBase & orig);
- ///
- ~MathFracChanger();
-};
-
-
-
struct MathFontChanger : public MathChanger<LyXFont> {
///
MathFontChanger(LyXFont & orig, char const * font);
};
+struct MathScriptChanger : public MathStyleChanger {
+ ///
+ MathScriptChanger(MathMetricsBase & mb);
+};
+
+
+struct MathFracChanger : public MathStyleChanger {
+ ///
+ MathFracChanger(MathMetricsBase & mb);
+};
+
+
struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
///
MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);