]> git.lyx.org Git - features.git/commitdiff
several fixes concerning font size in scripts/fractions/etc
authorAndré Pönitz <poenitz@gmx.net>
Mon, 5 Aug 2002 16:21:19 +0000 (16:21 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 5 Aug 2002 16:21:19 +0000 (16:21 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4865 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/math_cursor.C
src/mathed/math_extern.C
src/mathed/math_inset.h
src/mathed/math_metricsinfo.C
src/mathed/math_metricsinfo.h
src/mathed/math_scriptinset.C

index 7d627af26871e0af7060e0a034ea8f1b0195c857..cc011e635963b12a55cbe2c6416ffaa111463e6f 100644 (file)
@@ -1332,7 +1332,7 @@ bool MathCursor::interpret(char c)
        // handle macroMode
        if (inMacroMode()) {
                string name = macroName();
-               lyxerr << "interpret name: '" << name << "'\n";
+               //lyxerr << "interpret name: '" << name << "'\n";
 
                if (name.empty() && c == '\\') {
                        backspace();
index c277617e50d5a599bbcf5ab8008b5bf4c6287801..921e59fce4fe5f3c43de26f24df88342f3015288 100644 (file)
@@ -441,7 +441,7 @@ void extractFunctions(MathArray & ar)
                // is it a function?
                if ((*it)->asUnknownInset()) {
                        // it certainly is if it is well known...
-                       name = (*it)->asUnknownInset()->name();
+                       name = (*it)->name();
                } else {
                        // is this a user defined function?
                        // it it probably not, if it doesn't have a name.
index 30a8e9ebde6c6853fbd2dd0681bec3b005ad2d27..8cd78be5b0b908affe2d9a7c0ffbd21256cab31e 100644 (file)
@@ -62,8 +62,6 @@ class MathStringInset;
 class MathSpaceInset;
 class MathSymbolInset;
 class MathUnknownInset;
-class MathXYMatrixInset;
-class MathXYMatrixInset;
 
 class InsetRef;
 
@@ -211,7 +209,6 @@ public:
        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
index 10e2e195f98923a9e7df4e0eb91f7312682f7cf6..1235e77b4b0ff692d5461719d539d1a4c4ef816a 100644 (file)
@@ -3,6 +3,7 @@
 
 #include "math_metricsinfo.h"
 #include "math_support.h"
+#include "debug.h"
 #include "frontends/Painter.h"
 
 
@@ -33,63 +34,48 @@ void MathPainterInfo::draw(int x, int y, char c)
 }
 
 
-
-
-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))
+{}
 
 
 
@@ -108,22 +94,22 @@ MathShapeChanger::~MathShapeChanger()
 
 
 
-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;
 }
 
 
index 6985a6d30927629f50e8a0a1b7ed905b1e496d58..bd8a46d15be1a9db2f4e22cb820f491b0a839151 100644 (file)
@@ -79,23 +79,6 @@ protected:
 
 
 
-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);
@@ -120,6 +103,18 @@ struct MathStyleChanger : public MathChanger<MathMetricsBase> {
 };
 
 
+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);
index cff1503225d8e59fe8282c3d40dc206df5aef1cd..f0023d9f66c9a02513ae6f1ea14dc064ae6d3a32 100644 (file)
@@ -184,8 +184,10 @@ int MathScriptInset::ndes() const
 
 void MathScriptInset::metrics(MathMetricsInfo & mi) const
 {
-       MathNestInset::metrics(mi);
+       cell(2).metrics(mi);
        MathScriptChanger dummy(mi.base);
+       cell(0).metrics(mi);
+       cell(1).metrics(mi);
        dim_.w = 0;
        if (hasLimits()) {
                dim_.w = nwid();