]> git.lyx.org Git - features.git/commitdiff
fonts as insets
authorAndré Pönitz <poenitz@gmx.net>
Thu, 30 May 2002 07:09:54 +0000 (07:09 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 30 May 2002 07:09:54 +0000 (07:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4289 a592a061-630c-0410-9148-cb99ea01b6c8

113 files changed:
src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/formulabase.h
src/mathed/formulamacro.C
src/mathed/math_amsarrayinset.C
src/mathed/math_amsarrayinset.h
src/mathed/math_arrayinset.C
src/mathed/math_arrayinset.h
src/mathed/math_biginset.C
src/mathed/math_biginset.h
src/mathed/math_binaryopinset.C
src/mathed/math_binaryopinset.h
src/mathed/math_binominset.C
src/mathed/math_binominset.h
src/mathed/math_boxinset.C
src/mathed/math_boxinset.h
src/mathed/math_braceinset.C
src/mathed/math_braceinset.h
src/mathed/math_casesinset.C
src/mathed/math_casesinset.h
src/mathed/math_charinset.C
src/mathed/math_charinset.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_defs.h
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_diffinset.C
src/mathed/math_diffinset.h
src/mathed/math_dotsinset.C
src/mathed/math_dotsinset.h
src/mathed/math_exfuncinset.C
src/mathed/math_exfuncinset.h
src/mathed/math_exintinset.C
src/mathed/math_exintinset.h
src/mathed/math_extern.C
src/mathed/math_factory.C
src/mathed/math_factory.h
src/mathed/math_fontinset.C [new file with mode: 0644]
src/mathed/math_fontinset.h [new file with mode: 0644]
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_funcinset.C
src/mathed/math_funcinset.h
src/mathed/math_funcliminset.C
src/mathed/math_funcliminset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hash.C [deleted file]
src/mathed/math_hullinset.C
src/mathed/math_hullinset.h
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_kerninset.C
src/mathed/math_kerninset.h
src/mathed/math_lefteqninset.C
src/mathed/math_lefteqninset.h
src/mathed/math_limitopinset.C
src/mathed/math_limitopinset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_macroarg.C
src/mathed/math_macroarg.h
src/mathed/math_macrotable.C
src/mathed/math_macrotemplate.C
src/mathed/math_macrotemplate.h
src/mathed/math_matrixinset.h
src/mathed/math_metricsinfo.C
src/mathed/math_metricsinfo.h
src/mathed/math_nestinset.C
src/mathed/math_nestinset.h
src/mathed/math_notinset.C
src/mathed/math_notinset.h
src/mathed/math_parser.C
src/mathed/math_parser.h
src/mathed/math_rootinset.C
src/mathed/math_rootinset.h
src/mathed/math_scriptinset.C
src/mathed/math_scriptinset.h
src/mathed/math_sizeinset.C
src/mathed/math_sizeinset.h
src/mathed/math_spaceinset.C
src/mathed/math_spaceinset.h
src/mathed/math_specialcharinset.C
src/mathed/math_specialcharinset.h
src/mathed/math_sqrtinset.C
src/mathed/math_sqrtinset.h
src/mathed/math_stackrelinset.C
src/mathed/math_stackrelinset.h
src/mathed/math_stringinset.C
src/mathed/math_stringinset.h
src/mathed/math_substackinset.C
src/mathed/math_substackinset.h
src/mathed/math_support.C
src/mathed/math_support.h
src/mathed/math_symbolinset.C
src/mathed/math_symbolinset.h
src/mathed/math_undersetinset.C
src/mathed/math_undersetinset.h
src/mathed/math_unknowninset.C
src/mathed/math_unknowninset.h
src/mathed/math_xarrowinset.C
src/mathed/math_xarrowinset.h
src/mathed/math_xdata.C
src/mathed/math_xdata.h
src/mathed/math_xyarrowinset.C
src/mathed/math_xyarrowinset.h
src/mathed/math_xymatrixinset.C
src/mathed/math_xymatrixinset.h

index cd5999f8a7f754f6922ca114624e3c62b51b1ca7..d9a7e658722358a87e3a47c2a8434cebb4a93190 100644 (file)
@@ -1,3 +1,8 @@
+
+2002-05-30  André Pönitz <poenitz@gmx.net>
+
+       * *.[Ch]: "fonts as inset"
+
 2002-05-29  Lars Gullik Bjønnes  <larsbj@birdstep.com>
 
        * switch from SigC signals to boost::signals.
index 15659663aa205ec0197792fe53a36d0d81e6e567..29ceacc6c7d930a1b5e379ae39da82a297ecd86e 100644 (file)
@@ -58,17 +58,16 @@ libmathed_la_SOURCES = \
        math_exintinset.h \
        math_factory.C \
        math_factory.h \
+       math_fontinset.C \
+       math_fontinset.h \
        math_fracinset.C \
        math_fracinset.h \
        math_fracbase.C \
        math_fracbase.h \
-       math_funcinset.C \
-       math_funcinset.h \
        math_funcliminset.C \
        math_funcliminset.h \
        math_gridinset.C \
        math_gridinset.h \
-       math_hash.C \
        math_hullinset.C \
        math_hullinset.h \
        math_inset.C \
index f79bc5f3a53ac3bb160cec7ff0ea66957471f782..e0928cc6429192b8b19015d614e5700523e524c1 100644 (file)
@@ -353,19 +353,23 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
        int w = par_->width();
        int h = par_->height();
        int a = par_->ascent();
-       Painter & pain = bv->painter();
+
+       MathPainterInfo pi(bv->painter());
+       pi.base.font  = font;
+       pi.base.font.setColor(LColor::math);
+       pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT;
 
        if (lcolor.getX11Name(LColor::mathbg)!=lcolor.getX11Name(LColor::background))
-               pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
+               pi.pain.fillRectangle(x, y - a, w, h, LColor::mathbg);
 
        if (mathcursor &&
                        const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
        {
-               mathcursor->drawSelection(pain);
-               pain.rectangle(x, y - a, w, h, LColor::mathframe);
+               mathcursor->drawSelection(pi);
+               pi.pain.rectangle(x, y - a, w, h, LColor::mathframe);
        }
 
-       par_->draw(pain, x, y);
+       par_->draw(pi, x, y);
 
        // preview stuff
 #if 0
@@ -556,7 +560,7 @@ void InsetFormula::handleExtern(const string & arg)
                mathcursor->last();
                mathcursor->stripFromLastEqualSign();
                ar = mathcursor->cursor().cell();
-               mathcursor->insert(MathAtom(new MathCharInset('=', LM_TC_VAR)));
+               mathcursor->insert('=');
                //lyxerr << "use whole cell: " << ar << "\n";
        }
 
index 7b9a9e2c1c248ebd05aac4f0b59ea86739a6ba58..2258fa55aee37365b93102719fe474e58695e02b 100644 (file)
@@ -41,6 +41,7 @@
 #include "math_charinset.h"
 #include "math_cursor.h"
 #include "math_factory.h"
+#include "math_fontinset.h"
 #include "math_hullinset.h"
 #include "math_iterator.h"
 #include "math_macrotable.h"
@@ -68,6 +69,7 @@ int first_x;
 int first_y;
 
 
+
 bool openNewInset(BufferView * bv, UpdatableInset * new_inset)
 {
        if (!bv->insertInset(new_inset)) {
@@ -91,6 +93,7 @@ InsetFormulaBase::InsetFormulaBase()
        //lyxerr << "sizeof MathInset: " << sizeof(MathInset) << "\n";
        //lyxerr << "sizeof(MathMetricsInfo): " << sizeof(MathMetricsInfo) << "\n";
        //lyxerr << "sizeof(MathCharInset): " << sizeof(MathCharInset) << "\n";
+       //lyxerr << "sizeof(LyXFont): " << sizeof(LyXFont) << "\n";
 }
 
 
@@ -116,6 +119,21 @@ void InsetFormulaBase::mutateToText()
 }
 
 
+void InsetFormulaBase::handleFont
+       (BufferView * bv, string const & arg, string const & font)
+{
+       bv->lockedInsetStoreUndo(Undo::EDIT);
+       bool sel = mathcursor->selection();
+       if (sel)
+               updateLocal(bv, true);
+       mathcursor->handleNest(new MathFontInset(font));
+  for (string::const_iterator it = arg.begin(); it != arg.end(); ++it)
+    mathcursor->insert(*it);
+       if (!sel)
+               updateLocal(bv, false);
+}
+
+
 // Check if uses AMS macros
 void InsetFormulaBase::validate(LaTeXFeatures &) const
 {}
@@ -132,7 +150,12 @@ void InsetFormulaBase::metrics(BufferView * bv) const
 {
        if (bv)
                view_ = bv;
-       MathMetricsInfo mi(view_, font_, display() ? LM_ST_DISPLAY : LM_ST_TEXT);
+       MathMetricsInfo mi;
+       mi.view       = view_;
+       mi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT;
+       mi.base.font  = font_;
+       mi.base.font.setColor(LColor::math);
+       //whichFont(mi.font, LM_TC_MIN, mi);
        par()->metrics(mi);
 }
 
@@ -170,20 +193,6 @@ void InsetFormulaBase::edit(BufferView * bv, bool front)
 }
 
 
-void InsetFormulaBase::handleFont
-       (BufferView * bv, string const & arg, MathTextCodes t)
-{
-       if (mathcursor->selection()) {
-               bv->lockedInsetStoreUndo(Undo::EDIT);
-               updateLocal(bv, true);
-       }
-       mathcursor->handleFont(t);
-       for (string::const_iterator it = arg.begin(); it != arg.end(); ++it)
-               mathcursor->insert(*it);
-       updateLocal(bv, false);
-}
-
-
 void InsetFormulaBase::insetUnlock(BufferView * bv)
 {
        if (mathcursor) {
@@ -564,27 +573,27 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                break;
 
        //  Math fonts
-       case LFUN_GREEK_TOGGLE: handleFont(bv, arg, LM_TC_GREEK); break;
-       case LFUN_BOLD:         handleFont(bv, arg, LM_TC_BF); break;
-       case LFUN_SANS:         handleFont(bv, arg, LM_TC_SF); break;
-       case LFUN_EMPH:         handleFont(bv, arg, LM_TC_CAL); break;
-       case LFUN_ROMAN:        handleFont(bv, arg, LM_TC_RM); break;
-       case LFUN_CODE:         handleFont(bv, arg, LM_TC_TT); break;
-       case LFUN_FRAK:         handleFont(bv, arg, LM_TC_EUFRAK); break;
-       case LFUN_ITAL:         handleFont(bv, arg, LM_TC_IT); break;
-       case LFUN_NOUN:         handleFont(bv, arg, LM_TC_BB); break;
-       case LFUN_DEFAULT:      handleFont(bv, arg, LM_TC_VAR); break;
-       case LFUN_FREE:         handleFont(bv, arg, LM_TC_TEXTRM); break;
+       case LFUN_GREEK_TOGGLE: handleFont(bv, arg, "lyxgreek"); break;
+       case LFUN_BOLD:         handleFont(bv, arg, "textbf"); break;
+       case LFUN_SANS:         handleFont(bv, arg, "textsf"); break;
+       case LFUN_EMPH:         handleFont(bv, arg, "mathcal"); break;
+       case LFUN_ROMAN:        handleFont(bv, arg, "mathrm"); break;
+       case LFUN_CODE:         handleFont(bv, arg, "texttt"); break;
+       case LFUN_FRAK:         handleFont(bv, arg, "mathfrak"); break;
+       case LFUN_ITAL:         handleFont(bv, arg, "mathit"); break;
+       case LFUN_NOUN:         handleFont(bv, arg, "mathbb"); break;
+       case LFUN_DEFAULT:      handleFont(bv, arg, "textnormal"); break;
+       case LFUN_FREE:         handleFont(bv, arg, "textrm"); break;
 
        case LFUN_GREEK:
-               handleFont(bv, arg, LM_TC_GREEK1);
+               handleFont(bv, arg, "lyxgreek1");
                if (arg.size())
                        mathcursor->interpret(arg);
                break;
 
        case LFUN_MATH_MODE:
 #if 1
-               handleFont(bv, arg, LM_TC_TEXTRM);
+               handleFont(bv, arg, "textrm");
 #endif
 
 #if 0
@@ -724,6 +733,10 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                        result = UNDISPATCHED;
                break;
 
+       case LFUN_INSET_TOGGLE:
+               mathcursor->insetToggle();
+               break;
+
        default:
                result = UNDISPATCHED;
        }
@@ -748,10 +761,12 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
 }
 
 
-void InsetFormulaBase::revealCodes(BufferView * /*bv*/) const
+void InsetFormulaBase::revealCodes(BufferView * bv) const
 {
        if (!mathcursor)
                return;
+       bv->owner()->message(mathcursor->info());
+
 #if 0
        // write something to the minibuffer
        // translate to latex
@@ -899,8 +914,9 @@ void mathDispatchCreation(BufferView * bv, string const & arg, bool display)
                        // formula otherwise
                        if (sel.find("\\newcommand") == string::npos &&
                                  sel.find("\\def") == string::npos)
+                       {
                                f = new InsetFormula(sel);
-                       else {
+                       else {
                                string name;
                                if (!mathed_parse_macro(name, sel))
                                        return;
index 1f3f2157923d846e76b2a4de418b9045f4806d20..a91eed0b38d80c09e101176f92d2e6920096ca2d 100644 (file)
@@ -19,7 +19,6 @@
 #pragma interface
 #endif
 
-#include <iosfwd>
 #include "insets/inset.h"
 #include "frontends/mouse_state.h"
 #include "lyxfont.h"
@@ -27,6 +26,8 @@
 // only for getType():
 #include "math_defs.h"
 
+#include <iosfwd>
+
 class Buffer;
 class BufferView;
 class MathAtom;
@@ -134,7 +135,7 @@ protected:
        ///
        void metrics(BufferView * bv = 0) const;
        ///
-       void handleFont(BufferView * bv, string const & arg, MathTextCodes t);
+       void handleFont(BufferView * bv, string const & arg, string const & font);
 
        ///
        mutable int xo_;
index 8eb819d6ba1a5459a4217be3578a948da7f0ffb4..7e0493644dcfdb4ca6b87e20dd1495cab7a28788 100644 (file)
@@ -167,7 +167,7 @@ MathInsetTypes InsetFormulaMacro::getType() const
 void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
                             int y, float & xx, bool /*cleared*/) const
 {
-       Painter & pain = bv->painter();
+       MathPainterInfo pain = MathPainterInfo(bv->painter());
        LyXFont font(f);
 
        // label
@@ -179,14 +179,14 @@ void InsetFormulaMacro::draw(BufferView * bv, LyXFont const & f,
        int const h = ascent(bv, font) + descent(bv, font) - 2;
 
        // LColor::mathbg used to be "AntiqueWhite" but is "linen" now, too
-       pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
-       pain.rectangle(x, a, w, h, LColor::mathframe);
+       pain.pain.fillRectangle(x, a, w, h, LColor::mathmacrobg);
+       pain.pain.rectangle(x, a, w, h, LColor::mathframe);
 
        if (mathcursor &&
                        const_cast<InsetFormulaBase const *>(mathcursor->formula()) == this)
                mathcursor->drawSelection(pain);
 
-       pain.text(x + 2, y, prefix(), font);
+       pain.pain.text(x + 2, y, prefix(), font);
 
        // formula
        par()->draw(pain, x + font_metrics::width(prefix(), f) + 5, y);
index 367c44669dcbb151fd3486eb5875f50177f51279..f221f419f0322c4204a55cc83066da59c127e88a 100644 (file)
@@ -56,22 +56,22 @@ char const * MathAMSArrayInset::name_right() const
 }
 
 
-void MathAMSArrayInset::metrics(MathMetricsInfo const & st) const
+void MathAMSArrayInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       if (mi.style == LM_ST_DISPLAY)
-               mi.style = LM_ST_TEXT;
-       MathGridInset::metrics(mi);
+       MathMetricsInfo m = mi;
+       if (m.base.style == LM_ST_DISPLAY)
+               m.base.style = LM_ST_TEXT;
+       MathGridInset::metrics(m);
        width_ += 12;
 }
 
 
-void MathAMSArrayInset::draw(Painter & pain, int x, int y) const
+void MathAMSArrayInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       MathGridInset::draw(pain, x + 6, y);
+       MathGridInset::draw(pi, x + 6, y);
        int yy = y - ascent_;
-       mathed_draw_deco(pain, x + 1, yy, 5, height(), name_left());
-       mathed_draw_deco(pain, x + width_ - 6, yy, 5, height(), name_right());
+       mathed_draw_deco(pi, x + 1, yy, 5, height(), name_left());
+       mathed_draw_deco(pi, x + width_ - 6, yy, 5, height(), name_right());
 }
 
 
index 6f9d39809f8417e74720377baafeb1bd43d7e8f5..eb24eff9fead6babd0a2011d34657c041f4d288b 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter & pain, int x, int y) const;
+       void draw(MathPainterInfo & pain, int x, int y) const;
        ///
        MathAMSArrayInset * asAMSArrayInset() { return this; }
 
index b9e442d8fd6f8ee2fd4651361b6308ede8375ba8..d785b4cede6cb2707d87007380641cd5d78c058f 100644 (file)
@@ -65,12 +65,12 @@ MathInset * MathArrayInset::clone() const
 }
 
 
-void MathArrayInset::metrics(MathMetricsInfo const & st) const
+void MathArrayInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       if (mi.style == LM_ST_DISPLAY)
-               mi.style = LM_ST_TEXT;
-       MathGridInset::metrics(mi);
+       MathMetricsInfo m = mi;
+       if (m.base.style == LM_ST_DISPLAY)
+               m.base.style = LM_ST_TEXT;
+       MathGridInset::metrics(m);
 }
 
 
index 8a715370d20329a85395120381f7c1dd5ad46ae4..64c7d6f1691ad1b619db4cc0ab076dfabb6e9f0e 100644 (file)
@@ -23,7 +23,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        MathArrayInset * asArrayInset() { return this; }
 
index cff9a7d2393b4f9f7d6817301abd47ba8744337b..71e13e0723d7f7739e851cfba6ae63d790a90a91 100644 (file)
@@ -40,11 +40,9 @@ double MathBigInset::increase() const
 }
 
 
-void MathBigInset::metrics(MathMetricsInfo const & mi) const
+void MathBigInset::metrics(MathMetricsInfo & mi) const
 {
-       LyXFont font;
-       whichFont(font, LM_TC_VAR, mi);
-       double h = mathed_char_ascent(font, 'I');
+       double h = mathed_char_ascent(mi.base.font, 'I');
        double f = increase();
        width_   = 6;
        ascent_  = int(h + f * h);
@@ -52,9 +50,9 @@ void MathBigInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathBigInset::draw(Painter & pain, int x, int y) const
+void MathBigInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       mathed_draw_deco(pain, x + 1, y - ascent_, 4, height(), delim_);
+       mathed_draw_deco(pi, x + 1, y - ascent_, 4, height(), delim_);
 }
 
 
index daf0078db07530716eb7a77300789f5f0a14b7ad..2d16590c874e8786196448b9587a28749a654eb2 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        void normalize(NormalStream & os) const;
 
index 9a447379adbf633dd2d7ff3df1cdc17ea4b73f19..aaac72a1867c19725d0153fe0f543e5af40dca4f 100644 (file)
@@ -5,7 +5,7 @@
 #endif
 
 #include "math_binaryopinset.h"
-#include "frontends/Painter.h"
+#include "MathPainterInfo.h"
 #include "support/LOstream.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
@@ -31,7 +31,7 @@ int MathBinaryOpInset::opwidth() const
 }
 
 
-void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
+void MathBinaryOpInset::metrics(MathMetricsInfo & mi) const
 {
        mi_ = mi;
        xcell(0).metrics(mi);
@@ -42,7 +42,7 @@ void MathBinaryOpInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathBinaryOpInset::draw(Painter & pain, int x, int y) const
+void MathBinaryOpInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        xcell(0).draw(pain, x, y);
        drawChar(pain, LM_TC_CONST, mi_, x + xcell(0).width() , y, op_);
index cdd4db15730e4eddc4fd3eb929c9fc4edc035039..24cf79f4c58ae9d39e69ebd780a857c459617489 100644 (file)
@@ -19,13 +19,13 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
 private:
        ///
        int opwidth() const;
index 20732e7ccacfb374af4f2b19807d6ce042ff2071..cfdb835ca000c0dd9baaacba1e0777ae5042036b 100644 (file)
@@ -34,10 +34,9 @@ int MathBinomInset::dw() const
 }
 
 
-void MathBinomInset::metrics(MathMetricsInfo const & st) const
+void MathBinomInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       smallerStyleFrac(mi);
+       MathScriptChanger(mi.base);
        xcell(0).metrics(mi);
        xcell(1).metrics(mi);
        ascent_  = xcell(0).height() + 4 + 5;
@@ -46,13 +45,14 @@ void MathBinomInset::metrics(MathMetricsInfo const & st) const
 }
 
 
-void MathBinomInset::draw(Painter & pain, int x, int y) const
+void MathBinomInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int m = x + width() / 2;
-       xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
-       xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 3 - 5);
-       mathed_draw_deco(pain, x, y - ascent_, dw(), height(), "(");
-       mathed_draw_deco(pain, x + width() - dw(), y - ascent_, dw(), height(), ")");
+       MathScriptChanger(pi.base);
+       xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 3 - 5);
+       xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 3 - 5);
+       mathed_draw_deco(pi, x, y - ascent_, dw(), height(), "(");
+       mathed_draw_deco(pi, x + width() - dw(), y - ascent_,   dw(), height(), ")");
 }
 
 
index 3bac831efe615dc9ed090ef23495e9d116b8953e..a9c55dda61c3b83b96f7ef7d0ceb12574ec02549 100644 (file)
@@ -22,9 +22,9 @@ public:
        ///
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 private:
        ///
        int dw() const;
index 8065cd136dc16351d3b7748feec6cb69942f8130..eeb4005c55d0f075e56fd0792254344334b79f84 100644 (file)
@@ -41,7 +41,7 @@ void MathBoxInset::rebreak()
 }
 
 
-void MathBoxInset::draw(Painter & pain, int x, int y) const
+void MathBoxInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        MathGridInset::draw(pain, x, y);
        mathed_draw_framebox(pain, x, y, this);
index c2f4364daaf4b5ea371f9ffed1b26dde16796e61..0dfc8e44760caa4c344ca52eca9ec80bab018c9d 100644 (file)
@@ -30,7 +30,7 @@ public:
        ///
        void normalize(NormalStream &) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
 private:
        ///
index 9e73f782935e7da5a594db9279d8b1a107da7267..1d27ce03cb73fa40cfe94c542538f348a39e87a3 100644 (file)
@@ -24,23 +24,24 @@ MathInset * MathBraceInset::clone() const
 }
 
 
-void MathBraceInset::metrics(MathMetricsInfo const & mi) const
+void MathBraceInset::metrics(MathMetricsInfo & mi) const
 {
        xcell(0).metrics(mi);
        int a, d;
-       whichFont(font_, LM_TC_TEX, mi);
-       mathed_char_dim(font_, '{', a, d, wid_);
+       mathed_char_dim(mi.base.font, '{', a, d, wid_);
        ascent_  = max(xcell(0).ascent(), a);
        descent_ = max(xcell(0).descent(), a);
        width_   = xcell(0).width() + 2 * wid_;
 }
 
 
-void MathBraceInset::draw(Painter & pain, int x, int y) const
+void MathBraceInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       drawChar(pain, font_, x, y, '{');
-       xcell(0).draw(pain, x + wid_, y);
-       drawChar(pain, font_, x + width_ - wid_, y, '}');
+       LyXFont font = pi.base.font;
+       font.setColor(LColor::latex);
+       drawChar(pi, font, x, y, '{');
+       xcell(0).draw(pi, x + wid_, y);
+       drawChar(pi, font, x + width_ - wid_, y, '}');
 }
 
 
index adebc05bb0125210305f2fb08995abc7a1ddac81..d53af2dc350d64010a034272306fafa3d0851c6f 100644 (file)
@@ -22,19 +22,17 @@ public:
        ///
        MathBraceInset * asBraceInset() { return this; }
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        /// write normalized content
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
 
 private:
        /// width of brace character
        mutable int wid_;
-       ///
-       mutable LyXFont font_;
 };
 
 #endif
index 01acf7681206bf6daed6fc2139b8b947608f3f3b..94c83c0df726af46fc3c761f7499ac11feced4dd 100644 (file)
@@ -8,7 +8,6 @@
 #include "math_parser.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
-#include "frontends/Painter.h"
 
 
 MathCasesInset::MathCasesInset(row_type n)
@@ -22,14 +21,14 @@ MathInset * MathCasesInset::clone() const
 }
 
 
-void MathCasesInset::metrics(MathMetricsInfo const & mi) const
+void MathCasesInset::metrics(MathMetricsInfo & mi) const
 {
        MathGridInset::metrics(mi);
        width_ += 8;
 }
 
 
-void MathCasesInset::draw(Painter & pain, int x, int y) const
+void MathCasesInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        mathed_draw_deco(pain, x + 1, y - ascent(), 6, height(), "{");
        MathGridInset::draw(pain, x + 8, y);
index 07a83a2de64c7ec9890d05fb70ce6ae245f29af0..a7a3fc50269de6f2f3db38acc5778ef6f9c9ab37 100644 (file)
@@ -16,9 +16,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter & pain, int x, int y) const;
+       void draw(MathPainterInfo & pain, int x, int y) const;
 
        ///
        void normalize(NormalStream &) const;
index 38b4871e1968769cdc6172a4a8104acc461975f1..2d6ea5e72636af30901b93be6e6f2aeda196772e 100644 (file)
@@ -28,33 +28,27 @@ using std::isalpha;
 #endif
 
 
-bool isBinaryOp(char c, MathTextCodes type)
-{
-       return type < LM_TC_SYMB && strchr("+-<>=/*", c);
-}
+namespace {
 
+       bool isBinaryOp(char c)
+       {
+               return strchr("+-<>=/*", c);
+       }
 
-MathCharInset::MathCharInset(char c)
-       : char_(c), code_(nativeCode(c))
-{
-//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
-}
 
+       bool slanted(char c)
+       {
+               //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
+               return isalpha(c);
+       }
 
-MathCharInset::MathCharInset(char c, MathTextCodes t)
-       : char_(c), code_((t == LM_TC_MIN) ? nativeCode(c) : t)
-{
-//lyxerr << "creating char '" << char_ << "' with code " << int(code_) << endl;
 }
 
 
-MathTextCodes MathCharInset::nativeCode(char c)
-{
-       if (isalpha(c))
-               return LM_TC_VAR;
-       //if (strchr("0123456789;:!|[]().,?+/-*<>=", c)
-       return LM_TC_CONST;
-}
+MathCharInset::MathCharInset(char c)
+       : char_(c)
+{}
+
 
 
 MathInset * MathCharInset::clone() const
@@ -63,21 +57,41 @@ MathInset * MathCharInset::clone() const
 }
 
 
-void MathCharInset::metrics(MathMetricsInfo const & mi) const
+void MathCharInset::metrics(MathMetricsInfo & mi) const
 {
+#if 1
+       if (slanted(char_) && !mi.base.fontinset) {
+               MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
+               mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
+       } else {
+               mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
+       }
+       if (isBinaryOp(char_))
+               width_ += 2 * font_metrics::width(' ', mi.base.font);
+#else
        whichFont(font_, code_, mi);
        mathed_char_dim(font_, char_, ascent_, descent_, width_);
        if (isBinaryOp(char_, code_))
                width_ += 2 * font_metrics::width(' ', font_);
+#endif
 }
 
 
-void MathCharInset::draw(Painter & pain, int x, int y) const
+void MathCharInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       //lyxerr << "drawing '" << char_ << "' code: " << code_ << endl;
-       if (isBinaryOp(char_, code_))
-               x += font_metrics::width(' ', font_);
+       //lyxerr << "drawing '" << char_ << "' code: " << pi.code << endl;
+       if (isBinaryOp(char_))
+               x += font_metrics::width(' ', pi.base.font);
+#if 1
+       if (slanted(char_) && !pi.base.fontinset) {
+               MathShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE);
+               pi.draw(x, y, char_);
+       } else {
+               pi.draw(x, y, char_);
+       }
+#else
        drawChar(pain, font_, x, y, char_);
+#endif
 }
 
 
@@ -96,31 +110,9 @@ void MathCharInset::drawT(TextPainter & pain, int x, int y) const
 }
 
 
-void MathCharInset::writeHeader(ostream & os) const
-{
-       if (math_font_name(code_))
-               os << '\\' << math_font_name(code_) << '{';
-}
-
-
-void MathCharInset::writeTrailer(ostream & os) const
-{
-       if (math_font_name(code_))
-               os << '}';
-}
-
-
-void MathCharInset::writeRaw(ostream & os) const
-{
-       os << char_;
-}
-
-
 void MathCharInset::write(WriteStream & os) const
 {
-       writeHeader(os.os());
-       writeRaw(os.os());
-       writeTrailer(os.os());
+       os << char_;
 }
 
 
@@ -136,23 +128,8 @@ bool MathCharInset::isRelOp() const
 }
 
 
-void MathCharInset::handleFont(MathTextCodes t)
-{
-       code_ = (code_ == t) ? LM_TC_VAR : t;
-}
-
-
-void MathCharInset::validate(LaTeXFeatures & features) const
-{
-       // Make sure amssymb is put in preamble if Blackboard Bold or
-       // Fraktur used:
-       if ((code_ == LM_TC_BB) || (code_ == LM_TC_EUFRAK))
-               features.require("amssymb");
-}
-
-
 bool MathCharInset::match(MathInset * p) const
 {
        MathCharInset const * q = p->asCharInset();
-       return q && char_ == q->char_ && code_ == q->code_;
+       return q && char_ == q->char_;
 }
index 645c56a2cc01b73ada3aa9341ed1e7493c9d5986..da50061c494c1f3d37501151c5020b02aac839cb 100644 (file)
@@ -17,15 +17,11 @@ public:
        ///
        explicit MathCharInset(char c);
        ///
-       MathCharInset(char c, MathTextCodes t);
-       ///
        MathInset * clone() const;
        ///
-       static MathTextCodes nativeCode(char c);
-       ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(TextMetricsInfo const & st) const;
        ///
@@ -33,26 +29,14 @@ public:
        ///
        void write(WriteStream & os) const;
        ///
-       void writeHeader(std::ostream &) const;
-       ///
-       void writeTrailer(std::ostream &) const;
-       ///
-       void writeRaw(std::ostream &) const;
-       ///
        void normalize(NormalStream &) const;
        /// identifies Charinsets
        MathCharInset const * asCharInset() const { return this; }
        ///
        char getChar() const { return char_; }
        ///
-       MathTextCodes code() const { return code_; }
-       ///
        bool isRelOp() const;
        ///
-       void validate(LaTeXFeatures & features) const;
-       ///
-       void handleFont(MathTextCodes t);
-       ///
        bool match(MathInset *) const;
        /// identifies complicated things that need braces if used as arg
        bool needsBraces() const { return false; }
@@ -60,9 +44,5 @@ public:
 private:
        /// the character
        char char_;
-       /// the font to be used on screen
-       MathTextCodes code_;
-       ///
-       mutable LyXFont font_;
 };
 #endif
index ae212ae06b1254831c99dc41ef27353c9dc02fd4..a941eadec0ca4d7ba7fcef5f8e84308fe765d84f 100644 (file)
@@ -48,6 +48,7 @@
 #include "math_spaceinset.h"
 #include "math_specialcharinset.h"
 #include "math_support.h"
+#include "math_unknowninset.h"
 
 #include <algorithm>
 #include <cctype>
@@ -185,8 +186,7 @@ Selection theSelection;
 
 
 MathCursor::MathCursor(InsetFormulaBase * formula, bool left)
-       :       formula_(formula), lastcode_(LM_TC_MIN),
-               autocorrect_(false), selection_(false)
+       :       formula_(formula), autocorrect_(false), selection_(false)
 {
        left ? first() : last();
 }
@@ -306,11 +306,9 @@ bool MathCursor::left(bool sel)
        autocorrect_ = false;
        if (inMacroMode()) {
                macroModeClose();
-               lastcode_ = LM_TC_MIN;
                return true;
        }
        selHandle(sel);
-       lastcode_ = LM_TC_MIN;
 
        if (hasPrevAtom() && openable(prevAtom(), sel)) {
                pushRight(prevAtom());
@@ -327,11 +325,9 @@ bool MathCursor::right(bool sel)
        autocorrect_ = false;
        if (inMacroMode()) {
                macroModeClose();
-               lastcode_ = LM_TC_MIN;
                return true;
        }
        selHandle(sel);
-       lastcode_ = LM_TC_MIN;
 
        if (hasNextAtom() && openable(nextAtom(), sel)) {
                pushLeft(nextAtom());
@@ -395,7 +391,6 @@ void MathCursor::home(bool sel)
        autocorrect_ = false;
        selHandle(sel);
        macroModeClose();
-       lastcode_ = LM_TC_MIN;
        if (!par()->idxHome(idx(), pos()))
                popLeft();
        dump("home 2");
@@ -408,7 +403,6 @@ void MathCursor::end(bool sel)
        autocorrect_ = false;
        selHandle(sel);
        macroModeClose();
-       lastcode_ = LM_TC_MIN;
        if (!par()->idxEnd(idx(), pos()))
                popRight();
        dump("end 2");
@@ -424,7 +418,7 @@ void MathCursor::plainErase()
 void MathCursor::markInsert()
 {
        //lyxerr << "inserting mark\n";
-       array().insert(pos(), MathAtom(new MathCharInset(0, lastcode_)));
+       array().insert(pos(), MathAtom(new MathCharInset(0)));
 }
 
 
@@ -442,17 +436,11 @@ void MathCursor::plainInsert(MathAtom const & t)
 }
 
 
-void MathCursor::insert(char c, MathTextCodes t)
-{
-       //lyxerr << "inserting '" << c << "'\n";
-       selClearOrDel();
-       plainInsert(MathAtom(new MathCharInset(c, t)));
-}
-
-
 void MathCursor::insert(char c)
 {
-       insert(c, lastcode_);
+       //lyxerr << "inserting '" << c << "'\n";
+       selClearOrDel();        
+       plainInsert(MathAtom(new MathCharInset(c)));
 }
 
 
@@ -631,35 +619,21 @@ bool MathCursor::toggleLimits()
 
 void MathCursor::macroModeClose()
 {
-       MathInset::difference_type const t = macroNamePos();
-       if (t == -1)
+       MathUnknownInset * p = inMacroMode();
+       if (!p)
                return;
-       string s = macroName();
-       array().erase(t, pos());
-       pos() = t;
+       p->finalize();
+       string s = p->name();
+       --pos();
+       array().erase(pos());
        if (s != "\\")
                interpret(s);
 }
 
 
-MathInset::difference_type MathCursor::macroNamePos() const
-{
-       for (MathInset::difference_type i = pos() - 1; i >= 0; --i) {
-               MathAtom & p = array().at(i);
-               if (p->code() == LM_TC_TEX && p->getChar() == '\\')
-                       return i;
-       }
-       return -1;
-}
-
-
 string MathCursor::macroName() const
 {
-       string s;
-       MathInset::difference_type i = macroNamePos();
-       for (; i >= 0 && i < int(pos()); ++i)
-               s += array().at(i)->getChar();
-       return s;
+       return inMacroMode() ? inMacroMode()->name() : "";
 }
 
 
@@ -757,7 +731,7 @@ void MathCursor::selGet(MathArray & ar)
 
 
 
-void MathCursor::drawSelection(Painter & pain) const
+void MathCursor::drawSelection(MathPainterInfo & pain) const
 {
        if (!selection_)
                return;
@@ -772,7 +746,7 @@ void MathCursor::drawSelection(Painter & pain) const
                int y1 = c.yo() - c.ascent();
                int x2 = c.xo() + c.pos2x(i2.pos_);
                int y2 = c.yo() + c.descent();
-               pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+               pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
        } else {
                vector<MathInset::idx_type> indices
                        = i1.par_->idxBetween(i1.idx_, i2.idx_);
@@ -782,7 +756,7 @@ void MathCursor::drawSelection(Painter & pain) const
                        int y1 = c.yo() - c.ascent();
                        int x2 = c.xo() + c.width();
                        int y2 = c.yo() + c.descent();
-                       pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
+                       pain.pain.fillRectangle(x1, y1, x2 - x1, y2 - y1, LColor::selection);
                }
        }
 
@@ -800,23 +774,6 @@ void MathCursor::drawSelection(Painter & pain) const
 }
 
 
-void MathCursor::handleFont(MathTextCodes t)
-{
-       macroModeClose();
-       if (selection_) {
-               MathCursorPos i1;
-               MathCursorPos i2;
-               getSelection(i1, i2);
-               if (i1.idx_ == i2.idx_) {
-                       MathArray & ar = i1.cell();
-                       for (MathInset::pos_type pos = i1.pos_; pos != i2.pos_; ++pos)
-                               ar.at(pos)->handleFont(t);
-               }
-       } else
-               lastcode_ = (lastcode_ == t) ? LM_TC_VAR : t;
-}
-
-
 void MathCursor::handleDelim(string const & l, string const & r)
 {
        handleNest(new MathDelimInset(l, r));
@@ -883,9 +840,12 @@ MathCursor::pos_type & MathCursor::pos()
 }
 
 
-bool MathCursor::inMacroMode() const
+MathUnknownInset * MathCursor::inMacroMode() const
 {
-       return macroNamePos() != -1;
+       if (pos() == 0)
+               return 0;
+       MathUnknownInset * p = prevAtom()->asUnknownInset();
+       return (p && !p->final()) ? p : 0;
 }
 
 
@@ -1397,12 +1357,6 @@ bool MathCursor::interpret(string const & s)
                return true;
        }
 
-       latexkeys const * l = in_word_set(name);
-       if (l && (l->token == LM_TK_FONT || l->token == LM_TK_OLDFONT)) {
-               lastcode_ = static_cast<MathTextCodes>(l->id);
-               return true;
-       }
-
        // prevent entering of recursive macros
        if (formula()->lyxCode() == Inset::MATHMACRO_CODE
                && formula()->getInsetName() == name)
@@ -1461,7 +1415,7 @@ bool MathCursor::interpret(char c)
                int n = c - '0';
                MathMacroTemplate * p = formula()->par()->asMacroTemplate();
                if (p && 1 <= n && n <= p->numargs())
-                       insert(MathAtom(new MathMacroArgument(c - '0', lastcode_)));
+                       insert(MathAtom(new MathMacroArgument(c - '0')));
                else {
                        insert(MathAtom(new MathSpecialCharInset('#')));
                        interpret(c); // try again
@@ -1474,15 +1428,14 @@ bool MathCursor::interpret(char c)
                string name = macroName();
                //lyxerr << "interpret name: '" << name << "'\n";
 
-               // extend macro name if possible
-               if (isalpha(c)) {
-                       insert(c, LM_TC_TEX);
+               if (name.empty() && c == '\\') {
+                       backspace();
+                       interpret("\\backslash");
                        return true;
                }
 
-               // leave macro mode if explicitly requested
-               if (c == ' ') {
-                       macroModeClose();
+               if (isalpha(c)) {
+                       inMacroMode()->name() += c;
                        return true;
                }
 
@@ -1517,13 +1470,19 @@ bool MathCursor::interpret(char c)
 
        selClearOrDel();
 
-       if (lastcode_ == LM_TC_TEXTRM || par()->asBoxInset()) {
+       if (/*lastcode_ == LM_TC_TEXTRM ||*/ par()->asBoxInset()) {
                // suppress direct insertion of two spaces in a row
                // the still allows typing  '<space>a<space>' and deleting the 'a', but
                // it is better than nothing...
                if (c == ' ' && hasPrevAtom() && prevAtom()->getChar() == ' ')
                        return true;
-               insert(c, LM_TC_TEXTRM);
+               insert(c); // LM_TC_TEXTRM;
+               return true;
+       }
+
+       if (c == '\\') {
+               lyxerr << "starting with macro\n";
+               insert(MathAtom(new MathUnknownInset("\\", false)));
                return true;
        }
 
@@ -1539,13 +1498,13 @@ bool MathCursor::interpret(char c)
        }
 
        if (c == '#') {
-               insert(c, LM_TC_TEX);
+               insert(c); // LM_TC_TEX;
                return true;
        }
 
 /*
        if (c == '{' || c == '}', c)) {
-               insert(c, LM_TC_TEX);
+               insert(c); // LM_TC_TEX;
                return true;
        }
 */
@@ -1561,10 +1520,10 @@ bool MathCursor::interpret(char c)
 
        if (c == '$' || c == '%') {
                insert(MathAtom(new MathSpecialCharInset(c)));
-               lastcode_ = LM_TC_VAR;
                return true;
        }
 
+/*
        if (isalpha(c) && lastcode_ == LM_TC_GREEK) {
                insert(c, LM_TC_VAR);
                return true;
@@ -1581,15 +1540,15 @@ bool MathCursor::interpret(char c)
                //bv->owner()->message(_("TeX mode"));
                return true;
        }
+*/
 
        // try auto-correction
        if (autocorrect_ && hasPrevAtom() && math_autocorrect(prevAtom(), c))
                return true;
 
        // no special circumstances, so insert the character without any fuss
-       insert(c, lastcode_ == LM_TC_MIN ? MathCharInset::nativeCode(c) : lastcode_);
-       lastcode_ = LM_TC_MIN;
-       autocorrect_ = true;
+       insert(c);
+       autocorrect_ = true;  
        return true;
 }
 
@@ -1637,10 +1596,23 @@ void MathCursor::setSelection(cursor_type const & where, size_type n)
 }
 
 
+void MathCursor::insetToggle()
+{
+       if (hasNextAtom())
+               nextAtom()->lock(!nextAtom()->lock());
+}
+
+
 string MathCursor::info() const
 {
        ostringstream os;
-       if (pos() > 0)
-               prevAtom()->infoize(os);
+       os << "Math editor mode ";
+       for (int i = 0, n = Cursor_.size(); i < n; ++i) {
+               Cursor_[i].par_->infoize(os);
+               os << "  ";
+       }
+       //if (pos() > 0) 
+       //      prevAtom()->infoize(os);
+       os << "                ";
        return os.str().c_str(); // .c_str() needed for lyxstring
 }
index 350de76ad90177b7645a1e3b4236c61d75893d39..bdb4f26037bb6e73c7a7881c8a92269e351733b8 100644 (file)
 #pragma interface
 #endif
 
-#include "math_defs.h"
 #include "math_inset.h"
 #include "math_pos.h"
 #include "LString.h"
 
 class InsetFormulaBase;
-class Painter;
+class MathPainterInfo;
+class MathUnknownInset;
 class Selection;
 
 /**
@@ -127,7 +127,7 @@ public:
        /// interpret name a name of a macro
        void macroModeClose();
        /// are we currently typing the name of a macro?
-       bool inMacroMode() const;
+       MathUnknownInset * inMacroMode() const;
        /// are we currently typing '#1' or '#2' or...?
        bool inMacroArgMode() const;
 
@@ -153,9 +153,7 @@ public:
        ///
        void selGet(MathArray & ar);
        ///
-       void drawSelection(Painter & pain) const;
-       ///
-       void handleFont(MathTextCodes t);
+       void drawSelection(MathPainterInfo & pain) const;
        ///
        void handleDelim(string const & l, string const & r);
        ///
@@ -167,14 +165,12 @@ public:
        /// read contents of line into an array
        void readLine(MathArray & ar) const;
        /// remove this as soon as LyXFunc::getStatus is "localized"
-       MathTextCodes getLastCode() const { return lastcode_; }
+       string getLastCode() const { return "mathnormal"; }
        ///
        void pullArg(bool goright);
        ///
        bool isInside(MathInset const *) const;
        ///
-       MathTextCodes nextCode() const;
-       ///
        char valign() const;
        ///
        char halign() const;
@@ -244,6 +240,8 @@ public:
        void setSelection(cursor_type const & where, size_type n);
        ///
        void insert(char);
+       /// lock/unlock inset
+       void insetToggle();
 
        /// hack for reveal codes
        void markInsert();
@@ -270,8 +268,6 @@ private:
        string macroName() const;
        ///
        MathInset::difference_type macroNamePos() const;
-       ///
-       void insert(char, MathTextCodes t);
        /// can we enter the inset?
        bool openable(MathAtom const &, bool selection) const;
        /// write access to cursor cell position
@@ -285,12 +281,15 @@ private:
        mutable cursor_type Anchor_;
        /// pointer to enclsing LyX inset
        InsetFormulaBase * formula_;
+       // Selection stuff
        /// text code of last char entered
-       MathTextCodes lastcode_;
+       //MathTextCodes lastcode_;
        /// do we allow autocorrection
        bool autocorrect_;
        /// do we currently select
        bool selection_;
+       /// are we entering a macro name?
+       bool macromode_;
 };
 
 extern MathCursor * mathcursor;
index 0a70a07924db1af0cba46e3631a172c60583bb70..cccbed283951e539965a2989f4851559fc1ec831 100644 (file)
@@ -74,7 +74,7 @@ bool MathDecorationInset::wide() const
 }
 
 
-void MathDecorationInset::metrics(MathMetricsInfo const & mi) const
+void MathDecorationInset::metrics(MathMetricsInfo & mi) const
 {
        xcell(0).metrics(mi);
        width_   = xcell(0).width();
@@ -94,7 +94,7 @@ void MathDecorationInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathDecorationInset::draw(Painter & pain, int x, int y) const
+void MathDecorationInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        xcell(0).draw(pain, x, y);
        if (wide())
index 2c5866256625d515160d6a3c99070fdb584e1053..1c98714183194881cae434ecf4eaff4c11190ac2 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        void normalize(NormalStream & os) const;
        ///
index 03c03dd4ca7772379e8180ed3c8b981887d5cb35..284d61a41149fc509b432fa0e223fe793ac20ccc 100644 (file)
 #endif
 
 
-///
-enum MathTextCodes  {
-       ///
-       LM_TC_MIN = 0,
-       /// internal code for variables
-       LM_TC_VAR,
-       /// internal code for stuff in wrapped in mbox etc
-       LM_TC_BOX,
-       ///
-       LM_TC_CONST,
-       ///
-       LM_TC_RM,
-       ///
-       LM_TC_CAL,
-       ///
-       LM_TC_EUFRAK,
-       ///
-       LM_TC_BF,
-       //
-       LM_TC_BB,
-       ///
-       LM_TC_SF,
-       ///
-       LM_TC_TT,
-       ///
-       LM_TC_IT,
-       ///
-       LM_TC_TEXTRM,
-       /// math mode TeX characters ",;:{}"
-       LM_TC_TEX,
-       /// internal code when typing greek
-       LM_TC_GREEK,
-       /// internal code when typing a single greek character
-       LM_TC_GREEK1,
-       /// internal code for symbols
-       LM_TC_SYMB,
-       /// internal code for symbols that get bigger in displayed math
-       LM_TC_BOLDSYMB,
-       ///
-       LM_TC_CMR,
-       ///
-       LM_TC_CMSY,
-       ///
-       LM_TC_CMM,
-       ///
-       LM_TC_CMEX,
-       ///
-       LM_TC_MSA,
-       ///
-       LM_TC_MSB,
-       ///
-       LM_FONT_END
-};
-
-
 /// Types of lyx-math insets
 enum MathInsetTypes  {
        ///
@@ -104,13 +49,9 @@ enum MathInsetTypes  {
        LM_OT_MATRIX,
 
        /// A LaTeX macro
-       LM_OT_UNDEF,
-       ///
-       LM_OT_FUNCLIM,
-       ///
        LM_OT_MACRO,
        ///
-       LM_OT_MAX
+       LM_OT_NONE
 };
 
 #endif
index 84525f9d6844297ced15ee2829037c065698bc83..6fa100606c48b3dfd7ab7329b0f30453cc5b2423 100644 (file)
@@ -51,13 +51,11 @@ int MathDelimInset::dw() const
 }
 
 
-void MathDelimInset::metrics(MathMetricsInfo const & mi) const
+void MathDelimInset::metrics(MathMetricsInfo & mi) const
 {
        xcell(0).metrics(mi);
        int a, d, w;
-       LyXFont font;
-       whichFont(font, LM_TC_VAR, mi);
-       mathed_char_dim(font, 'I', a, d, w);
+       mathed_char_dim(mi.base.font, 'I', a, d, w);
        int h0   = (a + d) / 2;
        int a0   = max(xcell(0).ascent(), a)   - h0;
        int d0   = max(xcell(0).descent(), d)  + h0;
@@ -67,13 +65,13 @@ void MathDelimInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathDelimInset::draw(Painter & pain, int x, int y) const
+void MathDelimInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int const w = dw();
        int const b = y - ascent_;
-       xcell(0).draw(pain, x + w + 4, y);
-       mathed_draw_deco(pain, x + 4, b, w, height(), left_);
-       mathed_draw_deco(pain, x + width() - w - 4, b, w, height(), right_);
+       xcell(0).draw(pi, x + w + 4, y);
+       mathed_draw_deco(pi, x + 4, b, w, height(), left_);
+       mathed_draw_deco(pi, x + width() - w - 4, b, w, height(), right_);
 }
 
 
index c96ffa5924cb30ce63916d5919271b66c7b54391..2f8b7047cb6a067b4a7aa12ec23303cd23a76d46 100644 (file)
@@ -30,9 +30,9 @@ public:
        /// is it |...|?
        bool isAbs() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void write(WriteStream & os) const;
index 7708364b2db5772c22e7b753f922c0f041d94861..75d3852d193eb7bedf02badef1169d902e853390 100644 (file)
@@ -32,13 +32,13 @@ void MathDiffInset::normalize(NormalStream & os) const
 }
 
 
-void MathDiffInset::metrics(MathMetricsInfo const &) const
+void MathDiffInset::metrics(MathMetricsInfo &) const
 {
        lyxerr << "should not happen\n";
 }
 
 
-void MathDiffInset::draw(Painter &, int, int) const
+void MathDiffInset::draw(MathPainterInfo &, int, int) const
 {
        lyxerr << "should not happen\n";
 }
index 3957a8f21da5c34a5cdc6df3a4ba3fa0654eb164..284c822a2e9ac0ac23e2d2b076589162e8de5fe5 100644 (file)
@@ -16,9 +16,9 @@ public:
        ///
        void addDer(MathArray const & der);
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void normalize(NormalStream &) const;
index 839af0d3602ac319de5c0ac548cbc430d825588d..b6c460acb1352e3fc82b10c0fa2b703363580e6d 100644 (file)
@@ -21,11 +21,9 @@ MathInset * MathDotsInset::clone() const
 }
 
 
-void MathDotsInset::metrics(MathMetricsInfo const & mi) const
+void MathDotsInset::metrics(MathMetricsInfo & mi) const
 {
-       LyXFont font;
-       whichFont(font, LM_TC_VAR, mi);
-       mathed_char_dim(font, 'M', ascent_, descent_, width_);
+       mathed_char_dim(mi.base.font, 'M', ascent_, descent_, width_);
        if (name_ == "ldots" || name_ == "dotsm") 
                dh_ = 0;
        else if (name_ == "cdots" || name_ == "dotsb"
@@ -40,7 +38,7 @@ void MathDotsInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathDotsInset::draw(Painter & pain, int x, int y) const
+void MathDotsInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        mathed_draw_deco(pain, x + 2, y - dh_, width_ - 2, ascent_, name_);
        if (name_ == "vdots" || name_ == "ddots")
index 9ac4f722b9c553e45ec97abf65f4bbbbb6bc9202..be37fb641bbd7bb3d31095262a4cc9e01fad3f55 100644 (file)
@@ -17,13 +17,13 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
 protected:
        /// cache for the thing's heigth
        mutable int dh_;
index 84ab2df48978692dd5f93cb1ae36e16723cc3cef..ceb4d621fba05baace15c1e9d99a57f1ed08e52e 100644 (file)
@@ -17,16 +17,15 @@ MathInset * MathExFuncInset::clone() const
 }
 
 
-void MathExFuncInset::metrics(MathMetricsInfo const & mi) const
+void MathExFuncInset::metrics(MathMetricsInfo & mi) const
 {
-       whichFont(font_, LM_TC_TEXTRM, mi);
-       mathed_string_dim(font_, name_, ascent_, descent_, width_);
+       mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
 }
 
 
-void MathExFuncInset::draw(Painter & pain, int x, int y) const
+void MathExFuncInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       drawStr(pain, font_, x, y, name_);
+       drawStrBlack(pi, x, y, name_);
 }
 
 
index a9a7cdf182159596dbc757ecc0898185fb62ae4f..08d4a94620d6b43947fbb35421b1b93c04e0d61b 100644 (file)
@@ -14,9 +14,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void normalize(NormalStream &) const;
@@ -32,7 +32,5 @@ public:
 private:
        ///
        string const name_;
-       ///
-       mutable LyXFont font_;
 };
 #endif
index 212e87eecdda0be27ccb9a42864d849a9d8ccaa9..e26a74e6b69890d8e0a40749839bafab48e96e19 100644 (file)
@@ -49,13 +49,13 @@ void MathExIntInset::normalize(NormalStream & os) const
 }
 
 
-void MathExIntInset::metrics(MathMetricsInfo const &) const
+void MathExIntInset::metrics(MathMetricsInfo &) const
 {
        lyxerr << "should not happen" << endl;
 }
 
 
-void MathExIntInset::draw(Painter &, int, int) const
+void MathExIntInset::draw(MathPainterInfo &, int, int) const
 {
        lyxerr << "should not happen" << endl;
 }
index 67bebf3b2d0b39d72fd11c116bee643ee7fb683d..5ef2642c9d1e17f058619d6afae0ae9a562d0319 100644 (file)
@@ -17,9 +17,9 @@ public:
        ///
        void symbol(string const &);
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void normalize(NormalStream &) const;
index 0e0a5280124af19ad0824db6fbbf10e2c252878a..502c640e2d2d236725422e4b5f67f7bedd49e667 100644 (file)
 #include "math_diffinset.h"
 #include "math_exfuncinset.h"
 #include "math_exintinset.h"
-#include "math_funcinset.h"
 #include "math_fracinset.h"
 #include "math_matrixinset.h"
 #include "math_mathmlstream.h"
 #include "math_scriptinset.h"
 #include "math_stringinset.h"
 #include "math_symbolinset.h"
+#include "math_unknowninset.h"
 #include "Lsstream.h"
 #include "debug.h"
 
@@ -121,16 +121,10 @@ MathScriptInset const * asScript(MathArray::const_iterator it)
 // returns sequence of char with same code starting at it up to end
 // it might be less, though...
 MathArray::const_iterator charSequence(MathArray::const_iterator it,
-       MathArray::const_iterator end, string & s, MathTextCodes & c)
+       MathArray::const_iterator end, string & s)
 {
-       MathCharInset const * p = (*it)->asCharInset();
-       c = p->code();
-       for (; it != end; ++it) {
-               p = (*it)->asCharInset();
-               if (!p || p->code() != c)
-                       break;
-               s += p->getChar();
-       }
+       for (; it != end && (*it)->asCharInset(); ++it)
+               s += (*it)->getChar();
        return it;
 }
 
@@ -146,7 +140,7 @@ void extractStrings(MathArray & ar)
                // create proper string inset
                MathStringInset * p = new MathStringInset;
                MathArray::const_iterator
-                       jt = charSequence(it, ar.end(), p->str_, p->code_);
+                       jt = charSequence(it, ar.end(), p->str_);
 
                // clean up
                (*it).reset(p);
@@ -208,8 +202,7 @@ bool extractString(MathInset * p, string & str)
 bool extractNumber(MathArray const & ar, int & i)
 {
        string s;
-       MathTextCodes c;
-       charSequence(ar.begin(), ar.end(), s, c);
+       charSequence(ar.begin(), ar.end(), s);
        istringstream is(s.c_str());
        is >> i;
        return is;
@@ -219,8 +212,7 @@ bool extractNumber(MathArray const & ar, int & i)
 bool extractNumber(MathArray const & ar, double & i)
 {
        string s;
-       MathTextCodes c;
-       charSequence(ar.begin(), ar.end(), s, c);
+       charSequence(ar.begin(), ar.end(), s);
        istringstream is(s.c_str());
        is >> i;
        return is;
@@ -407,9 +399,9 @@ void extractFunctions(MathArray & ar)
 
                string name;
                // is it a function?
-               if ((*it)->asFuncInset()) {
+               if ((*it)->asUnknownInset()) {
                        // it certainly is if it is well known...
-                       name = (*it)->asFuncInset()->name();
+                       name = (*it)->asUnknownInset()->name();
                } else {
                        // is this a user defined function?
                        // it it probably not, if it doesn't have a name.
index ec39ab9636a50569b58de84412bcfb5228ea1604..00acdbb6228f189d1108e118fea777aba48d87fd 100644 (file)
@@ -8,7 +8,7 @@
 #include "math_casesinset.h"
 #include "math_decorationinset.h"
 #include "math_dotsinset.h"
-#include "math_funcinset.h"
+#include "math_fontinset.h"
 #include "math_funcliminset.h"
 #include "math_fracinset.h"
 #include "math_kerninset.h"
 #include "math_xyarrowinset.h"
 
 
-MathAtom createMathInset(latexkeys const * l)
+#include "math_metricsinfo.h"
+#include "debug.h"
+#include "math_support.h"
+#include "Lsstream.h"
+#include "support/filetools.h" // LibFileSearch
+
+#include <map>
+#include <fstream>
+
+
+namespace {
+
+// file scope
+typedef std::map<string, latexkeys> WordList;
+WordList theWordList;
+
+
+struct key_type {
+       ///
+       char const * name;
+       ///
+       char const * inset;
+       ///
+       int id;
+};
+
+
+key_type wordlist_array[] =
 {
-       switch (l->token) {
-       case LM_TK_FUNCLIM:
-               return MathAtom(new MathFuncLimInset(l->name));
-       case LM_TK_SPECIAL:
-               return MathAtom(new MathSpecialCharInset(static_cast<char>(l->id)));
-       case LM_TK_SYM:
-       case LM_TK_CMR:
-       case LM_TK_CMSY:
-       case LM_TK_CMM:
-       case LM_TK_CMEX:
-       case LM_TK_MSA:
-       case LM_TK_MSB:
-               return MathAtom(new MathSymbolInset(l));
-       case LM_TK_STACK:
-               return MathAtom(new MathStackrelInset);
-       case LM_TK_UNDERSET:
-               return MathAtom(new MathUndersetInset);
-       case LM_TK_BINOM:
-       case LM_TK_CHOOSE:
-               return MathAtom(new MathBinomInset);
-       case LM_TK_OVER:
-       case LM_TK_FRAC:
-               return MathAtom(new MathFracInset);
-       case LM_TK_ATOP:
-               return MathAtom(new MathFracInset(true));
-       case LM_TK_NOT:
-               return MathAtom(new MathNotInset);
-       case LM_TK_LEFTEQN:
-               return MathAtom(new MathLefteqnInset);
-       case LM_TK_SQRT:
-               return MathAtom(new MathSqrtInset);
-       case LM_TK_ROOT:
-               return MathAtom(new MathRootInset);
-       case LM_TK_DECORATION:
-               return MathAtom(new MathDecorationInset(l->name));
-       case LM_TK_SPACE:
-               return MathAtom(new MathSpaceInset(l->id));
-       case LM_TK_DOTS:
-               return MathAtom(new MathDotsInset(l->name));
-       case LM_TK_BOX:
-               return MathAtom(new MathBoxInset(l->name));
-       case LM_TK_FUNC:
-               return MathAtom(new MathFuncInset(l->name));
-       case LM_TK_STY:
-               return MathAtom(new MathSizeInset(l));
-       default:
-               return MathAtom(new MathUnknownInset(l->name));
+       {"!",  "space", 0},
+       {"#",  "special", 0},
+       {"$",  "special", 0},
+       {"%",  "special", 0},
+       {"&",  "special", 0},
+       {"(",  "begin", LM_OT_SIMPLE},
+       {")",  "end", LM_OT_SIMPLE},
+       {",",  "space", 1},
+       {".",  "special", 0},
+       {":",  "space", 2},
+       {";",  "space", 3},
+       {"Pr",  "funclim", 0},
+       {"[",  "begin", LM_OT_EQUATION},
+       {"]",  "end", LM_OT_EQUATION},
+       {"_",  "special", '_'},
+       {"acute",  "decoration", 0},
+       {"arccos",  "func", 0},
+       {"arcsin",  "func", 0},
+       {"arctan",  "func", 0},
+       {"arg",  "func", 0},
+       {"bar",  "decoration", 0},
+       {"begin",  "begin", 0},
+       {"bf",  "oldfont", 0},
+       {"bmod",  "func", 0},
+       {"breve",  "decoration", 0},
+       {"cal",  "oldfont", 0},
+       {"cdots",  "dots", 0},
+       {"check",  "decoration", 0},
+       {"cos",  "func", 0},
+       {"cosh",  "func", 0},
+       {"cot",  "func", 0},
+       {"coth",  "func", 0},
+       {"csc",  "func", 0},
+       {"ddot",  "decoration", 0},
+       {"dddot",  "decoration", 0},
+       {"ddots",  "dots", 0},
+       {"deg",  "func", 0},
+       {"det",  "funclim", 0},
+       {"dim",  "func", 0},
+       {"displaystyle",  "style", LM_ST_DISPLAY},
+       {"dot",  "decoration", 0},
+       {"dotsb",  "dots", 0},
+       {"dotsc",  "dots", 0},
+       {"dotsi",  "dots", 0},
+       {"dotsm",  "dots", 0},
+       {"dotso",  "dots", 0},
+       {"end",  "end", 0},
+       {"exp",  "func", 0},
+       {"frak",  "font", 0},
+       {"gcd",  "funclim", 0},
+       {"grave",  "decoration", 0},
+       {"hat",  "decoration", 0},
+       {"hom",  "func", 0},
+       {"inf",  "funclim", 0},
+       {"it",  "oldfont", 0},
+       {"ker",  "func", 0},
+       {"label",  "label", 0},
+       {"ldots",  "dots", 0},
+       {"left",  "left", 0},
+       {"lg",  "func", 0},
+       {"lim",  "funclim", 0},
+       {"liminf",  "funclim", 0},
+       {"limits",  "limit", 1 },
+       {"limsup",  "funclim", 0},
+       {"ln",  "func", 0},
+       {"log",  "func", 0},
+       {"lyxbox",  "box", 0},
+       {"lyxnegspace",  "space", 6},
+       {"mathbb",  "font", 0},
+       {"mathbf",  "font", 0},
+       {"mathcal",  "font", 0},
+       {"mathfrak",  "font", 0},
+       {"mathit",  "font", 0},
+       {"mathnormal",  "font", 0},
+       {"mathring",  "decoration", 0},
+       {"mathrm",  "font", 0},
+       {"mathsf",  "font", 0},
+       {"mathtt",  "font", 0},
+       {"max",  "funclim", 0},
+       {"mbox",  "box", 0},
+       {"min",  "funclim", 0},
+       {"newcommand",  "newcommand", 0 },
+       {"nolimits",  "limit", -1},
+       {"nonumber",  "nonum", 0},
+       {"overbrace",  "decoration", 0},
+       {"overleftarrow",  "decoration", 0},
+       {"overline",  "decoration", 0},
+       {"overrightarrow",  "decoration", 0},
+       {"overleftrightarrow", "decoration", 0},
+       {"protect",  "protect", 0},
+       {"qquad",  "space", 5},
+       {"quad",  "space", 4},
+       {"right",  "right", 0},
+       {"rm",  "oldfont", 0},
+       {"scriptscriptstyle",  "style", LM_ST_SCRIPTSCRIPT},
+       {"scriptstyle",  "style", LM_ST_SCRIPT},
+       {"sec",  "func", 0},
+       {"sin",  "func", 0},
+       {"sinh",  "func", 0},
+       {"sup",  "funclim", 0},
+       {"tan",  "func", 0},
+       {"tanh",  "func", 0},
+       {"textbf",  "font", 0},
+       {"textit",  "font", 0},
+       {"textmd",  "font", 0},
+       {"textrm",  "font", 0},
+       {"textsl",  "font", 0},
+       {"textup",  "font", 0},
+       {"textstyle",  "style", LM_ST_TEXT},
+       {"tilde",  "decoration", 0},
+       {"tt",  "oldfont", 0},
+       {"underbar",  "decoration", 0},
+       {"underbrace",  "decoration", 0},
+       {"underleftarrow", "decoration", 0},
+       {"underline",  "decoration", 0},
+       {"underrightarrow", "decoration", 0},
+       {"underleftrightarrow", "decoration", 0},
+       {"underset",  "underset", 0},
+       {"vdots",  "dots", 0},
+       {"vec",  "decoration", 0},
+       {"widehat",  "decoration", 0},
+       {"widetilde",  "decoration", 0},
+       {"{",  "special", '{'},
+       {"}",  "special", '}'}
+};
+
+
+
+void readSymbols(string const & filename)
+{
+       std::ifstream fs(filename.c_str());
+       while (fs) {
+               int charid     = 0;
+               int fallbackid = 0;
+               latexkeys tmp;
+               string line;
+               getline(fs, line);
+               istringstream is(line);
+               is      >> tmp.name
+                               >> tmp.inset
+                               >> charid
+                               >> fallbackid
+                               >> tmp.extra
+                               >> tmp.xmlname;
+               if (!is)
+                       continue;
+
+               // tmp.inset _is_ the fontname here.
+               if (math_font_available(tmp.inset)) {
+                       tmp.draw += char(charid);
+               } else {
+                       if (tmp.inset == "cmex")
+                               tmp.inset  = "lyxsymb";
+                       else
+                               tmp.inset  = "lyxboldsymb";
+                       tmp.draw += char(fallbackid); 
+               }
+
+               if (theWordList.find(tmp.name) != theWordList.end())
+                       lyxerr << "readSymbols: inset " << tmp.name
+                              << " already exists.\n";
+               else
+                       theWordList[tmp.name] = tmp;
+               lyxerr << "read symbol '" << tmp.name
+                                       <<  "  inset: " << tmp.inset
+                                       <<  "  draw: " << int(tmp.draw[0])
+                                       <<  "  extra: " << tmp.extra
+                                       << "'\n";
+       }
+}
+
+
+void initSymbols()
+{
+       unsigned const n = sizeof(wordlist_array) / sizeof(wordlist_array[0]);
+       for (key_type * p = wordlist_array; p != wordlist_array + n; ++p) {
+               latexkeys tmp;
+               tmp.name  = p->name;
+               tmp.inset = p->inset;
+               tmp.draw  = p->name;
+               theWordList[p->name] = tmp;
        }
+
+       lyxerr[Debug::MATHED] << "reading symbols file\n";
+       string const file = LibFileSearch(string(), "symbols");
+       if (file.empty())
+               lyxerr << "Could not find symbols file\n";
+       else
+               readSymbols(file);
+}
+
+
+} // namespace anon
+
+
+latexkeys const * in_word_set(string const & str)
+{
+       static bool initialized = false;
+
+       if (!initialized) {
+               initSymbols();
+               initialized = true;
+       }
+
+       WordList::iterator it = theWordList.find(str);
+       lyxerr << "looking up '" << str << "' found: " << (it !=
+               theWordList.end()) << "\n";
+       return (it != theWordList.end()) ? &(it->second) : 0;
 }
 
 
 MathAtom createMathInset(string const & s)
 {
-       //cerr << "creating inset with name: '" << s << "'\n";
+       cerr << "creating inset with name: '" << s << "'\n";
        if (s.size() == 2 && s[0] == '#' && s[1] >= '1' && s[1] <= '9')
                return MathAtom(new MathMacroArgument(s[1] - '0'));
 
        if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
                        && s[2] >= '1' && s[2] <= '9')
                return MathAtom(new MathMacroArgument(s[2] - '0'));
-
        if (s == "kern")
                return MathAtom(new MathKernInset);
-
        if (s == "xymatrix")
                return MathAtom(new MathXYMatrixInset);
-
        if (s == "xrightarrow" || s == "xleftarrow")
                return MathAtom(new MathXArrowInset(s));
-
        if (s == "split" || s == "gathered" || s == "aligned")
                return MathAtom(new MathSplitInset(s));
-
        if (s == "cases")
                return MathAtom(new MathCasesInset);
-
        if (s == "substack")
                return MathAtom(new MathSubstackInset);
-
        if (s == "subarray" || s == "array")
                return MathAtom(new MathArrayInset(s, 1, 1));
-
        if (s == "pmatrix" || s == "bmatrix" || s == "vmatrix" || s == "Vmatrix" ||
                  s == "matrix")
                return MathAtom(new MathAMSArrayInset(s));
+       if (s == "sqrt")
+               return MathAtom(new MathSqrtInset);
+       if (s == "root")
+               return MathAtom(new MathRootInset);
+       if (s == "stack")
+               return MathAtom(new MathStackrelInset);
+       if (s == "binom" || s == "choose")
+               return MathAtom(new MathBinomInset);
+       if (s == "over" || s == "frac")
+               return MathAtom(new MathFracInset);
+       if (s == "atop")
+               return MathAtom(new MathFracInset(true));
+       if (s == "not")
+               return MathAtom(new MathNotInset);
+       if (s == "lefteqn")
+               return MathAtom(new MathLefteqnInset);
 
        latexkeys const * l = in_word_set(s);
-       if (l)
-               return createMathInset(l);
+       if (l) {
+               string const & inset = l->inset;
+               cerr << " fount inset: '" << inset << "'\n";
+               if (inset == "funclim")
+                       return MathAtom(new MathFuncLimInset(s));
+               if (inset == "special")
+                       return MathAtom(new MathSpecialCharInset(s[0]));
+               if (inset == "lyxsym" ||
+                               inset == "cmr" ||
+                               inset == "cmsy" ||
+                               inset == "cmm" ||
+                               inset == "cmex" ||
+                               inset == "msa" ||
+                               inset == "msb")
+                       return MathAtom(new MathSymbolInset(l));
+               if (inset == "underset")
+                       return MathAtom(new MathUndersetInset);
+               if (inset == "decoration")
+                       return MathAtom(new MathDecorationInset(l->name));
+               //if (inset == "space")
+               //      return MathAtom(new MathSpaceInset(l->id));
+               if (inset == "dots")
+                       return MathAtom(new MathDotsInset(l->name));
+               if (inset == "box")
+                       return MathAtom(new MathBoxInset(l->name));
+               if (inset == "style")
+                       return MathAtom(new MathSizeInset(l));
+               if (inset == "font")
+                       return MathAtom(new MathFontInset(l->name));
+               if (inset == "oldfont")
+                       return MathAtom(new MathFontInset(l->name));
+               if (inset == "func")
+                       return MathAtom(new MathUnknownInset(l->name, true, true));
+               
+               return MathAtom(new MathUnknownInset(l->name));
+       }
 
        if (MathMacroTable::has(s))
                return MathAtom(new MathMacro(s));
index 56e0e916691b9dcc4f4112c69e8639c727451fb4..b53efdda646cd0a5164a536df346177d1a886539 100644 (file)
@@ -8,6 +8,5 @@ class MathInset;
 class latexkeys;
 
 MathAtom createMathInset(string const &);
-MathAtom createMathInset(latexkeys const *);
 
 #endif
diff --git a/src/mathed/math_fontinset.C b/src/mathed/math_fontinset.C
new file mode 100644 (file)
index 0000000..380cc73
--- /dev/null
@@ -0,0 +1,89 @@
+#include <config.h>
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+
+#include "math_fontinset.h"
+#include "debug.h"
+#include "math_mathmlstream.h"
+#include "math_streamstr.h"
+#include "math_support.h"
+#include "LaTeXFeatures.h"
+#include "textpainter.h"
+
+
+
+
+MathFontInset::MathFontInset(string const & name)
+       : MathNestInset(1), name_(name)
+{
+       lock(true);
+}
+
+
+MathInset * MathFontInset::clone() const
+{
+       return new MathFontInset(*this);
+}
+
+
+void MathFontInset::metrics(MathMetricsInfo & mi) const
+{
+       MathFontSetChanger dummy(mi.base, name_.c_str());
+       xcell(0).metrics(mi);
+       width_   = xcell(0).width();
+       ascent_  = xcell(0).ascent();
+       descent_ = xcell(0).descent();
+}
+
+
+void MathFontInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       //lyxerr << "MathFontInset::draw\n";
+       MathFontSetChanger dummy(pi.base, name_.c_str());
+       xcell(0).draw(pi, x, y);
+}
+
+
+void MathFontInset::metricsT(TextMetricsInfo const & mi) const
+{
+       xcell(0).metricsT(mi);
+       width_   = xcell(0).width();
+       ascent_  = xcell(0).ascent();
+       descent_ = xcell(0).descent();
+}
+
+
+void MathFontInset::drawT(TextPainter & pain, int x, int y) const
+{
+       //lyxerr << "drawing font code: " << code_ << '\n';
+       xcell(0).drawT(pain, x, y);
+}
+
+
+void MathFontInset::write(WriteStream & os) const
+{
+       os << '\\' << name_ << '{' << cell(0) << '}';
+}
+
+
+void MathFontInset::normalize(NormalStream & os) const
+{
+       os << "[font_ " << name_ << " " << cell(0) << "]";
+}
+
+
+void MathFontInset::validate(LaTeXFeatures & features) const
+{
+       // Make sure amssymb is put in preamble if Blackboard Bold or
+       // Fraktur used:
+       if (name_ == "mathfrak" || name_ == "mathbb")
+               features.require("amssymb");
+}
+
+
+void MathFontInset::infoize(std::ostream & os) const
+{
+       os << "Font: " << name_;
+}
diff --git a/src/mathed/math_fontinset.h b/src/mathed/math_fontinset.h
new file mode 100644 (file)
index 0000000..1c62eb9
--- /dev/null
@@ -0,0 +1,46 @@
+// -*- C++ -*-
+#ifndef MATH_FONTINSET_H
+#define MATH_FONTINSET_H
+
+#include "math_nestinset.h"
+#include "LString.h"
+#include "lyxfont.h"
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+/** The base character inset.
+    \author André Pönitz
+ */
+
+class MathFontInset : public MathNestInset {
+public:
+       ///
+       explicit MathFontInset(string const & name);
+       ///
+       MathInset * clone() const;
+       ///
+       void metrics(MathMetricsInfo & st) const;
+       ///
+       void draw(MathPainterInfo &, int x, int y) const;
+       ///
+       void metricsT(TextMetricsInfo const & st) const;
+       ///
+       void drawT(TextPainter &, int x, int y) const;
+       ///
+       void write(WriteStream & os) const;
+       ///
+       void normalize(NormalStream &) const;
+       /// identifies Fontinsets
+       MathFontInset const * asFontInset() const { return this; }
+       ///
+       void validate(LaTeXFeatures & features) const;
+       ///
+       void infoize(std::ostream & os) const;
+
+private:
+       /// the font to be used on screen
+       string name_;
+};
+#endif
index cc7efc8890a7c2b410639b4d9e4b083724723013..119c27877470a7c4cce93154f05da7e18dc44bb2 100644 (file)
@@ -29,25 +29,25 @@ MathFracInset * MathFracInset::asFracInset()
 }
 
 
-void MathFracInset::metrics(MathMetricsInfo const & mi) const
+void MathFracInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo m = mi;
-       smallerStyleFrac(m);
-       xcell(0).metrics(m);
-       xcell(1).metrics(m);
+       MathFracChanger dummy(mi.base);
+       xcell(0).metrics(mi);
+       xcell(1).metrics(mi);
        width_   = max(xcell(0).width(), xcell(1).width()) + 2;
        ascent_  = xcell(0).height() + 2 + 5;
        descent_ = xcell(1).height() + 2 - 5;
 }
 
 
-void MathFracInset::draw(Painter & pain, int x, int y) const
+void MathFracInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int m = x + width() / 2;
-       xcell(0).draw(pain, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5);
-       xcell(1).draw(pain, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 2 - 5);
+       MathFracChanger dummy(pi.base);
+       xcell(0).draw(pi, m - xcell(0).width() / 2, y - xcell(0).descent() - 2 - 5);
+       xcell(1).draw(pi, m - xcell(1).width() / 2, y + xcell(1).ascent()  + 2 - 5);
        if (!atop_)
-               pain.line(x, y - 5, x + width(), y - 5, LColor::math);
+               pi.pain.line(x, y - 5, x + width(), y - 5, LColor::math);
 }
 
 
index 771c2e9ece477c11a40c8a500d59fceaa51b26ac..4f903d7c8b3482635035d262568bce941ab72756 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & mi) const;
+       void metrics(MathMetricsInfo & mi) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(TextMetricsInfo const & mi) const;
        ///
index 59d4e4d7e15d2b1f3de0f0d8e39c960af50b5762..e687e48720194cf35be988c21792dbba376c28b4 100644 (file)
@@ -38,16 +38,15 @@ void MathFuncInset::setName(string const & n)
 }
 
 
-void MathFuncInset::metrics(MathMetricsInfo const & mi) const
+void MathFuncInset::metrics(MathMetricsInfo & mi) const
 {
-       whichFont(font_, LM_TC_TEXTRM, mi);
-       mathed_string_dim(font_, name_, ascent_, descent_, width_);
+       mathed_string_dim(mi.font_, name_, ascent_, descent_, width_);
 }
 
 
 void MathFuncInset::draw(Painter & pain, int x, int y) const
 {
-       drawStr(pain, font_, x, y, name_);
+       drawStr(pain, mi.font_, x, y, name_);
 }
 
 
index 9a92c96af6890d5474938448bb74617afef653da..8256479c8f6ae666b9ade624b66284586da4b147 100644 (file)
@@ -3,7 +3,6 @@
 #define MATH_FUNCINSET_H
 
 #include "math_diminset.h"
-#include "math_defs.h"
 
 #ifdef __GNUG__
 #pragma interface
@@ -19,7 +18,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        void draw(Painter &, int x, int y) const;
        ///
index dba26a2aa95932ad01b200c2b150fece31b84933..c2826c6b5685f1a19eb44bc236410879842a13f3 100644 (file)
@@ -19,8 +19,7 @@ MathInset * MathFuncLimInset::clone() const
 
 bool MathFuncLimInset::isScriptable() const
 {
-       //return mi_.style == LM_ST_DISPLAY;
-       return true;
+       return scriptable_;
 }
 
 
@@ -36,14 +35,14 @@ void MathFuncLimInset::normalize(NormalStream & os) const
 }
 
 
-void MathFuncLimInset::metrics(MathMetricsInfo const & mi) const
+void MathFuncLimInset::metrics(MathMetricsInfo & mi) const
 {
-       whichFont(font_, LM_TC_TEXTRM, mi);
-       mathed_string_dim(font_, name_, ascent_, descent_, width_);
+       scriptable_ =  (mi.base.style == LM_ST_DISPLAY);
+       mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
 }
 
 
-void MathFuncLimInset::draw(Painter & pain, int x, int y) const
+void MathFuncLimInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       drawStr(pain, font_, x, y, name_);
+       drawStrBlack(pi, x, y, name_);
 }
index b54a335d1d299fa4a5335431c0aabfb110e4d6d0..61d2e1fe50ef840065b548cc00a464af566cccbc 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        bool isScriptable() const;
 
@@ -28,6 +28,6 @@ private:
        ///
        string const name_;
        ///
-       mutable LyXFont font_;
+       mutable bool scriptable_;
 };
 #endif
index 0b7a7ea3c6091955bb19a9c225182c1c683fb6d8..dbcdece874b700cef4cc3977afe384b42cb4d5d8 100644 (file)
@@ -216,7 +216,7 @@ LyXLength MathGridInset::vcrskip(row_type row) const
 }
 
 
-void MathGridInset::metrics(MathMetricsInfo const & mi) const
+void MathGridInset::metrics(MathMetricsInfo & mi) const
 {
        // let the cells adjust themselves
        MathNestInset::metrics(mi);
@@ -355,7 +355,7 @@ void MathGridInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathGridInset::draw(Painter & pain, int x, int y) const
+void MathGridInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        for (idx_type idx = 0; idx < nargs(); ++idx)
                xcell(idx).draw(pain, x + cellXOffset(idx), y + cellYOffset(idx));
@@ -364,14 +364,14 @@ void MathGridInset::draw(Painter & pain, int x, int y) const
                for (int i = 0; i < rowinfo_[row].lines_; ++i) {
                        int yy = y + rowinfo_[row].offset_ - rowinfo_[row].ascent_
                                - i * hlinesep() - hlinesep()/2 - rowsep()/2;
-                       pain.line(x + 1, yy, x + width_ - 1, yy);
+                       pain.pain.line(x + 1, yy, x + width_ - 1, yy);
                }
 
        for (col_type col = 0; col <= ncols(); ++col)
                for (int i = 0; i < colinfo_[col].lines_; ++i) {
                        int xx = x + colinfo_[col].offset_
                                - i * vlinesep() - vlinesep()/2 - colsep()/2;
-                       pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
+                       pain.pain.line(xx, y - ascent_ + 1, xx, y + descent_ - 1);
                }
 }
 
index b31cafae4f3700155917001f2e19909f3ac3d114..2a3625aef279fa5b5090ed3c887d9d8bd08fdcb2 100644 (file)
@@ -70,9 +70,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(TextMetricsInfo const & st) const;
        ///
diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C
deleted file mode 100644 (file)
index dbf5d58..0000000
+++ /dev/null
@@ -1,244 +0,0 @@
-#include <config.h>
-
-#include "math_parser.h"
-#include "math_metricsinfo.h"
-#include "lyxlex.h"
-#include "debug.h"
-#include "support/filetools.h" // LibFileSearch
-
-#include <map>
-
-using std::map;
-
-namespace {
-
-// file scope
-typedef map<string, latexkeys> WordList;
-WordList theWordList;
-
-
-struct key_type {
-       ///
-       char const * name;
-       ///
-       MathTokenEnum token;
-       ///
-       unsigned int id;
-};
-
-
-key_type wordlist_array[] =
-{
-       {"!",  LM_TK_SPACE, 0},
-       {"#",  LM_TK_SPECIAL, '#'},
-       {"$",  LM_TK_SPECIAL, '$'},
-       {"%",  LM_TK_SPECIAL, '%'},
-       {"&",  LM_TK_SPECIAL, '&'},
-       {"(",  LM_TK_BEGIN, LM_OT_SIMPLE},
-       {")",  LM_TK_END, LM_OT_SIMPLE},
-       {",",  LM_TK_SPACE, 1},
-       {".",  LM_TK_SPECIAL, '.'},
-       {":",  LM_TK_SPACE, 2},
-       {";",  LM_TK_SPACE, 3},
-       {"Pr",  LM_TK_FUNCLIM, 0},
-       {"[",  LM_TK_BEGIN, LM_OT_EQUATION},
-       {"]",  LM_TK_END, LM_OT_EQUATION},
-       {"_",  LM_TK_SPECIAL, '_'},
-       {"acute",  LM_TK_DECORATION, 0},
-       {"arccos",  LM_TK_FUNC, 0},
-       {"arcsin",  LM_TK_FUNC, 0},
-       {"arctan",  LM_TK_FUNC, 0},
-       {"arg",  LM_TK_FUNC, 0},
-       {"atop",  LM_TK_ATOP, 0},
-       {"bar",  LM_TK_DECORATION, 0},
-       {"begin",  LM_TK_BEGIN, 0},
-       {"bf",  LM_TK_OLDFONT, LM_TC_BF},
-       {"binom",  LM_TK_BINOM, 0},
-       {"bmod",  LM_TK_FUNC, 0},
-       {"breve",  LM_TK_DECORATION, 0},
-       {"cal",  LM_TK_OLDFONT, LM_TC_CAL},
-       {"cdots",  LM_TK_DOTS, 0},
-       {"check",  LM_TK_DECORATION, 0},
-       {"choose",  LM_TK_CHOOSE, 0},
-       {"cos",  LM_TK_FUNC, 0},
-       {"cosh",  LM_TK_FUNC, 0},
-       {"cot",  LM_TK_FUNC, 0},
-       {"coth",  LM_TK_FUNC, 0},
-       {"csc",  LM_TK_FUNC, 0},
-       {"ddot",  LM_TK_DECORATION, 0},
-       {"dddot",  LM_TK_DECORATION, 0},
-       {"ddots",  LM_TK_DOTS, 0},
-       {"dotsb",  LM_TK_DOTS, 0},
-       {"dotsc",  LM_TK_DOTS, 0},
-       {"dotsi",  LM_TK_DOTS, 0},
-       {"dotsm",  LM_TK_DOTS, 0},
-       {"dotso",  LM_TK_DOTS, 0},
-       {"deg",  LM_TK_FUNC, 0},
-       {"det",  LM_TK_FUNCLIM, 0},
-       {"dim",  LM_TK_FUNC, 0},
-       {"displaystyle",  LM_TK_STY, LM_ST_DISPLAY},
-       {"dot",  LM_TK_DECORATION, 0},
-       {"end",  LM_TK_END, 0},
-       {"exp",  LM_TK_FUNC, 0},
-       {"frac",  LM_TK_FRAC, 0},
-       {"frak",  LM_TK_FONT, LM_TC_EUFRAK},
-       {"gcd",  LM_TK_FUNCLIM, 0},
-       {"grave",  LM_TK_DECORATION, 0},
-       {"hat",  LM_TK_DECORATION, 0},
-       {"hom",  LM_TK_FUNC, 0},
-       {"inf",  LM_TK_FUNCLIM, 0},
-       {"it",  LM_TK_OLDFONT, LM_TC_IT},
-       {"ker",  LM_TK_FUNC, 0},
-       {"label",  LM_TK_LABEL, 0},
-       {"lefteqn",  LM_TK_LEFTEQN, 1},
-       {"ldots",  LM_TK_DOTS, 0},
-       {"left",  LM_TK_LEFT, 0},
-       {"lg",  LM_TK_FUNC, 0},
-       {"lim",  LM_TK_FUNCLIM, 0},
-       {"liminf",  LM_TK_FUNCLIM, 0},
-       {"limits",  LM_TK_LIMIT, 1 },
-       {"limsup",  LM_TK_FUNCLIM, 0},
-       {"ln",  LM_TK_FUNC, 0},
-       {"log",  LM_TK_FUNC, 0},
-       {"lyxbox",  LM_TK_BOX, 0},
-       {"lyxnegspace",  LM_TK_SPACE, 6},
-       {"mathbb",  LM_TK_FONT, LM_TC_BB},
-       {"mathbf",  LM_TK_FONT, LM_TC_BF},
-       {"mathcal",  LM_TK_FONT, LM_TC_CAL},
-       {"mathfrak",  LM_TK_FONT, LM_TC_EUFRAK},
-       {"mathit",  LM_TK_FONT, LM_TC_IT},
-       {"mathnormal",  LM_TK_FONT, LM_TC_VAR},
-       {"mathring",  LM_TK_DECORATION, 0},
-       {"mathrm",  LM_TK_FONT, LM_TC_RM},
-       {"mathsf",  LM_TK_FONT, LM_TC_SF},
-       {"mathtt",  LM_TK_FONT, LM_TC_TT},
-       {"max",  LM_TK_FUNCLIM, 0},
-       //{"mbox",  LM_TK_BOX, 0},
-       {"min",  LM_TK_FUNCLIM, 0},
-       {"newcommand",  LM_TK_NEWCOMMAND, 0 },
-       {"nolimits",  LM_TK_LIMIT, static_cast<unsigned>(-1)},
-       {"nonumber",  LM_TK_NONUM, 0},
-       {"not",  LM_TK_NOT, 0},
-       {"over",  LM_TK_OVER, 0},
-       {"overbrace",  LM_TK_DECORATION, 0},
-       {"overleftarrow",  LM_TK_DECORATION, 0},
-       {"overline",  LM_TK_DECORATION, 0},
-       {"overrightarrow",  LM_TK_DECORATION, 0},
-       {"overleftrightarrow", LM_TK_DECORATION, 0},
-       {"protect",  LM_TK_PROTECT, 0},
-       {"qquad",  LM_TK_SPACE, 5},
-       {"quad",  LM_TK_SPACE, 4},
-       {"right",  LM_TK_RIGHT, 0},
-       {"rm",  LM_TK_OLDFONT, LM_TC_RM},
-       {"root",  LM_TK_ROOT, 0},
-       {"scriptscriptstyle",  LM_TK_STY, LM_ST_SCRIPTSCRIPT},
-       {"scriptstyle",  LM_TK_STY, LM_ST_SCRIPT},
-       {"sec",  LM_TK_FUNC, 0},
-       {"sin",  LM_TK_FUNC, 0},
-       {"sinh",  LM_TK_FUNC, 0},
-       {"sqrt",  LM_TK_SQRT, 0},
-       {"stackrel",  LM_TK_STACK, 0},
-       {"sup",  LM_TK_FUNCLIM, 0},
-       {"tan",  LM_TK_FUNC, 0},
-       {"tanh",  LM_TK_FUNC, 0},
-       {"textrm",  LM_TK_FONT, LM_TC_TEXTRM},
-       {"textstyle",  LM_TK_STY, LM_ST_TEXT},
-       {"tilde",  LM_TK_DECORATION, 0},
-       {"tt",  LM_TK_OLDFONT, LM_TC_TT},
-       {"underbar",  LM_TK_DECORATION, 0},
-       {"underbrace",  LM_TK_DECORATION, 0},
-       {"underleftarrow", LM_TK_DECORATION, 0},
-       {"underline",  LM_TK_DECORATION, 0},
-       {"underrightarrow", LM_TK_DECORATION, 0},
-       {"underleftrightarrow", LM_TK_DECORATION, 0},
-       {"underset",  LM_TK_UNDERSET, 0},
-       {"vdots",  LM_TK_DOTS, 0},
-       {"vec",  LM_TK_DECORATION, 0},
-       {"widehat",  LM_TK_DECORATION, 0},
-       {"widetilde",  LM_TK_DECORATION, 0},
-       {"{",  LM_TK_SPECIAL, '{'},
-       {"}",  LM_TK_SPECIAL, '}'}
-};
-
-
-
-MathTokenEnum tokenEnum(const string & font)
-{
-       if (font == "cmr")
-               return LM_TK_CMR;
-       if (font == "cmsy")
-               return LM_TK_CMSY;
-       if (font == "cmm")
-               return LM_TK_CMM;
-       if (font == "cmex")
-               return LM_TK_CMEX;
-       if (font == "msa")
-               return LM_TK_MSA;
-       if (font == "msb")
-               return LM_TK_MSB;
-       return LM_TK_SYM;
-}
-
-
-void readSymbols(string const & filename)
-{
-       LyXLex lex(0, 0);
-       lex.setFile(filename);
-       while (lex.isOK() && lex.next()) {
-               latexkeys tmp;
-               tmp.name = lex.getString();
-               if (lex.next())
-                       tmp.token = tokenEnum(lex.getString());
-               if (lex.next())
-                       tmp.latex_font_id = lex.getInteger();
-               if (lex.next())
-                       tmp.id = lex.getInteger();
-               if (lex.next())
-                       tmp.type = lex.getString();
-               if (lex.next())
-                       tmp.xmlname = lex.getString();
-               if (theWordList.find(tmp.name) != theWordList.end())
-                       lyxerr << "readSymbols: token " << tmp.name
-                              << " already exists.\n";
-               else
-                       theWordList[tmp.name] = tmp;
-       }
-}
-
-
-void initSymbols()
-{
-       unsigned const n = sizeof(wordlist_array) / sizeof(wordlist_array[0]);
-       for (key_type * p = wordlist_array; p != wordlist_array + n; ++p) {
-               latexkeys tmp;
-               tmp.name          = p->name;
-               tmp.token         = p->token;
-               tmp.id            = p->id;
-               tmp.latex_font_id = 0;
-               theWordList[p->name] = tmp;
-       }
-
-       lyxerr[Debug::MATHED] << "reading symbols file\n";
-       string const file = LibFileSearch(string(), "symbols");
-       if (file.empty())
-               lyxerr << "Could not find symbols file\n";
-       else
-               readSymbols(file);
-}
-
-
-} // namespace anon
-
-
-latexkeys const * in_word_set(string const & str)
-{
-       static bool initialized = false;
-
-       if (!initialized) {
-               initSymbols();
-               initialized = true;
-       }
-
-       WordList::iterator it = theWordList.find(str);
-       return (it != theWordList.end()) ? &(it->second) : 0;
-}
index 75bc87bf5b6e6ad39ff3f5548b60f48a0059bd99..5d1c551f0cf88070c2b4b52168b3f2d1f81f1e81 100644 (file)
@@ -57,6 +57,7 @@ namespace {
 
        MathInsetTypes typecode(string const & s)
        {
+               if (s == "none")      return LM_OT_NONE;
                if (s == "equation")  return LM_OT_EQUATION;
                if (s == "display")   return LM_OT_EQUATION;
                if (s == "eqnarray")  return LM_OT_EQNARRAY;
@@ -156,24 +157,24 @@ int MathHullInset::defaultColSpace(col_type col)
 }
 
 
-void MathHullInset::metrics(MathMetricsInfo const & mi) const
+void MathHullInset::metrics(MathMetricsInfo & mi) const
 {
-       mi_ = mi;
-       mi_.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
-
        // let the cells adjust themselves
-       MathGridInset::metrics(mi_);
+       MathGridInset::metrics(mi);
 
        if (display()) {
                ascent_  += 12;
                descent_ += 12;
        }
 
+       mi_ = mi;
+       mi_.base.style = (getType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
+
        if (numberedType()) {
-               whichFont(mi_.font, LM_TC_BF, mi_);
+               //augmentFont(mi_.base.font, "mathbf");
                int l = 0;
                for (row_type row = 0; row < nrows(); ++row)
-                       l = max(l, mathed_string_width(mi_.font, nicelabel(row)));
+                       l = max(l, mathed_string_width(mi_.base.font, nicelabel(row)));
 
                if (l)
                        width_ += 30 + l;
@@ -182,21 +183,21 @@ void MathHullInset::metrics(MathMetricsInfo const & mi) const
        // make it at least as high as the current font
        int asc = 0;
        int des = 0;
-       math_font_max_dim(mi_.font, asc, des);
+       math_font_max_dim(mi_.base.font, asc, des);
        ascent_  = max(ascent_,  asc);
        descent_ = max(descent_, des);
 }
 
 
-void MathHullInset::draw(Painter & pain, int x, int y) const
+void MathHullInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       MathGridInset::draw(pain, x, y);
+       MathGridInset::draw(pi, x, y);
 
        if (numberedType()) {
                int const xx = x + colinfo_.back().offset_ + colinfo_.back().width_ + 20;
                for (row_type row = 0; row < nrows(); ++row) {
                        int const yy = y + rowinfo_[row].offset_;
-                       drawStr(pain, mi_.font, xx, yy, nicelabel(row));
+                       drawStrBlack(pi, xx, yy, nicelabel(row));
                }
        }
 }
@@ -371,6 +372,9 @@ void MathHullInset::header_write(WriteStream & os) const
                        os << "\\begin{gather}\n";
                        break;
 
+               case LM_OT_NONE:
+                       break;
+
                default:
                        os << "\\begin{unknown" << star(n) << "}";
        }
@@ -421,6 +425,10 @@ void MathHullInset::footer_write(WriteStream & os) const
                        os << "\n\\end{gather}\n";
                        break;
 
+               case LM_OT_NONE:
+                       os << "\n";
+                       break;
+
                default:
                        os << "\\end{unknown" << star(n) << "}";
        }
@@ -737,6 +745,11 @@ void MathHullInset::mathmlize(MathMLStream & os) const
 }
 
 
+void MathHullInset::infoize(std::ostream & os) const
+{
+       os << normalName(getType());
+}
+
 void MathHullInset::check() const
 {
        lyx::Assert(nonum_.size() == nrows());
index 8b05af262e17538348cd462cf90da546f42e4469..13a61bf2a454e5cc3d9a5805d0c4a8bc882d339e 100644 (file)
@@ -27,9 +27,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(TextMetricsInfo const & st) const;
        ///
@@ -86,6 +86,8 @@ public:
        void mathmlize(MathMLStream &) const;
        ///
        void normalize(NormalStream &) const;
+       ///
+       void infoize(std::ostream & os) const;
 
 private:
        ///
index 3210b3558fe4d6fd3ca9c3119cce704881cbe54d..c137de313afdde05694c7f755168085020d83295 100644 (file)
@@ -190,13 +190,13 @@ vector<MathInset::idx_type>
 }
 
 
-void MathInset::metrics(MathMetricsInfo const &) const
+void MathInset::metrics(MathMetricsInfo &) const
 {
        lyxerr << "MathInset::metrics() called directly!\n";
 }
 
 
-void MathInset::draw(Painter &, int, int) const
+void MathInset::draw(MathPainterInfo &, int, int) const
 {
        lyxerr << "MathInset::draw() called directly!\n";
 }
index 65f3d15e6cb3b89b3c0f5a7b6fc2511d6e242b5e..379820f7f1661b4f582780a13f892a6c2f00a777 100644 (file)
@@ -28,9 +28,9 @@
 #pragma interface
 #endif
 
+#include "LString.h"
 #include "frontends/mouse_state.h"
 #include "math_xdata.h"
-#include "math_defs.h"
 
 /**
 
@@ -53,6 +53,7 @@ class MathBraceInset;
 class MathBoxInset;
 class MathCharInset;
 class MathDelimInset;
+class MathFontInset;
 class MathFuncInset;
 class MathGridInset;
 class MathFracInset;
@@ -107,9 +108,9 @@ public:
        virtual void substitute(MathMacro const & macro);
        /// compute the size of the object, sets ascend_, descend_ and width_
        // updates the (xo,yo)-caches of all contained cells
-       virtual void metrics(MathMetricsInfo const & st) const;
+       virtual void metrics(MathMetricsInfo & st) const;
        /// draw the object
-       virtual void draw(Painter &, int x, int y) const;
+       virtual void draw(MathPainterInfo &, int x, int y) const;
        /// the ascent of the inset above the baseline
        /// compute the size of the object for text based drawing
        virtual void metricsT(TextMetricsInfo const & st) const;
@@ -192,6 +193,7 @@ public:
        virtual MathCharInset const    * asCharInset() const    { return 0; }
        virtual MathDelimInset         * asDelimInset()         { return 0; }
        virtual MathDelimInset const   * asDelimInset() const   { return 0; }
+       virtual MathFontInset const    * asFontInset() const    { return 0; }
        virtual MathFuncInset          * asFuncInset()          { return 0; }
        virtual MathFracInset          * asFracInset()          { return 0; }
        virtual MathGridInset          * asGridInset()          { return 0; }
@@ -205,6 +207,7 @@ public:
        virtual MathSpaceInset         * asSpaceInset()         { return 0; }
        virtual MathStringInset        * asStringInset()        { return 0; }
        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; }
 
@@ -217,8 +220,6 @@ public:
 
        /// return the content as char if the inset is able to do so
        virtual char getChar() const { return 0; }
-       /// return the content's char code if it has one
-       virtual MathTextCodes code() const { return LM_TC_MIN; }
        /// identifies things that can get \limits or \nolimits
        virtual bool takesLimits() const { return false; }
        /// identifies complicated things that need braces if used as arg
@@ -230,13 +231,17 @@ public:
        /// request "external features"
        virtual void validate(LaTeXFeatures & features) const;
        /// char char code if possible
-       virtual void handleFont(MathTextCodes) {}
+       virtual void handleFont(string const &) {}
        /// is this inset equal to a given other inset?
        virtual bool match(MathInset *) const { return false; }
        /// replace things by other things
        virtual void replace(ReplaceData &) {}
        /// do we contain a given subsequence?
        virtual bool contains(MathArray const &) { return false; }
+       /// access to the lock (only nest array have one)
+       virtual bool lock() const { return false; }
+       /// access to the lock (only nest array have one)
+       virtual void lock(bool) {}
 
        /// write LaTeX and Lyx code
        virtual void write(WriteStream & os) const;
index e2d8b60e52a3e5a06ea38434c45b5efc67f5d02b..b7fcd368554cca6c11111e794cd9c19775e626cf 100644 (file)
@@ -32,7 +32,7 @@ MathInset * MathKernInset::clone() const
 }
 
 
-void MathKernInset::metrics(MathMetricsInfo const & /*mi*/) const
+void MathKernInset::metrics(MathMetricsInfo & /*mi*/) const
 {
 #ifdef WITH_WARNINGS
 #warning fix this once the interface to LyXLength has improved
@@ -46,7 +46,7 @@ void MathKernInset::metrics(MathMetricsInfo const & /*mi*/) const
 }
 
 
-void MathKernInset::draw(Painter &, int, int) const
+void MathKernInset::draw(MathPainterInfo &, int, int) const
 {}
 
 
index 5af50f4651e47722c097536fa7846ca3effed3ad..37adf09da2486c8c8345bdaf4bd137edf4773481 100644 (file)
@@ -25,13 +25,13 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream & ns) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
 private:
        /// width in em
        LyXLength wid_;
index 318a634549838f1a6b961e51a774fb66c5de3fae..4331a549580e96b85b4a5375a3bff923e4bec917 100644 (file)
@@ -18,7 +18,7 @@ MathInset * MathLefteqnInset::clone() const
 }
 
 
-void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const
+void MathLefteqnInset::metrics(MathMetricsInfo & mi) const
 {
        MathNestInset::metrics(mi);
        ascent_  = xcell(0).ascent() + 2;
@@ -27,7 +27,7 @@ void MathLefteqnInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathLefteqnInset::draw(Painter & pain, int x, int y) const
+void MathLefteqnInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        xcell(0).draw(pain, x + 2, y);
        //mathed_draw_framebox(pain, x, y, this);
index 3c75e612a8bdfa6aa88eae84fb850bf943b9992c..0956310561c7386f77d0e66906d834bc5a012eba 100644 (file)
@@ -17,12 +17,12 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
 };
 #endif
index d92e7a69a13d996c208611a80ced6bc63245fda4..d901f52e1531c19e64810689ade3ff58fa437341 100644 (file)
@@ -31,13 +31,13 @@ void MathLimitOpInset::normalize(NormalStream &) const
 }
 
 
-void MathLimitOpInset::metrics(MathMetricsInfo const &) const
+void MathLimitOpInset::metrics(MathMetricsInfo &) const
 {
        lyxerr << "should not happen\n";
 }
 
 
-void MathLimitOpInset::draw(Painter &, int, int) const
+void MathLimitOpInset::draw(MathPainterInfo &, int, int) const
 {
        lyxerr << "should not happen\n";
 }
index f5343c2514dcec4ed6545cce0d76294534da6650..5c9e4c01b1028b6d702510febc78e525fb855e82 100644 (file)
@@ -14,9 +14,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
index d80be9f55e53651c520b59a9198b4eb29863decd..0ee956ed1335d543dcdf4bf4d7f8dcc8060afa67 100644 (file)
@@ -28,7 +28,6 @@
 #include "support/lstrings.h"
 #include "support/LAssert.h"
 #include "debug.h"
-#include "frontends/Painter.h"
 #include "LaTeXFeatures.h"
 
 
@@ -73,9 +72,9 @@ void MathMacro::expand() const
 }
 
 
-void MathMacro::metrics(MathMetricsInfo const & mi) const
+void MathMacro::metrics(MathMetricsInfo & mi) const
 {
-       whichFont(font_, LM_TC_TEX, mi);
+       augmentFont(font_, "lyxtex");
        mi_ = mi;
 
        if (defining()) {
@@ -116,12 +115,12 @@ void MathMacro::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathMacro::draw(Painter & pain, int x, int y) const
+void MathMacro::draw(MathPainterInfo & pain, int x, int y) const
 {
        metrics(mi_);
 
        LyXFont texfont;
-       whichFont(texfont, LM_TC_TEX, mi_);
+       augmentFont(texfont, "lyxtex");
 
        if (defining()) {
                drawStr(pain, texfont, x, y, name());
index 1de5a90cafbf59d00bc68c652d39168716a085c8..d72483a892c0d5880cec3b60904178d540c1a7f1 100644 (file)
@@ -42,9 +42,9 @@ public:
        ///
        MathMacro(MathMacro const &);
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        MathInset * clone() const;
        ///
index 8033d70b84fb7bf58ab289b0078202cf49424c8f..0430a41d3d077481c1316b37a6415d5fd272efd2 100644 (file)
@@ -4,7 +4,6 @@
 
 #include "math_macroarg.h"
 #include "math_macro.h"
-#include "math_defs.h"
 #include "math_mathmlstream.h"
 #include "math_support.h"
 #include "debug.h"
@@ -13,8 +12,8 @@
 using std::endl;
 
 
-MathMacroArgument::MathMacroArgument(int n, MathTextCodes code)
-       : MathNestInset(1), number_(n), expanded_(false), code_(code)
+MathMacroArgument::MathMacroArgument(int n)
+       : MathNestInset(1), number_(n), expanded_(false)
 {
        if (n < 1 || n > 9) {
                lyxerr << "MathMacroArgument::MathMacroArgument: wrong Argument id: "
@@ -34,32 +33,29 @@ MathInset * MathMacroArgument::clone() const
 
 void MathMacroArgument::write(WriteStream & os) const
 {
-       if (code_ == LM_TC_MIN)
-               os << str_;
-       else
-               os << '\\' << math_font_name(code_) << '{' << str_ << '}';
+       os << str_;
 }
 
 
-void MathMacroArgument::metrics(MathMetricsInfo const & mi) const
+void MathMacroArgument::metrics(MathMetricsInfo & mi) const
 {
-       whichFont(font_, LM_TC_TEX, mi);
        if (expanded_) {
                xcell(0).metrics(mi);
                width_   = xcell(0).width();
                ascent_  = xcell(0).ascent();
                descent_ = xcell(0).descent();
-       } else
-               mathed_string_dim(font_, str_, ascent_, descent_, width_);
+       } else {
+               mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
+       }
 }
 
 
-void MathMacroArgument::draw(Painter & pain, int x, int y) const
+void MathMacroArgument::draw(MathPainterInfo & pi, int x, int y) const
 {
        if (expanded_)
-               xcell(0).draw(pain, x, y);
+               xcell(0).draw(pi, x, y);
        else
-               drawStr(pain, font_, x, y, str_);
+               drawStrRed(pi, x, y, str_);
 }
 
 
@@ -72,8 +68,5 @@ void MathMacroArgument::normalize(NormalStream & os) const
 void MathMacroArgument::substitute(MathMacro const & m)
 {
        cell(0) = m.cell(number_ - 1);
-       if (code_ != LM_TC_MIN)
-               for (MathArray::iterator it = cell(0).begin(); it != cell(0).end(); ++it)
-                       it->nucleus()->handleFont(code_);
        expanded_ = true;
 }
index cb45e631003c8f55b4ff0e146d5b8fbe9d25b1d2..1c642586a7b40c99f0d12b84b96a3151b89ec63e 100644 (file)
 class MathMacroArgument : public MathNestInset {
 public:
        ///
-       explicit MathMacroArgument(int, MathTextCodes = LM_TC_MIN);
+       explicit MathMacroArgument(int);
        ///
        MathInset * clone() const;
        ///
        bool isActive() const { return false; }
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void substitute(MathMacro const & macro);
 
@@ -38,10 +38,6 @@ private:
        char str_[3];
        ///
        bool expanded_;
-       ///
-       mutable LyXFont font_;
-       ///
-       MathTextCodes code_;
 };
 
 #endif
index 7df45d81637bb27c1182c02490c83fa4f6e3821f..b7cd35d2d36afc409ca0c60f704d8600dfc75b34 100644 (file)
@@ -108,26 +108,26 @@ void MathMacroTable::builtinMacros()
        define("\\def\\Longleftrightarrow{\\Leftarrow\\kern-8mu\\Rightarrow}");
        define("\\def\\doteq{\\stackrel{\\cdot}{\\=}}");
 
-       if (math_font_available(LM_TC_CMSY)) {
+       //if (math_font_available(LM_TC_CMSY)) {
                define("\\def\\longrightarrow{\\lyxbar\\kern-6mu\\rightarrow}");
                define("\\def\\longleftarrow{\\leftarrow\\kern-6mu\\lyxbar}");
                define("\\def\\mapsto{\\mapstochar\\kern-4mu\\rightarrow}");
                define("\\def\\longmapsto{\\mapstochar\\kern-3mu\\lyxbar\\kern-6mu\\rightarrow}");
-       }
+       //}
 
-       if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
+       //if (math_font_available(LM_TC_CMR) && math_font_available(LM_TC_CMSY)) {
                define("\\def\\Longrightarrow{\\lyxeq\\kern-5mu\\Rightarrow}");
                define("\\def\\Longleftarrow{\\Leftarrow\\kern-5mu\\lyxeq}");
                define("\\def\\models{\\vert\\kern-3mu\\lyxeq}");
-       }
+       //}
 
-       if (math_font_available(LM_TC_CMM)) {
+       //if (math_font_available(LM_TC_CMM)) {
                define("\\def\\hookrightarrow{\\lhook\\kern-8mu\\rightarrow}");
                define("\\def\\hookleftarrow{\\leftarrow\\kern-8mu\\rhook}");
                define("\\def\\bowtie{\\triangleright\\kern-2mu\\triangleleft}");
-       }
+       //}
 
-       if (math_font_available(LM_TC_MSA)) {
+       //if (math_font_available(LM_TC_MSA)) {
                //amsfonts.sty
 
                define("\\def\\dashrightarrow{\\lyxdabar\\lyxdabar\\lyxright}");
@@ -145,11 +145,11 @@ void MathMacroTable::builtinMacros()
                define("\\def\\doublecap{\\Cap}");
                define("\\def\\llless{\\lll}");
                define("\\def\\gggtr{\\ggg}");
-       }
+       //}
 
-       if (math_font_available(LM_TC_MSB)) {
+       //if (math_font_available(LM_TC_MSB)) {
                define("\\def\\Join{\\ltimes\\kern-12mu\\rtimes}");
-       }
+       //}
 
        //
        define("\\def\\mathcircumflex{\\mbox{\\^{}}}\n"   "{\\hat{}}");
index 7d518782d0ab8c32029740f034ddc11ab7b3d47c..04c96f11f8ff3470d4acad28e46be9d02e50734b 100644 (file)
@@ -47,7 +47,7 @@ string const & MathMacroTemplate::name() const
 }
 
 
-void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const
+void MathMacroTemplate::metrics(MathMetricsInfo & mi) const
 {
        xcell(0).metrics(mi);
        xcell(1).metrics(mi);
@@ -57,14 +57,14 @@ void MathMacroTemplate::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathMacroTemplate::draw(Painter & pain, int x, int y) const
+void MathMacroTemplate::draw(MathPainterInfo & pain, int x, int y) const
 {
        int const w0 = xcell(0).width();
        int const w1 = xcell(1).width();
        xcell(0).draw(pain, x + 2, y + 1);
-       pain.rectangle(x, y - ascent() + 1, w0 + 4, height(), LColor::blue);
+       pain.pain.rectangle(x, y - ascent() + 1, w0 + 4, height(), LColor::blue);
        xcell(1).draw(pain, x + 8 + w0, y + 1);
-       pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4, height(), LColor::blue);
+       pain.pain.rectangle(x + w0 + 6 , y - ascent() + 1, w1 + 4, height(), LColor::blue);
 }
 
 
index 726874ff848241c02201e241c08ad4d5d29e9751..a8f09a04ad75af19df95e803d703f623dad6361c 100644 (file)
@@ -33,9 +33,9 @@ public:
        ///
        string const & name() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        /// identifies macro templates
        MathMacroTemplate * asMacroTemplate() { return this; }
 private:
index 57d45d61ea39f46ffdd7191c449e8695bdc49af9..9c796bfa2735092a99b012e0032b01f2084e7e87 100644 (file)
@@ -19,7 +19,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const &) const {}
+       void metrics(MathMetricsInfo &) const {}
        /// identifies MatrixInsets
        MathMatrixInset const * asMatrixInset() const { return this; }
 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..81d5dbd75ebfc3274f104978e5946ef9405b30d8 100644 (file)
@@ -0,0 +1,149 @@
+
+#include <config.h>
+
+#include "math_metricsinfo.h"
+#include "math_support.h"
+#include "frontends/Painter.h"
+
+
+
+MathMetricsBase::MathMetricsBase()
+       : font(), style(LM_ST_TEXT), fontinset(false)
+{}
+
+
+
+
+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<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_;
+}
+
+
+
+
+MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * cmd)
+       :       MathChanger<MathMetricsBase>(mb)
+{
+       save_ = mb;     
+       mb.fontinset = true;
+       augmentFont(mb.font, cmd);
+}
+
+MathFontSetChanger::~MathFontSetChanger()
+{
+       orig_ = save_;
+}
+
index d68f10533b7e05e4e2af9248848f229658445041..d607cc43393f43c9660380ed9c6ca2d0da6edc39 100644 (file)
@@ -2,8 +2,10 @@
 #define MATH_METRICSINFO_H
 
 #include "lyxfont.h"
+#include "math_defs.h"
 
 class BufferView;
+class Painter;
 class MathNestInset;
 
 
@@ -20,26 +22,27 @@ enum MathStyles {
 };
 
 
-struct MathMetricsInfo {
-       ///
-       MathMetricsInfo()
-               : view(0), font(), style(LM_ST_TEXT),
-                 inset(0), idx(0),
-                 fullredraw(false)
-       {}
+struct MathMetricsBase {
        ///
-       MathMetricsInfo(BufferView * v, LyXFont const & f, MathStyles s)
-               : view(v), font(f), style(s),
-                 inset(0), idx(0),
-                 fullredraw(false)
-       {}
+       MathMetricsBase();
 
-       ///
-       BufferView * view;
        ///
        LyXFont font;
        ///
        MathStyles style;
+       ///
+       bool fontinset;
+};
+
+
+struct MathMetricsInfo {
+       ///
+       MathMetricsInfo();
+
+       ///
+       MathMetricsBase base;
+       ///
+       BufferView * view;
        /// used to pass some info down
        MathNestInset const * inset;
        ///
@@ -49,10 +52,84 @@ struct MathMetricsInfo {
 };
 
 
-struct TextMetricsInfo {
+struct MathPainterInfo {
+       ///
+       MathPainterInfo(Painter & p);
+       ///
+       void draw(int x, int y, char c);
+
+       ///
+       MathMetricsBase base;
+       ///
+       Painter & pain;
+};
+
+
+struct TextMetricsInfo {};
+
+
+// Generic base for temporarily changing things.
+// The original state gets restored when the Changer is destructed
+template <class Struct, class Temp = Struct>
+struct MathChanger {
+       ///
+       MathChanger(Struct & orig) : orig_(orig) {}
+protected:
        ///
-       TextMetricsInfo()
-               {}
+       Struct & orig_;
+       ///
+       Temp save_;
 };
 
+
+
+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);
+       ///
+       ~MathFontChanger();
+};
+
+
+struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathFontSetChanger(MathMetricsBase & mb, char const * font);
+       ///
+       ~MathFontSetChanger();
+};
+
+
+struct MathStyleChanger : public MathChanger<MathMetricsBase> {
+       ///
+       MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
+       ///
+       ~MathStyleChanger();
+};
+
+
+struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
+       ///
+       MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
+       ///
+       ~MathShapeChanger();
+};
+
+
 #endif
index 6a11a9dbfee62ee6a0d4805bc02ae358d9bfd767..82d6c5fb47cd1b91a1d0cdbe27ef5b3ca82eb528 100644 (file)
@@ -9,7 +9,7 @@
 
 
 MathNestInset::MathNestInset(idx_type nargs)
-       : MathDimInset(), cells_(nargs)
+       : MathDimInset(), cells_(nargs), lock_(false)
 {}
 
 
@@ -182,3 +182,21 @@ bool MathNestInset::editing() const
 {
        return mathcursor && mathcursor->isInside(this);
 }
+
+
+bool MathNestInset::lock() const
+{
+       return lock_;
+}
+
+
+void MathNestInset::lock(bool l)
+{
+       lock_ = l;
+}
+
+
+bool MathNestInset::isActive() const
+{
+       return !lock_ && nargs() > 0;
+}
index 78175a75068e14160d285c3cc7d5781cb6c7bb6e..5ec120e7a42396d9c82be6a6ece499a05ccded52 100644 (file)
@@ -49,6 +49,10 @@ public:
 
        /// number of cells currently governed by us
        idx_type nargs() const;
+       /// access to the lock
+       bool lock() const;
+       /// access to the lock
+       void lock(bool);
 
        /// direct access to the cell
        MathArray & cell(idx_type);
@@ -60,7 +64,7 @@ public:
        MathXArray const & xcell(idx_type) const;
 
        /// can we move into this cell (see macroarg.h)
-       bool isActive() const { return nargs() > 0; }
+       bool isActive() const;
        /// request "external features"
        void validate(LaTeXFeatures & features) const;
 
@@ -81,6 +85,8 @@ protected:
        typedef std::vector<MathXArray> cells_type;
        /// thusly:
        cells_type cells_;
+       /// if the inset is locked, it can't be enter with the cursor
+       bool lock_;
 };
 
 #endif
index ce3db3945cb45fbe7351f3330ae0697e608de386..b341a1c6e1de21d4d74a1feaeda86e0a070e9e88 100644 (file)
@@ -26,24 +26,22 @@ void MathNotInset::normalize(NormalStream & os) const
 }
 
 
-void MathNotInset::metrics(MathMetricsInfo const & mi) const
+void MathNotInset::metrics(MathMetricsInfo & mi) const
 {
-       if (math_font_available(LM_TC_CMSY)) {
-               whichFont(font_, LM_TC_CMSY, mi);
-               mathed_char_dim(font_, 54, ascent_, descent_, width_);
-       }
-       else {
-               whichFont(font_, LM_TC_VAR, mi);
-               mathed_char_dim(font_, '/', ascent_, descent_, width_);
+       font_ = mi.base.font;
+       if (math_font_available("cmsy")) {
+               augmentFont(font_, "cmsy");
+               char_ = 54;
+       else {
+               augmentFont(font_, "mathnormal");
+               char_ = '/';
        }
+       mathed_char_dim(font_, char_, ascent_, descent_, width_);
        width_ = 0;
 }
 
 
-void MathNotInset::draw(Painter & pain, int x, int y) const
+void MathNotInset::draw(MathPainterInfo & pain, int x, int y) const
 {
-       if (math_font_available(LM_TC_CMSY))
-               drawChar(pain, font_, x, y, 54);
-       else
-               drawChar(pain, font_, x, y, '/');
+       drawChar(pain, font_, x, y, char_);
 }
index 6e56207bb0d370091fb7859bde6eb86362f0445a..c221ec0186d24a7bcb83f1696e3d077b855018f6 100644 (file)
@@ -17,11 +17,13 @@ public:
        ///
        void normalize(NormalStream & ns) const;
        ///
-       void metrics(MathMetricsInfo const & mi) const;
+       void metrics(MathMetricsInfo & mi) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 private:
        ///
        mutable LyXFont font_;
+       ///
+       mutable char char_;
 };
 #endif
index e6765fa19389d00fc7e5a7b44350c5b567eed6b8..c37de8de99aa4ea10bea9e404fb9f6073d0babbd 100644 (file)
@@ -57,7 +57,6 @@ point to write some macros:
 #include "math_charinset.h"
 #include "math_deliminset.h"
 #include "math_factory.h"
-#include "math_funcinset.h"
 #include "math_kerninset.h"
 #include "math_macro.h"
 #include "math_macrotable.h"
@@ -102,9 +101,9 @@ bool stared(string const & s)
 }
 
 
-void add(MathArray & ar, char c, MathTextCodes code)
+void add(MathArray & ar, char c)
 {
-       ar.push_back(MathAtom(new MathCharInset(c, code)));
+       ar.push_back(MathAtom(new MathCharInset(c)));
 }
 
 
@@ -253,7 +252,7 @@ public:
        ///
        bool parse_normal(MathAtom &);
        ///
-       void parse_into(MathArray & array, unsigned flags, MathTextCodes = LM_TC_MIN);
+       void parse_into(MathArray & array, unsigned flags);
        ///
        int lineno() const { return lineno_; }
        ///
@@ -261,9 +260,9 @@ public:
 
 private:
        ///
-       void parse_into1(MathArray & array, unsigned flags, MathTextCodes);
-       ///
-       string getArg(char lf, char rf);
+       void parse_into1(MathArray & array, unsigned flags);
+       /// get arg delimited by 'left' and 'right'
+       string getArg(char left, char right);
        ///
        char getChar();
        ///
@@ -731,9 +730,7 @@ bool Parser::parse_lines2(MathAtom & t, bool braced)
        return true;
 }
 
-
-
-
 bool Parser::parse_macro(string & name)
 {
        int nargs = 0;
@@ -812,7 +809,7 @@ bool Parser::parse_macro(string & name)
        MathMacroTable::create(name, nargs, ar1, ar2);
        return true;
 }
-
 
 bool Parser::parse_normal(MathAtom & matrix)
 {
@@ -930,9 +927,9 @@ bool Parser::parse_normal(MathAtom & matrix)
 }
 
 
-void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
+void Parser::parse_into(MathArray & array, unsigned flags)
 {
-       parse_into1(array, flags, code);
+       parse_into1(array, flags);
        // remove 'unnecessary' braces:
        if (array.size() == 1 && array.back()->asBraceInset()) {
                lyxerr << "extra braces removed\n";
@@ -941,7 +938,7 @@ void Parser::parse_into(MathArray & array, unsigned flags, MathTextCodes code)
 }
 
 
-void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
+void Parser::parse_into1(MathArray & array, unsigned flags)
 {
        bool panic  = false;
        int  limits = 0;
@@ -1001,14 +998,14 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                }
 
                else if (t.cat() == catLetter)
-                       add(array, t.character(), code);
+                       add(array, t.character());
 
-               else if (t.cat() == catSpace && code == LM_TC_TEXTRM)
-                       add(array, t.character(), code);
+               else if (t.cat() == catSpace) //&& code == LM_TC_TEXTRM
+                       add(array, t.character());
 
                else if (t.cat() == catParameter) {
                        Token const & n = getToken();
-                       array.push_back(MathAtom(new MathMacroArgument(n.character()-'0', code)));
+                       array.push_back(MathAtom(new MathMacroArgument(n.character()-'0')));
                }
 
                else if (t.cat() == catBegin) {
@@ -1044,7 +1041,7 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                        lyxerr << "found tab unexpectedly, array: '" << array << "'\n";
                        dump();
                        //lyxerr << "found tab unexpectedly\n";
-                       add(array, '&', LM_TC_TEX);
+                       add(array, '&'); //, LM_TC_TEX;
                }
 
                else if (t.cat() == catSuper || t.cat() == catSub) {
@@ -1066,7 +1063,7 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                        return;
 
                else if (t.cat() == catOther)
-                       add(array, t.character(), code);
+                       add(array, t.character());
 
                //
                // control sequences
@@ -1171,14 +1168,6 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                        array.push_back(MathAtom(new MathKernInset(s)));
                }
 
-/*
-               else if (t.cs() == "lyxkern") {
-                       MathAtom p = createMathInset(t.cs());
-                       parse_into(p->cell(0), flags, code);
-                       array.push_back(p);
-               }
-*/
-
                else if (t.cs() == "label") {
                        curr_label_ = getArg('{', '}');
                }
@@ -1186,7 +1175,7 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                else if (t.cs() == "choose" || t.cs() == "over" || t.cs() == "atop") {
                        MathAtom p = createMathInset(t.cs());
                        array.swap(p->cell(0));
-                       parse_into(p->cell(1), flags, code);
+                       parse_into(p->cell(1), flags);
                        array.push_back(p);
                        return;
                }
@@ -1245,36 +1234,39 @@ void Parser::parse_into1(MathArray & array, unsigned flags, MathTextCodes code)
                else if (t.cs().size()) {
                        latexkeys const * l = in_word_set(t.cs());
                        if (l) {
-                               if (l->token == LM_TK_FONT) {
-                                       //lyxerr << "starting font\n";
+                               if (l->inset == "font") {
+                                       lyxerr << "starting font " << t.cs() << "\n";
                                        //CatCode catSpaceSave = theCatcode[' '];
                                        //if (l->id == LM_TC_TEXTRM) {
                                        //      // temporarily change catcode
                                        //      theCatcode[' '] = catLetter;
                                        //}
 
-                                       MathArray ar;
-                                       parse_into(ar, FLAG_ITEM, static_cast<MathTextCodes>(l->id));
-                                       array.push_back(ar);
+                                       MathAtom p = createMathInset(t.cs());
+                                       parse_into(p->cell(0), FLAG_ITEM);
+                                       array.push_back(p);
 
                                        // undo catcode changes
-                                       ////theCatcode[' '] = catSpaceSave;
+                                       //theCatcode[' '] = catSpaceSave;
                                        //lyxerr << "ending font\n";
                                }
 
-                               else if (l->token == LM_TK_OLDFONT) {
-                                       code = static_cast<MathTextCodes>(l->id);
+                               else if (l->inset == "oldfont") {
+                                       MathAtom p = createMathInset(t.cs());
+                                       parse_into(p->cell(0), flags);
+                                       array.push_back(p);
+                                       return;
                                }
 
-                               else if (l->token == LM_TK_BOX) {
+                               else if (l->inset == "box") {
                                        MathAtom p = createMathInset(t.cs());
-                                       parse_into(p->cell(0), FLAG_ITEM | FLAG_BOX, LM_TC_BOX);
+                                       parse_into(p->cell(0), FLAG_ITEM | FLAG_BOX);
                                        array.push_back(p);
                                }
 
-                               else if (l->token == LM_TK_STY) {
+                               else if (l->inset == "style") {
                                        MathAtom p = createMathInset(t.cs());
-                                       parse_into(p->cell(0), flags, code);
+                                       parse_into(p->cell(0), flags);
                                        array.push_back(p);
                                        return;
                                }
index 0b51edbec19da0ca5ead06e3f0d0b55c8611e56c..ffd966549c7bdfc87687a7ff901367e7a2e6c185 100644 (file)
@@ -30,102 +30,17 @@ class MathAtom;
 class MathArray;
 class LyXLex;
 
-///
-enum MathTokenEnum
-{
-       ///
-       LM_TK_SYM = 256,
-       ///
-       LM_TK_BOX,
-       ///
-       LM_TK_CHOOSE,
-       ///
-       LM_TK_BINOM,
-       ///
-       LM_TK_ATOP,
-       ///
-       LM_TK_OVER,
-       ///
-       LM_TK_FRAC,
-       ///
-       LM_TK_SQRT,
-       ///
-       LM_TK_ROOT,
-       ///
-       LM_TK_LEFTEQN,
-       ///
-       LM_TK_BEGIN,
-       ///
-       LM_TK_END,
-       /// mathcal, mathrm...
-       LM_TK_OLDFONT,
-       /// cal,...
-       LM_TK_FONT,
-       ///
-       LM_TK_LEFT,
-       ///
-       LM_TK_RIGHT,
-       ///
-       LM_TK_DECORATION,
-       ///
-       LM_TK_FUNC,
-       ///
-       LM_TK_FUNCLIM,
-       ///
-       LM_TK_CMR,
-       ///
-       LM_TK_CMSY,
-       ///
-       LM_TK_CMM,
-       ///
-       LM_TK_CMEX,
-       ///
-       LM_TK_MSA,
-       ///
-       LM_TK_MSB,
-       ///
-       LM_TK_LABEL,
-       ///
-       LM_TK_NONUM,
-       ///
-       LM_TK_SPACE,
-       ///
-       LM_TK_DOTS,
-       ///
-       LM_TK_LIMIT,
-       ///
-       LM_TK_PROTECT,
-       ///
-       LM_TK_STY,
-       ///
-       LM_TK_SPECIAL,
-       ///
-       LM_TK_ARGUMENT,
-       ///
-       LM_TK_NEWCOMMAND,
-       ///
-       LM_TK_MATH,
-       ///
-       LM_TK_NOT,
-       ///
-       LM_TK_UNDERSET,
-       ///
-       LM_TK_STACK
-};
-
 
 ///
 struct latexkeys {
        /// name of the macro or primitive
        string name;
-       /// one of the categories above
-       MathTokenEnum token;
-       /// an id within a category if needed (only for spaces?)
-       unsigned int id;
-       /// which font to use (optional)
-       unsigned int latex_font_id;
-       /// operator/...
-       string type;
+       /// name of a inset that handles that macro
+       string inset;
+       /// position of the ting in a font
+       string draw;
+       /// operator/..., fontname e
+       string extra;
        /// how is this called as XML entity?
        string xmlname;
 };
index 98b8423f9491cc6ff0e0e7b7c20ffb6a31214238..bf3c211f94f9dbf12d1effc501aa81dad24ce1f3 100644 (file)
@@ -34,7 +34,7 @@ MathInset * MathRootInset::clone() const
 }
 
 
-void MathRootInset::metrics(MathMetricsInfo const & mi) const
+void MathRootInset::metrics(MathMetricsInfo & mi) const
 {
        MathNestInset::metrics(mi);
        ascent_  = max(xcell(0).ascent()  + 5, xcell(1).ascent())  + 2;
@@ -43,7 +43,7 @@ void MathRootInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathRootInset::draw(Painter & pain, int x, int y) const
+void MathRootInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        int const w = xcell(0).width();
        // the "exponent"
@@ -59,7 +59,7 @@ void MathRootInset::draw(Painter & pain, int x, int y) const
        xp[2] = x + w;        yp[2] = y + d;
        xp[3] = x + w - 2;    yp[3] = y + (d - a)/2 + 2;
        xp[4] = x;            yp[4] = y + (d - a)/2 + 2;
-       pain.lines(xp, yp, 5, LColor::math);
+       pain.pain.lines(xp, yp, 5, LColor::math);
 }
 
 
index 46034c651f4cd0e568c6183a5f8b78df516820da..e03755e0173cf4d2cb81d4da0e7038edf5c4159a 100644 (file)
@@ -34,9 +34,9 @@ public:
        ///
        bool idxUpDown(idx_type & idx, bool up) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void write(WriteStream & os) const;
index 0310eeb7922aff2ca2eb3900fc7c0f46e169d50d..e58b4cbabcfa5bb89fc58ee1f0134f3469e3f799 100644 (file)
@@ -177,19 +177,16 @@ int MathScriptInset::ndes(MathInset const * nuc) const
 }
 
 
-void MathScriptInset::metrics(MathMetricsInfo const & mi) const
+void MathScriptInset::metrics(MathMetricsInfo & mi) const
 {
        metrics(0, mi);
 }
 
 
-void MathScriptInset::metrics(MathInset const * nuc,
-       MathMetricsInfo const & mi) const
+void MathScriptInset::metrics(MathInset const * nuc, MathMetricsInfo & mi) const
 {
-       MathMetricsInfo m = mi;
-       smallerStyleScript(m);
-       MathNestInset::metrics(m);
-       whichFont(font_, LM_TC_VAR, m);
+       MathScriptChanger dummy(mi.base);
+       MathNestInset::metrics(mi);
        if (nuc)
                nuc->metrics(mi);
        ascent_  = ascent2(nuc);
@@ -198,10 +195,11 @@ void MathScriptInset::metrics(MathInset const * nuc,
 }
 
 
-void MathScriptInset::draw(Painter & pain, int x, int y) const
+void MathScriptInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "unexpected call to MathScriptInset::draw()\n";
-       draw(0, pain, x, y);
+       MathScriptChanger dummy(pi.base);
+       draw(0, pi, x, y);
 }
 
 
@@ -226,21 +224,22 @@ void MathScriptInset::metricsT(MathInset const * nuc,
 }
 
 
-void MathScriptInset::draw(MathInset const * nuc, Painter & pain,
+void MathScriptInset::draw(MathInset const * nuc, MathPainterInfo & pi,
        int x, int y) const
 {
+       MathScriptChanger dummy(pi.base);
        if (nuc)
-               nuc->draw(pain, x + dxx(nuc), y);
+               nuc->draw(pi, x + dxx(nuc), y);
        else if (editing())
-               drawStr(pain, font_, x + dxx(nuc), y, ".");
+               drawStr(pi, font_, x + dxx(nuc), y, ".");
 
        if (hasUp())
-               up().draw(pain, x + dx1(nuc), y - dy1(nuc));
-
+               up().draw(pi, x + dx1(nuc), y - dy1(nuc));
        if (hasDown())
-               down().draw(pain, x + dx0(nuc), y + dy0(nuc));
+               down().draw(pi, x + dx0(nuc), y + dy0(nuc));
 }
 
+
 void MathScriptInset::drawT(TextPainter & pain, int x, int y) const
 {
        //lyxerr << "unexpected call to MathScriptInset::draw()\n";
index 29049e9e27774eb60d0bfbfc7a52ff5942f10820..6087d537ec99174a3ee382c00c04354c43993040 100644 (file)
@@ -25,18 +25,18 @@ public:
        ///
        void normalize(NormalStream & os) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(TextMetricsInfo const & st) const;
        ///
        void drawT(TextPainter &, int x, int y) const;
 
        ///
-       void metrics(MathInset const * nuc, MathMetricsInfo const & st) const;
+       void metrics(MathInset const * nuc, MathMetricsInfo & st) const;
        ///
-       void draw(MathInset const * nuc, Painter &, int x, int y) const;
+       void draw(MathInset const * nuc, MathPainterInfo &, int x, int y) const;
        ///
        void metricsT(MathInset const * nuc, TextMetricsInfo const & st) const;
        ///
index 0f4eb4667aa4e1dce1d685e410894a59eddec411..07c9cfdc999e32b18b2fd3cb872184f5d5fa5027 100644 (file)
@@ -22,21 +22,21 @@ MathInset * MathSizeInset::clone() const
 }
 
 
-void MathSizeInset::draw(Painter & pain, int x, int y) const
+void MathSizeInset::metrics(MathMetricsInfo & mi) const
 {
-       xcell(0).draw(pain, x + 1, y);
-       mathed_draw_framebox(pain, x, y, this);
+       //MathStyleChanger dummy(mi.base, MathStyles(key_->id));
+       xcell(0).metrics(mi);
+       ascent_   = xcell(0).ascent_ + 1;
+       descent_  = xcell(0).descent_ + 1;
+       width_    = xcell(0).width_ + 2;
 }
 
 
-void MathSizeInset::metrics(MathMetricsInfo const & mi) const
+void MathSizeInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       MathMetricsInfo m = mi;
-       m.style = MathStyles(key_->id);
-       xcell(0).metrics(m);
-       ascent_   = xcell(0).ascent_ + 1;
-       descent_  = xcell(0).descent_ + 1;
-       width_    = xcell(0).width_ + 2;
+       //MathStyleChanger dummy(pi.base, MathStyles(key_->id));
+       xcell(0).draw(pi, x + 1, y);
+       mathed_draw_framebox(pi, x, y, this);
 }
 
 
index 048ffd498a5a8b55195059d200430e0cbeeb68da..9870777e3d495440f33247f42f1b2e3b79dba855 100644 (file)
@@ -3,7 +3,6 @@
 #define MATHSIZEINSET_H
 
 #include "math_nestinset.h"
-#include "math_defs.h"
 
 #ifdef __GNUG__
 #pragma interface
@@ -22,9 +21,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        bool needsBraces() const { return false; }
 
index 5fb436730007c321d96122a51e8754cc1ec4d470..c41de6bf80f1cfd28f5d33b35e9f855b178c79ea 100644 (file)
@@ -26,7 +26,7 @@ MathInset * MathSpaceInset::clone() const
 }
 
 
-void MathSpaceInset::metrics(MathMetricsInfo const &) const
+void MathSpaceInset::metrics(MathMetricsInfo &) const
 {
        switch (space_) {
                case 0: width_ = 6; break;
@@ -43,7 +43,7 @@ void MathSpaceInset::metrics(MathMetricsInfo const &) const
 }
 
 
-void MathSpaceInset::draw(Painter & pain, int x, int y) const
+void MathSpaceInset::draw(MathPainterInfo & pain, int x, int y) const
 {
 
 // Sadly, HP-UX CC can't handle that kind of initialization.
@@ -59,7 +59,7 @@ void MathSpaceInset::draw(Painter & pain, int x, int y) const
        xp[2] = x + width_ - 2;  yp[2] = y;
        xp[3] = x + width_ - 2;  yp[3] = y - 3;
 
-       pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
+       pain.pain.lines(xp, yp, 4, space_ ? LColor::latex : LColor::math);
 }
 
 
index 74c86d88482e226766cdff96f0a0f9ea2c15e42a..84ba58fb8db3a33fe7960b1a7fc3c9759d0d674c 100644 (file)
@@ -3,7 +3,6 @@
 #define MATH_SPACEINSET_H
 
 #include "math_diminset.h"
-#include "math_defs.h"
 
 #ifdef __GNUG__
 #pragma interface
@@ -23,9 +22,9 @@ public:
        ///
        void incSpace();
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void normalize(NormalStream &) const;
index b00c832f5b75f4aa65bc174d4ec81804ab43d115..562fe89d3c0de38b917054fb44d7304db8d0f6ab 100644 (file)
@@ -18,33 +18,17 @@ MathInset * MathSpecialCharInset::clone() const
 }
 
 
-int MathSpecialCharInset::ascent() const
+void MathSpecialCharInset::metrics(MathMetricsInfo & mi) const
 {
-       return mathed_char_ascent(font_, char_);
+       MathShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
+       mathed_char_dim(mi.base.font, char_, ascent_, descent_, width_);
 }
 
 
-int MathSpecialCharInset::descent() const
+void MathSpecialCharInset::draw(MathPainterInfo & pi, int x, int y) const
 {
-       return mathed_char_descent(font_, char_);
-}
-
-
-int MathSpecialCharInset::width() const
-{
-       return mathed_char_width(font_, char_);
-}
-
-
-void MathSpecialCharInset::metrics(MathMetricsInfo const & mi) const
-{
-       whichFont(font_, LM_TC_CONST, mi);
-}
-
-
-void MathSpecialCharInset::draw(Painter & pain, int x, int y) const
-{
-       drawChar(pain, font_, x, y, char_);
+       MathShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE);
+       pi.draw(x, y, char_);
 }
 
 
index 118760ed0cf853b2b8ebc2d4e1a0d058630834eb..7d17eab8b7ff3570cd2c34c793a7f3e92e179bcb 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef MATH_SPECIALCHARINSET_H
 #define MATH_SPECIALCHARINSET_H
 
-#include "math_inset.h"
+#include "math_diminset.h"
 
 #ifdef __GNUG__
 #pragma interface
     \author André Pönitz
  */
 
-class MathSpecialCharInset : public MathInset {
+class MathSpecialCharInset : public MathDimInset {
 public:
        ///
        explicit MathSpecialCharInset(char c);
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
        void normalize(NormalStream &) const;
-       ///
-       int ascent() const;
-       ///
-       int descent() const;
-       ///
-       int width() const;
 
 private:
        /// the character
        char char_;
-       ///
-       mutable LyXFont font_;
 };
 #endif
index 3b6a330cbde0b2e3b91dfcdb4650f987020bcb0b..02c3a780bc5f83b60a0b6111b8a3376b68f47baa 100644 (file)
@@ -20,7 +20,7 @@ MathInset * MathSqrtInset::clone() const
 }
 
 
-void MathSqrtInset::metrics(MathMetricsInfo const & mi) const
+void MathSqrtInset::metrics(MathMetricsInfo & mi) const
 {
        xcell(0).metrics(mi);
        ascent_  = xcell(0).ascent()  + 4;
@@ -29,7 +29,7 @@ void MathSqrtInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathSqrtInset::draw(Painter & pain, int x, int y) const
+void MathSqrtInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        xcell(0).draw(pain, x + 10, y);
        int const a = ascent_;
@@ -40,7 +40,7 @@ void MathSqrtInset::draw(Painter & pain, int x, int y) const
        xp[1] = x + 8;      yp[1] = y - a + 1;
        xp[2] = x + 5;      yp[2] = y + d - 1;
        xp[3] = x;          yp[3] = y + (d - a)/2;
-       pain.lines(xp, yp, 4, LColor::math);
+       pain.pain.lines(xp, yp, 4, LColor::math);
 }
 
 
index 69ab8d13f9be3a45985f4050d9da2b76ce50149e..9ce0c237a573ea4e1a778a801f7b33713a0751bb 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
-       void metrics(MathMetricsInfo const & mi) const;
+       void metrics(MathMetricsInfo & mi) const;
        ///
        void drawT(TextPainter &, int x, int y) const;
        ///
index 73500944eb02a6cb3b29f791868372d2b8cbea67..90ee3638b47b7cd629dc99a88a065cf35f862181 100644 (file)
@@ -20,24 +20,24 @@ MathInset * MathStackrelInset::clone() const
 }
 
 
-void MathStackrelInset::metrics(MathMetricsInfo const & mi) const
+void MathStackrelInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo m = mi;
-       smallerStyleFrac(m);
-       xcell(0).metrics(m);
        xcell(1).metrics(mi);
+       MathFracChanger dummy(mi.base);
+       xcell(0).metrics(mi);
        width_   = max(xcell(0).width(), xcell(1).width()) + 4;
        ascent_  = xcell(1).ascent() + xcell(0).height() + 4;
        descent_ = xcell(1).descent();
 }
 
 
-void MathStackrelInset::draw(Painter & pain, int x, int y) const
+void MathStackrelInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int m  = x + width() / 2;
        int yo = y - xcell(1).ascent() - xcell(0).descent() - 1;
-       xcell(0).draw(pain, m - xcell(0).width() / 2, yo);
-       xcell(1).draw(pain, m - xcell(1).width() / 2, y);
+       xcell(1).draw(pi, m - xcell(1).width() / 2, y);
+       MathFracChanger dummy(pi.base);
+       xcell(0).draw(pi, m - xcell(0).width() / 2, yo);
 }
 
 
index 7c2e8cd4758c2b220edd6f119651b3c231705821..5f6b8fe9805fbdb7ed4f0e5d3002f86581ca5b83 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void write(WriteStream & os) const;
index 988ac652080b6e53ee8ca6b5318dc7b0c660d921..bb381f340c96d5d8c6379c0b3e6f0e53adb8c283 100644 (file)
@@ -8,21 +8,18 @@
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 #include "LColor.h"
-#include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_parser.h"
 #include "LaTeXFeatures.h"
 #include "debug.h"
 
-#include <cctype>
-
 
 MathStringInset::MathStringInset()
-       : str_(), code_(LM_TC_MIN)
+       : str_()
 {}
 
-MathStringInset::MathStringInset(string const & s, MathTextCodes t)
-       : str_(s), code_(t)
+MathStringInset::MathStringInset(string const & s)
+       : str_(s)
 {}
 
 
@@ -32,42 +29,16 @@ MathInset * MathStringInset::clone() const
 }
 
 
-int MathStringInset::ascent() const
-{
-       return mathed_string_ascent(font_, str_);
-}
-
-
-int MathStringInset::descent() const
+void MathStringInset::metrics(MathMetricsInfo & mi) const
 {
-       return mathed_string_descent(font_, str_);
+       mathed_string_dim(mi.base.font, str_, ascent_, descent_, width_);
 }
 
 
-int MathStringInset::width() const
-{
-       return mathed_string_width(font_, str_);
-}
-
-
-void MathStringInset::validate(LaTeXFeatures & features) const
-{
-       //lyxerr << "stringinset amssymb" << endl;
-       if (code_ == LM_TC_MSA || code_ == LM_TC_MSB)
-               features.require("amssymb");
-}
-
-
-void MathStringInset::metrics(MathMetricsInfo const & mi) const
-{
-       whichFont(font_, code_, mi);
-}
-
-
-void MathStringInset::draw(Painter & pain, int x, int y) const
+void MathStringInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        //lyxerr << "drawing '" << str_ << "' code: " << code_ << endl;
-       drawStr(pain, font_, x, y, str_);
+       drawStr(pi, pi.base.font, x, y, str_);
 }
 
 
@@ -79,7 +50,7 @@ void MathStringInset::normalize(NormalStream & os) const
 
 void MathStringInset::maplize(MapleStream & os) const
 {
-       if (code_ != LM_TC_VAR || str_.size() <= 1) {
+       if (/*code_ != LM_TC_VAR || */ str_.size() <= 1) {
                os << ' ' << str_ << ' ';
                return;
        }
@@ -93,7 +64,7 @@ void MathStringInset::maplize(MapleStream & os) const
 
 void MathStringInset::octavize(OctaveStream & os) const
 {
-       if (code_ != LM_TC_VAR || str_.size() <= 1) {
+       if (/*code_ != LM_TC_VAR ||*/ str_.size() <= 1) {
                os << ' ' << str_ << ' ';
                return;
        }
@@ -107,6 +78,7 @@ void MathStringInset::octavize(OctaveStream & os) const
 
 void MathStringInset::mathmlize(MathMLStream & os) const
 {
+/*
        if (code_ == LM_TC_VAR)
                os << "<mi> " << str_ << " </mi>";
        else if (code_ == LM_TC_CONST)
@@ -114,14 +86,12 @@ void MathStringInset::mathmlize(MathMLStream & os) const
        else if (code_ == LM_TC_RM || code_ == LM_TC_TEXTRM)
                os << "<mtext> " << str_ <<  " </mtext>";
        else
+*/
                os << str_;
 }
 
 
 void MathStringInset::write(WriteStream & os) const
 {
-       if (math_font_name(code_))
-               os << '\\' << math_font_name(code_) << '{' << str_ << '}';
-       else
-               os << str_;
+       os << str_;
 }
index 58cfcd37834905523a379408900ae4d0cd32535b..54021486bbf3c63009ab6c9eea32e94e4d809302 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef MATH_STRINGINSET_H
 #define MATH_STRINGINSET_H
 
-#include "math_inset.h"
+#include "math_diminset.h"
 
 #ifdef __GNUG__
 #pragma interface
     \author André Pönitz
  */
 
-class MathStringInset : public MathInset {
+class MathStringInset : public MathDimInset {
 public:
        ///
        MathStringInset();
        ///
-       MathStringInset(string const & s, MathTextCodes t = LM_TC_TEXTRM);
+       explicit MathStringInset(string const & s);
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
-       ///
-       int ascent() const;
-       ///
-       int descent() const;
-       ///
-       int width() const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        string str() const { return str_; }
        ///
        MathStringInset * asStringInset() { return this; }
-       /// request "external features"
-       void validate(LaTeXFeatures & features) const;
 
        ///
        void normalize(NormalStream &) const;
@@ -51,9 +43,5 @@ public:
 public:
        /// the string
        string str_;
-       /// the font to be used on screen
-       MathTextCodes code_;
-       ///
-       mutable LyXFont font_;
 };
 #endif
index 43395d993713c1561bf4880f1d3d371a98999ddf..89635f8b3eefa0692bc4b62bb177e084eba7a76c 100644 (file)
@@ -20,12 +20,14 @@ MathInset * MathSubstackInset::clone() const
 }
 
 
-void MathSubstackInset::metrics(MathMetricsInfo const & st) const
+void MathSubstackInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       if (mi.style == LM_ST_DISPLAY)
-               mi.style = LM_ST_TEXT;
-       MathGridInset::metrics(mi);
+       if (mi.base.style == LM_ST_DISPLAY) {
+               MathStyleChanger dummy(mi.base, LM_ST_TEXT);
+               MathGridInset::metrics(mi);
+       } else {
+               MathGridInset::metrics(mi);
+       }
 }
 
 
index 4b3115efcf7fb9b29333038bfaf48722a49c123f..d0ec7098a7a0a6745a0a830217aba3933086bf85 100644 (file)
@@ -16,7 +16,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        MathSubstackInset const * asSubstackInset() const { return this; }
 
index 962e0e09c05e6cebfbc74c2097cd731718036139..2dd4f234f849e222df072788eccc2fd96e56f95a 100644 (file)
@@ -52,221 +52,6 @@ void Matrix::transform(double & x, double & y)
 }
 
 
-namespace {
-
-LyXFont * MathFonts = 0;
-bool font_available[LM_FONT_END];
-bool font_available_initialized[LM_FONT_END];
-
-enum MathFont {
-       FONT_IT,
-       FONT_SYMBOL,
-       FONT_SYMBOLI,
-       FONT_BF,
-       FONT_TT,
-       FONT_RM,
-       FONT_SF,
-       FONT_CMR,
-       FONT_CMSY,
-       FONT_CMM,
-       FONT_CMEX,
-       FONT_MSA,
-       FONT_MSB,
-       FONT_EUFRAK,
-       FONT_FAKEBB,
-       FONT_FAKECAL,
-       FONT_FAKEFRAK,
-       FONT_NUM
-};
-
-void mathed_init_fonts()
-{
-       MathFonts = new LyXFont[FONT_NUM];
-
-       MathFonts[FONT_IT].setShape(LyXFont::ITALIC_SHAPE);
-
-       MathFonts[FONT_SYMBOL].setFamily(LyXFont::SYMBOL_FAMILY);
-
-       MathFonts[FONT_SYMBOLI].setFamily(LyXFont::SYMBOL_FAMILY);
-       MathFonts[FONT_SYMBOLI].setShape(LyXFont::ITALIC_SHAPE);
-
-       MathFonts[FONT_BF].setSeries(LyXFont::BOLD_SERIES);
-
-       MathFonts[FONT_TT].setFamily(LyXFont::TYPEWRITER_FAMILY);
-       MathFonts[FONT_RM].setFamily(LyXFont::ROMAN_FAMILY);
-       MathFonts[FONT_SF].setFamily(LyXFont::SANS_FAMILY);
-
-       MathFonts[FONT_CMR].setFamily(LyXFont::CMR_FAMILY);
-       MathFonts[FONT_CMSY].setFamily(LyXFont::CMSY_FAMILY);
-       MathFonts[FONT_CMM].setFamily(LyXFont::CMM_FAMILY);
-       MathFonts[FONT_CMEX].setFamily(LyXFont::CMEX_FAMILY);
-       MathFonts[FONT_MSA].setFamily(LyXFont::MSA_FAMILY);
-       MathFonts[FONT_MSB].setFamily(LyXFont::MSB_FAMILY);
-       MathFonts[FONT_EUFRAK].setFamily(LyXFont::EUFRAK_FAMILY);
-
-       MathFonts[FONT_FAKEBB].setFamily(LyXFont::TYPEWRITER_FAMILY);
-       MathFonts[FONT_FAKEBB].setSeries(LyXFont::BOLD_SERIES);
-
-       MathFonts[FONT_FAKECAL].setFamily(LyXFont::SANS_FAMILY);
-       MathFonts[FONT_FAKECAL].setShape(LyXFont::ITALIC_SHAPE);
-
-       MathFonts[FONT_FAKEFRAK].setFamily(LyXFont::SANS_FAMILY);
-       MathFonts[FONT_FAKEFRAK].setSeries(LyXFont::BOLD_SERIES);
-
-       for (int i = 0; i < LM_FONT_END; ++i)
-               font_available_initialized[i] = false;
-}
-
-
-LyXFont const & whichFontBaseIntern(MathTextCodes type)
-{
-       if (!MathFonts)
-               mathed_init_fonts();
-
-       switch (type) {
-       case LM_TC_SYMB:
-       case LM_TC_BOLDSYMB:
-               return MathFonts[FONT_SYMBOLI];
-
-       case LM_TC_VAR:
-       case LM_TC_IT:
-               return MathFonts[FONT_IT];
-
-       case LM_TC_BF:
-               return MathFonts[FONT_BF];
-
-       case LM_TC_BB:
-               return MathFonts[FONT_MSB];
-
-       case LM_TC_CAL:
-               return MathFonts[FONT_CMSY];
-
-       case LM_TC_TT:
-               return MathFonts[FONT_TT];
-
-       case LM_TC_BOX:
-       case LM_TC_TEXTRM:
-       case LM_TC_CONST:
-       case LM_TC_TEX:
-       case LM_TC_RM:
-               return MathFonts[FONT_RM];
-
-       case LM_TC_SF:
-               return MathFonts[FONT_SF];
-
-       case LM_TC_CMR:
-               return MathFonts[FONT_CMR];
-
-       case LM_TC_CMSY:
-               return MathFonts[FONT_CMSY];
-
-       case LM_TC_CMM:
-               return MathFonts[FONT_CMM];
-
-       case LM_TC_CMEX:
-               return MathFonts[FONT_CMEX];
-
-       case LM_TC_MSA:
-               return MathFonts[FONT_MSA];
-
-       case LM_TC_MSB:
-               return MathFonts[FONT_MSB];
-
-       case LM_TC_EUFRAK:
-               return MathFonts[FONT_EUFRAK];
-
-       default:
-               break;
-       }
-       return MathFonts[1];
-}
-
-
-LyXFont const & whichFontBase(MathTextCodes type)
-{
-       if (!MathFonts)
-               mathed_init_fonts();
-
-       switch (type) {
-       case LM_TC_BB:
-               if (math_font_available(LM_TC_MSB))
-                       return MathFonts[FONT_MSB];
-               else
-                       return MathFonts[FONT_FAKEBB];
-
-       case LM_TC_CAL:
-               if (math_font_available(LM_TC_CMSY))
-                       return MathFonts[FONT_CMSY];
-               else
-                       return MathFonts[FONT_FAKECAL];
-
-       case LM_TC_EUFRAK:
-               if (math_font_available(LM_TC_EUFRAK))
-                       return MathFonts[FONT_EUFRAK];
-               else
-                       return MathFonts[FONT_FAKEFRAK];
-
-       default:
-               break;
-       }
-       return whichFontBaseIntern(type);
-}
-
-} // namespace
-
-
-void whichFont(LyXFont & f, MathTextCodes type, MathMetricsInfo const & size)
-{
-       f = whichFontBase(type);
-       // use actual size
-       f.setSize(size.font.size());
-
-       switch (size.style) {
-       case LM_ST_DISPLAY:
-               if (type == LM_TC_BOLDSYMB || type == LM_TC_CMEX) {
-                       f.incSize();
-                       f.incSize();
-               }
-               break;
-
-       case LM_ST_TEXT:
-               break;
-
-       case LM_ST_SCRIPT:
-               f.decSize();
-               f.decSize();
-               break;
-
-       case LM_ST_SCRIPTSCRIPT:
-               f.decSize();
-               f.decSize();
-               f.decSize();
-               break;
-
-       default:
-               lyxerr << "Math Error: wrong font size: " << size.style << endl;
-               break;
-       }
-
-       if (type != LM_TC_TEXTRM && type != LM_TC_BOX)
-               f.setColor(LColor::math);
-
-       if (type == LM_TC_TEX)
-               f.setColor(LColor::latex);
-}
-
-
-bool math_font_available(MathTextCodes type)
-{
-       if (!font_available_initialized[type]) {
-               font_available_initialized[type] = true;
-               font_available[type] = fontloader.available(whichFontBaseIntern(type));
-               if (!font_available[type])
-                       lyxerr[Debug::FONT] << "Math font " << type << " not available.\n";
-       }
-       return font_available[type];
-}
-
 
 namespace {
 
@@ -423,6 +208,13 @@ double const hlinesmall[] = {
 };
 
 
+double const ring[] = {
+       2, 5,
+       0.5, 0.8,  0.8, 0.5,  0.5, 0.2,  0.2, 0.5,  0.5, 0.8,
+       0
+};
+
+
 double const vert[] = {
        1, 0.5, 0.05,  0.5, 0.95,
        0
@@ -436,13 +228,6 @@ double const  Vert[] = {
 };
 
 
-double const ring[] = {
-       2, 5,
-       0.5, 0.8,  0.8, 0.5,  0.5, 0.2,  0.2, 0.5,  0.5, 0.8,
-       0
-};
-
-
 double const tilde[] = {
        2, 4,
        0.05, 0.8,  0.25, 0.2,  0.75, 0.8,  0.95, 0.2,
@@ -463,21 +248,21 @@ struct named_deco_struct {
 
 named_deco_struct deco_table[] = {
        // Decorations
-       {"widehat",        angle,      3 },
-       {"widetilde",      tilde,      0 },
-       {"underbar",       hline,      0 },
-       {"underline",      hline,      0 },
-       {"overline",       hline,      0 },
-       {"underbrace",     brace,      1 },
-       {"overbrace",      brace,      3 },
-       {"overleftarrow",  arrow,      1 },
-       {"overrightarrow", arrow,      3 },
-       {"overleftrightarrow", udarrow, 1 },
-       {"xleftarrow",     arrow,      1 },
-       {"xrightarrow",    arrow,      3 },
-       {"underleftarrow", arrow,      1 },
-       {"underrightarrow", arrow,     3 },
-       {"underleftrightarrow",udarrow, 1 },
+       {"widehat",             angle,    3 },
+       {"widetilde",           tilde,    0 },
+       {"underbar",            hline,    0 },
+       {"underline",           hline,    0 },
+       {"overline",            hline,    0 },
+       {"underbrace",          brace,    1 },
+       {"overbrace",           brace,    3 },
+       {"overleftarrow",       arrow,    1 },
+       {"overrightarrow",      arrow,    3 },
+       {"overleftrightarrow",  udarrow,  1 },
+       {"xleftarrow",          arrow,    1 },
+       {"xrightarrow",         arrow,    3 },
+       {"underleftarrow",      arrow,    1 },
+       {"underrightarrow",     arrow,    3 },
+       {"underleftrightarrow", udarrow,  1 },
 
        // Delimiters
        {"(",              parenth,    0 },
@@ -625,11 +410,11 @@ int mathed_string_descent(LyXFont const & font, string const & s)
 
 
 
-void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
+void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h,
        const string & name)
 {
        if (name == ".") {
-               pain.line(x + w/2, y, x + w/2, y + h,
+               pain.pain.line(x + w/2, y, x + w/2, y + h,
                          LColor::mathcursor, Painter::line_onoffdash);
                return;
        }
@@ -669,7 +454,7 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
                        else
                                mt.transform(xx, yy);
                        mt.transform(x2, y2);
-                       pain.line(x + int(xx), y + int(yy), x + int(x2), y + int(y2),
+                       pain.pain.line(x + int(xx), y + int(yy), x + int(x2), y + int(y2),
                                        LColor::math);
                }       else {
                        int xp[32];
@@ -687,53 +472,47 @@ void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
                                yp[j] = y + int(yy);
                                //  lyxerr << "P[" << j " " << xx << " " << yy << " " << x << " " << y << "]";
                        }
-                       pain.lines(xp, yp, n, LColor::math);
+                       pain.pain.lines(xp, yp, n, LColor::math);
                }
        }
 }
 
 
-void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const * p)
+void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const * p)
 {
        if (mathcursor && mathcursor->isInside(p))
-               pain.rectangle(x, y - p->ascent(), p->width(), p->height(),
+               pain.pain.rectangle(x, y - p->ascent(), p->width(), p->height(),
                        LColor::mathframe);
 }
 
 
 // In the future maybe we use a better fonts renderer
-void drawStr(Painter & pain, LyXFont const & font,
+void drawStr(MathPainterInfo & pain, LyXFont const & font,
        int x, int y, string const & str)
 {
-       pain.text(x, y, str, font);
+       pain.pain.text(x, y, str, font);
 }
 
 
-void drawChar(Painter & pain, LyXFont const & font, int x, int y, char c)
+void drawStrRed(MathPainterInfo & pi, int x, int y, string const & str)
 {
-       pain.text(x, y, c, font);
+       LyXFont f = pi.base.font;
+       f.setColor(LColor::latex);
+       pi.pain.text(x, y, str, f);
 }
 
 
-// decrease math size for super- and subscripts
-void smallerStyleScript(MathMetricsInfo & st)
+void drawStrBlack(MathPainterInfo & pi, int x, int y, string const & str)
 {
-       switch (st.style) {
-               case LM_ST_DISPLAY:
-               case LM_ST_TEXT:    st.style = LM_ST_SCRIPT; break;
-               default:            st.style = LM_ST_SCRIPTSCRIPT;
-       }
+       LyXFont f = pi.base.font;
+       f.setColor(LColor::black);
+       pi.pain.text(x, y, str, f);
 }
 
 
-// decrease math size for fractions
-void smallerStyleFrac(MathMetricsInfo & st)
+void drawChar(MathPainterInfo & pi, LyXFont const & font, int x, int y, char c)
 {
-       switch (st.style) {
-               case LM_ST_DISPLAY: st.style = LM_ST_TEXT; break;
-               case LM_ST_TEXT:    st.style = LM_ST_SCRIPT; break;
-               default:            st.style = LM_ST_SCRIPTSCRIPT;
-       }
+       pi.pain.text(x, y, c, font);
 }
 
 
@@ -744,25 +523,6 @@ void math_font_max_dim(LyXFont const & font, int & asc, int & des)
 }
 
 
-char const * math_font_name(MathTextCodes code)
-{
-       static char const * theFontNames[] = {
-               "mathrm",
-               "mathcal",
-               "mathfrak",
-               "mathbf",
-               "mathbb",
-               "mathsf",
-               "mathtt",
-               "mathit",
-               "textrm"
-       };
-
-       if (code >= LM_TC_RM && code <= LM_TC_TEXTRM)
-               return theFontNames[code - LM_TC_RM];
-       return 0;
-}
-
 string convertDelimToLatexName(string const & name)
 {
        if (name == "(")
@@ -781,3 +541,120 @@ string convertDelimToLatexName(string const & name)
                return name;
        return "\\" + name + " ";
 }
+
+
+
+
+struct fontinfo {
+       string cmd_;
+       LyXFont::FONT_FAMILY family_;
+       LyXFont::FONT_SERIES series_;
+       LyXFont::FONT_SHAPE  shape_;
+       LColor::color        color_;
+};
+
+
+LyXFont::FONT_FAMILY const def_family = LyXFont::INHERIT_FAMILY;
+LyXFont::FONT_SERIES const def_series = LyXFont::INHERIT_SERIES;
+LyXFont::FONT_SHAPE  const def_shape  = LyXFont::INHERIT_SHAPE; 
+
+
+
+fontinfo fontinfos[] = {
+       {"cmex",   LyXFont::CMEX_FAMILY, def_series, def_shape, LColor::math},
+       {"cmm",    LyXFont::CMM_FAMILY, def_series, def_shape, LColor::math},
+       {"cmr",    LyXFont::CMR_FAMILY, def_series, def_shape, LColor::math},
+       {"cmsy",   LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
+       {"eufrak", LyXFont::EUFRAK_FAMILY, def_series, def_shape, LColor::math},
+       {"mathbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::math},
+       {"mathcal",LyXFont::CMSY_FAMILY, def_series, def_shape, LColor::math},
+       {"mathnormal", def_family,def_series, def_shape, LColor::math},
+       {"mathrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::math},
+       {"mathsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::math},
+       {"msa",    LyXFont::MSA_FAMILY, def_series, def_shape, LColor::math},
+       {"msb",    LyXFont::MSB_FAMILY, def_series, def_shape, LColor::math},
+       {"textbf", def_family, LyXFont::BOLD_SERIES, def_shape, LColor::black},
+       {"textit", def_family, def_series, LyXFont::ITALIC_SHAPE, LColor::black},
+       {"textmd", def_family, LyXFont::MEDIUM_SERIES, def_shape, LColor::black},
+       {"textnormal", def_family, def_series, def_shape, LColor::black},
+       {"textrm", LyXFont::ROMAN_FAMILY, def_series, def_shape, LColor::black},
+       {"textsc", def_family, def_series, LyXFont::SMALLCAPS_SHAPE, LColor::black},
+       {"textsf", LyXFont::SANS_FAMILY, def_series, def_shape, LColor::black},
+       {"textsl", def_family, def_series, LyXFont::SLANTED_SHAPE, LColor::black},
+       {"texttt", LyXFont::TYPEWRITER_FAMILY, def_series, def_shape, LColor::black},
+       {"textup", def_family, def_series, LyXFont::UP_SHAPE, LColor::black},
+
+       {"lyxtex", def_family, def_series, def_shape, LColor::latex},
+       {"lyxsymbol", LyXFont::SYMBOL_FAMILY, def_series, def_shape, LColor::math},
+       {"lyxitsymbol", LyXFont::SYMBOL_FAMILY, def_series, LyXFont::ITALIC_SHAPE, LColor::math},
+};
+
+
+fontinfo * searchFont(string const & name)
+{
+       int const n = sizeof(fontinfos) / sizeof(fontinfo);
+       //lyxerr << "searching font '" << name << "'\n"; 
+       for (int i = 0; i < n; ++i)
+               if (fontinfos[i].cmd_ == name) {
+                       //lyxerr << "found '" << i << "'\n"; 
+                       return fontinfos + i;
+               }
+       return searchFont("mathnormal");
+}
+
+
+void augmentFont(LyXFont & font, string const & name)
+{
+       static bool initialized = false;
+       
+       if (!initialized) {
+               initialized = true;
+
+               LyXFont f1;
+               augmentFont(f1, "msb");
+               if (!fontloader.available(f1)) {
+                       lyxerr << "faking msb\n";
+                       fontinfo * info = searchFont("msb");
+                       info->family_ = LyXFont::TYPEWRITER_FAMILY;
+                       info->series_ = LyXFont::BOLD_SERIES;
+               }
+
+               LyXFont f2;
+               augmentFont(f2, "msex");
+               if (!fontloader.available(f2)) {
+                       lyxerr << "faking msex\n";
+                       fontinfo * info = searchFont("msex");
+                       info->family_ = LyXFont::SANS_FAMILY;
+                       info->series_ = LyXFont::BOLD_SERIES;
+                       info->shape_  = LyXFont::ITALIC_SHAPE;
+               }
+
+               //{"fakebb", LyXFont::TYPEWRITER_FAMILY, LyXFont::BOLD_SERIES,
+               //      LyXFont::UP_SHAPE, LColor::math},
+               //{"fakecal", LyXFont::SANS_FAMILY, LyXFont::MEDIUM_SERIES,
+               //      LyXFont::ITALIC_SHAPE, LColor::math},
+               //{"fakefrak", LyXFont::SANS_FAMILY, LyXFont::BOLD_SERIES,
+               //      LyXFont::ITALIC_SHAPE, LColor::math}
+
+       }
+
+
+       fontinfo * info = searchFont(name);
+       if (info->family_ != def_family)
+               font.setFamily(info->family_);
+
+       if (info->series_ != def_series)
+               font.setSeries(info->series_);
+
+       if (info->shape_ != def_shape)
+               font.setShape(info->shape_);
+
+       if (info->color_ != LColor::none)
+               font.setColor(info->color_);
+}
+
+
+bool math_font_available(string const & /*name*/)
+{
+       return true;
+}
index abe0a39e8318512f5142e487306fc4ecbf3b2c69..b2e104e730844b06948ffffb8418052a9f0435cd 100644 (file)
@@ -3,10 +3,9 @@
 #ifndef MATH_SUPPORT_H
 #define MATH_SUPPORT_H
 
-#include "math_defs.h"
 #include "LString.h"
 
-class Painter;
+class MathPainterInfo;
 class TextPainter;
 class latexkeys;
 class MathMetricsInfo;
@@ -19,10 +18,10 @@ int mathed_char_width(LyXFont const &, unsigned char c);
 int mathed_char_ascent(LyXFont const &, unsigned char c);
 int mathed_char_descent(LyXFont const &, unsigned char c);
 
-void mathed_draw_deco(Painter & pain, int x, int y, int w, int h,
+void mathed_draw_deco(MathPainterInfo & pain, int x, int y, int w, int h,
        string const & name);
 
-void mathed_draw_framebox(Painter & pain, int x, int y, MathInset const *);
+void mathed_draw_framebox(MathPainterInfo & pain, int x, int y, MathInset const *);
 
 void mathed_string_dim(LyXFont const &,
        string const & s, int & asc, int & des, int & wid);
@@ -31,23 +30,20 @@ int mathed_string_width(LyXFont const &, string const & s);
 int mathed_string_ascent(LyXFont const &, string const & s);
 int mathed_string_descent(LyXFont const &, string const & s);
 
-void drawStr(Painter & pain, LyXFont const &, int x, int y, string const & s);
-void drawChar(Painter & pain, LyXFont const & font, int x, int y, char c);
+void drawStr(MathPainterInfo & pain,
+       LyXFont const &, int x, int y, string const & s);
+void drawStrRed(MathPainterInfo & pain, int x, int y, string const & s);
+void drawStrBlack(MathPainterInfo & pain, int x, int y, string const & s);
+void drawChar(MathPainterInfo & pain,
+       LyXFont const & font, int x, int y, char c);
 
 void math_font_max_dim(LyXFont const &, int & asc, int & desc);
 
-bool math_font_available(MathTextCodes code);
-
-// decrease math size for super- and subscripts
-void smallerStyleScript(MathMetricsInfo &);
-
-// decrease math size for fractions
-void smallerStyleFrac(MathMetricsInfo & st);
-
-char const * math_font_name(MathTextCodes type);
+bool math_font_available(string const & name);
 
 string convertDelimToLatexName(string const & name);
 
-void whichFont(LyXFont & f, MathTextCodes type, MathMetricsInfo const & size);
+void augmentFont(LyXFont & f, string const & cmd);
+
 
 #endif
index 952dc816aeafae2d3e124ca388941ea55abeaf13..7ff59dc436441fd08946c1a462e2b781a18d26dc 100644 (file)
@@ -34,111 +34,69 @@ MathInset * MathSymbolInset::clone() const
 }
 
 
-MathTextCodes MathSymbolInset::code() const
-{
-       switch (sym_->token) {
-       case LM_TK_CMR:
-               return LM_TC_CMR;
-       case LM_TK_CMSY:
-               return LM_TC_CMSY;
-       case LM_TK_CMM:
-               return LM_TC_CMM;
-       case LM_TK_CMEX:
-               return LM_TC_CMEX;
-       case LM_TK_MSA:
-               return LM_TC_MSA;
-       case LM_TK_MSB:
-               return LM_TC_MSB;
-       default:
-               return LM_TC_SYMB;
-       }
-}
-
-
-MathTextCodes MathSymbolInset::code2() const
-{
-       if (sym_->token == LM_TK_CMEX)
-               return LM_TC_BOLDSYMB;
-       else
-               return LM_TC_SYMB;
-}
-
-
 string MathSymbolInset::name() const
 {
        return sym_->name;
 }
 
 
-void MathSymbolInset::metrics(MathMetricsInfo const & mi) const
-{
-       LyXFont font;
-       mi_ = mi;
-       MathTextCodes c = code();
-       if (sym_->latex_font_id > 0 && math_font_available(c)) {
-               whichFont(font, c, mi_);
-               mathed_char_dim(font, char(sym_->latex_font_id), ascent_, descent_, width_);
-               if (c == LM_TC_CMEX) {
-                       h_ = 4 * descent_ / 5;
-                       ascent_  += h_;
-                       descent_ -= h_;
-               }
-       } else {
-               if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB)) {
-                       whichFont(font, code2(), mi_);
-                       mathed_char_dim(font, char(sym_->id), ascent_, descent_, width_);
-               } else {
-                       whichFont(font, LM_TC_TEX, mi_);
-                       mathed_string_dim(font, sym_->name, ascent_, descent_, width_);
-               }
+void MathSymbolInset::metrics(MathMetricsInfo & mi) const
+{
+       //lyxerr << "metrics: symbol: '" << sym_->name
+       //      << "' in font: '" << sym_->inset
+       //      << "' drawn as: '" << sym_->draw
+       //      << "'\n";
+       MathFontSetChanger dummy(mi.base, sym_->inset.c_str());
+       mathed_string_dim(mi.base.font, sym_->draw, ascent_, descent_, width_);
+       if (sym_->inset == "cmex") {
+               h_ = 4 * descent_ / 5;
+               ascent_  += h_;
+               descent_ -= h_;
        }
        if (isRelOp())
                width_ += 6;
+       scriptable_ = (mi.base.style == LM_ST_DISPLAY && sym_->inset == "cmex");
 }
 
 
-void MathSymbolInset::draw(Painter & pain, int x, int y) const
+void MathSymbolInset::draw(MathPainterInfo & pi, int x, int y) const
 {
+       //lyxerr << "metrics: symbol: '" << sym_->name
+       //      << "' in font: '" << sym_->inset
+       //      << "' drawn as: '" << sym_->draw
+       //      << "'\n";
        if (isRelOp())
                x += 3;
-       MathTextCodes Code = code();
-       LyXFont font;
-       if (sym_->latex_font_id > 0 && math_font_available(Code)) {
-               whichFont(font, Code, mi_);
-               drawChar(pain, font, x, y - h_, char(sym_->latex_font_id));
-       } else if (sym_->id > 0 && sym_->id < 255 && math_font_available(LM_TC_SYMB)){
-               whichFont(font, code2(), mi_);
-               drawChar(pain, font, x, y, char(sym_->id));
-       } else {
-               whichFont(font, LM_TC_TEX, mi_);
-               drawStr(pain, font, x, y, sym_->name);
-       }
+       MathFontSetChanger dummy(pi.base, sym_->inset.c_str());
+       drawStr(pi, pi.base.font, x, y - h_, sym_->draw);
 }
 
 
 bool MathSymbolInset::isRelOp() const
 {
-       return sym_->type == "mathrel";
+       return sym_->extra == "mathrel";
 }
 
 
 bool MathSymbolInset::isScriptable() const
 {
-       return mi_.style == LM_ST_DISPLAY && sym_->token == LM_TK_CMEX;
+       return scriptable_;
 }
 
 
 bool MathSymbolInset::takesLimits() const
 {
-       return sym_->token == LM_TK_CMEX;
+       return sym_->inset == "cmex" || sym_->inset == "lyxboldsymb";
 }
 
+
 void MathSymbolInset::validate(LaTeXFeatures & features) const
 {
-       if (sym_->token == LM_TK_MSA || sym_->token == LM_TK_MSB)
+       if (sym_->inset == "msa" || sym_->inset == "msb")
                features.require("amssymb");
 }
 
+
 void MathSymbolInset::normalize(NormalStream & os) const
 {
        os << "[symbol " << name() << "]";
@@ -171,7 +129,7 @@ bool MathSymbolInset::match(MathInset * p) const
 
 void MathSymbolInset::mathmlize(MathMLStream & os) const
 {
-       char const * type = MathMLtype(sym_->type);
+       char const * type = MathMLtype(sym_->extra);
        os << '<' << type << "> ";
        if (sym_->xmlname == "x") // unknown so far
                os << name();
index 018fc63b8540229880905febbcca3d544cb48ef4..22b3f86901b5206d5c55859da33591d3aca9bef6 100644 (file)
@@ -20,9 +20,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        bool isRelOp() const;
        /// do we take scripts?
@@ -54,16 +54,11 @@ public:
        void infoize(std::ostream & os) const;
 
 private:
-       ///
-       MathTextCodes code() const;
-       ///
-       MathTextCodes code2() const;
-
        ///
        latexkeys const * sym_;
        ///
        mutable int h_;
        ///
-       mutable MathMetricsInfo mi_;
+       mutable bool scriptable_;
 };
 #endif
index c06fa46ddab9a7b16bcb1273e84bd611b1d3c0a7..7a027299bdfeb4fc95d60a2e34ce50b553751e70 100644 (file)
@@ -20,24 +20,24 @@ MathInset * MathUndersetInset::clone() const
 }
 
 
-void MathUndersetInset::metrics(MathMetricsInfo const & mi) const
+void MathUndersetInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo m = mi;
-       smallerStyleFrac(m);
-       xcell(0).metrics(m);
        xcell(1).metrics(mi);
+       MathFracChanger dummy(mi.base);
+       xcell(0).metrics(mi);
        width_   = max(xcell(0).width(), xcell(1).width()) + 4;
        ascent_  = xcell(1).ascent();
        descent_ = xcell(1).descent() + xcell(0).height() + 4;
 }
 
 
-void MathUndersetInset::draw(Painter & pain, int x, int y) const
+void MathUndersetInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        int m  = x + width() / 2;
        int yo = y + xcell(1).descent() + xcell(0).ascent() + 1;
-       xcell(0).draw(pain, m - xcell(0).width() / 2, yo);
-       xcell(1).draw(pain, m - xcell(1).width() / 2, y);
+       xcell(1).draw(pi, m - xcell(1).width() / 2, y);
+       MathFracChanger dummy(pi.base);
+       xcell(0).draw(pi, m - xcell(0).width() / 2, yo);
 }
 
 
index 35ed008fee2a534be75c964506031d01a61dae2b..a673a74781203e877fd63179254f121216acfa8f 100644 (file)
@@ -18,9 +18,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
 
        ///
        void write(WriteStream & os) const;
index b58588e1fa0cb852391274200344ed414176b51d..b7256c3d58e551822416ff2b12d8361aec1f0d1c 100644 (file)
@@ -5,17 +5,13 @@
 #endif
 
 #include "math_unknowninset.h"
-#include "frontends/Painter.h"
 #include "math_support.h"
 #include "math_mathmlstream.h"
 #include "math_streamstr.h"
 
 
-extern LyXFont WhichFont(short type, int size);
-
-
-MathUnknownInset::MathUnknownInset(string const & nm)
-       : name_(nm)
+MathUnknownInset::MathUnknownInset(string const & nm, bool final, bool black)
+       : name_(nm), final_(final), black_(black)
 {}
 
 
@@ -31,9 +27,9 @@ string const & MathUnknownInset::name() const
 }
 
 
-void MathUnknownInset::setName(string const & n)
+string & MathUnknownInset::name()
 {
-       name_ = n;
+       return name_;
 }
 
 
@@ -56,16 +52,30 @@ void MathUnknownInset::normalize(NormalStream & os) const
 }
 
 
-void MathUnknownInset::metrics(MathMetricsInfo const & mi) const
+void MathUnknownInset::metrics(MathMetricsInfo & mi) const
+{
+       mathed_string_dim(mi.base.font, name_, ascent_, descent_, width_);
+}
+
+
+void MathUnknownInset::draw(MathPainterInfo & pi, int x, int y) const
+{
+       if (black_)
+               drawStrBlack(pi, x, y, name_);
+       else
+               drawStrRed(pi, x, y, name_);
+}
+
+
+void MathUnknownInset::finalize()
 {
-       whichFont(font_, LM_TC_TEX, mi);
-       mathed_string_dim(font_, name_, ascent_, descent_, width_);
+       final_ = true;
 }
 
 
-void MathUnknownInset::draw(Painter & pain, int x, int y) const
+bool MathUnknownInset::final() const
 {
-       drawStr(pain, font_, x, y, name_);
+       return final_;
 }
 
 
index 4389f8aecd81d8d8adaac07631b111ccefaac058..2e9dd5b82b586570622285ec8396bc6840559648 100644 (file)
@@ -3,7 +3,6 @@
 #define MATH_UNKNOWNINSET_H
 
 #include "math_diminset.h"
-#include "math_defs.h"
 
 #ifdef __GNUG__
 #pragma interface
 class MathUnknownInset : public MathDimInset {
 public:
        ///
-       explicit MathUnknownInset(string const & name);
+       explicit MathUnknownInset(string const & name,
+               bool final = true, bool black = false);
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
+       ///
+       string & name();
        ///
        string const & name() const;
        /// identifies UnknownInsets
        MathUnknownInset const * asUnknownInset() const { return this; }
-       ///
-       void setName(string const &);
+       /// identifies UnknownInsets
+       MathUnknownInset * asUnknownInset() { return this; }
        ///
        bool match(MathInset * p) const;
 
@@ -41,10 +43,16 @@ public:
        void octavize(OctaveStream &) const;
        ///
        void write(WriteStream &) const;
+       ///
+       void finalize();
+       ///
+       bool final() const;
 private:
        ///
        string name_;
+       /// are we finished creating the name?
+       bool final_;
        ///
-       mutable LyXFont font_;
+       bool black_;
 };
 #endif
index 32959e666e14939fafb62b4499c43e4bd7111e9d..e95b47745f1ae61158c111091e3681ef21ffb56a 100644 (file)
@@ -22,10 +22,10 @@ MathInset * MathXArrowInset::clone() const
 }
 
 
-void MathXArrowInset::metrics(MathMetricsInfo const & st) const
+void MathXArrowInset::metrics(MathMetricsInfo & mi) const
 {
-       MathMetricsInfo mi = st;
-       smallerStyleScript(mi);
+       //MathMetricsInfo mi = st;
+       //smallerStyleScript(mi);
        xcell(0).metrics(mi);
        width_   = xcell(0).width() + 10;
        ascent_  = xcell(0).height() + 10;
@@ -33,7 +33,7 @@ void MathXArrowInset::metrics(MathMetricsInfo const & st) const
 }
 
 
-void MathXArrowInset::draw(Painter & pain, int x, int y) const
+void MathXArrowInset::draw(MathPainterInfo & pain, int x, int y) const
 {
        xcell(0).draw(pain, x + 5, y - 10);
        mathed_draw_deco(pain, x + 1, y - 7, width_ - 2, 5, name_);
index d086145726e96a86f3ca8f64a76df1f636c20a82..40078548cc4895f0e8e90de6fbdd19dad7ac5503 100644 (file)
@@ -20,11 +20,11 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void draw(Painter &, int x, int y) const;
+       void draw(MathPainterInfo &, int x, int y) const;
        ///
        void write(WriteStream & os) const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        void normalize(NormalStream & os) const;
 
index 6c9bcbd75a4395e03ff3d9910b1f85a9f1bfd610..854ddffc9dc307baf5562e69d84db1da84bb7a08 100644 (file)
@@ -32,7 +32,7 @@ void MathXArray::touch() const
 }
 
 
-void MathXArray::metrics(MathMetricsInfo const & mi) const
+void MathXArray::metrics(MathMetricsInfo & mi) const
 {
        //if (clean_)
        //      return;
@@ -42,9 +42,7 @@ void MathXArray::metrics(MathMetricsInfo const & mi) const
        drawn_  = false;
 
        if (data_.empty()) {
-               LyXFont font;
-               whichFont(font, LM_TC_VAR, mi);
-               mathed_char_dim(font, 'I', ascent_, descent_, width_);
+               mathed_char_dim(mi.base.font, 'I', ascent_, descent_, width_);
                return;
        }
 
@@ -73,7 +71,7 @@ void MathXArray::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathXArray::draw(Painter & pain, int x, int y) const
+void MathXArray::draw(MathPainterInfo & pi, int x, int y) const
 {
        //if (drawn_ && x == xo_ && y == yo_)
        //      return;
@@ -86,17 +84,17 @@ void MathXArray::draw(Painter & pain, int x, int y) const
 
        if (y + descent_ <= 0)                   // don't draw above the workarea
                return;
-       if (y - ascent_ >= pain.paperHeight())   // don't draw below the workarea
+       if (y - ascent_ >= pi.pain.paperHeight())   // don't draw below the workarea
                return;
        if (x + width_ <= 0)                     // don't draw left of workarea
                return;
-       if (x >= pain.paperWidth())              // don't draw right of workarea
+       if (x >= pi.pain.paperWidth())              // don't draw right of workarea
                return;
 
        const_iterator it = begin(), et = end();
 
        if (it == et) {
-               pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
+               pi.pain.rectangle(x, y - ascent_, width_, height(), LColor::mathline);
                return;
        }
 
@@ -104,11 +102,11 @@ void MathXArray::draw(Painter & pain, int x, int y) const
                MathInset const * p = it->nucleus();
                MathScriptInset const * q = (it + 1 == et) ? 0 : asScript(it);
                if (q) {
-                       q->draw(p, pain, x, y);
+                       q->draw(p, pi, x, y);
                        x += q->width2(p);
                        ++it;
                } else {
-                       p->draw(pain, x, y);
+                       p->draw(pi, x, y);
                        x += p->width();
                }
        }
index 41e4eedaab0665b418560266bdccf7bb0b8854c5..b35c062b9a575f02826100cec3fe7d52f511f658 100644 (file)
@@ -12,7 +12,7 @@
 #pragma interface
 #endif
 
-class Painter;
+class MathPainterInfo;
 class TextPainter;
 
 
@@ -30,9 +30,9 @@ public:
        /// constructor
        MathXArray();
        /// rebuild cached metrics information
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        /// redraw cell using cache metrics information
-       void draw(Painter & pain, int x, int y) const;
+       void draw(MathPainterInfo & pain, int x, int y) const;
        /// rebuild cached metrics information
        void metricsT(TextMetricsInfo const & st) const;
        /// redraw cell using cache metrics information
index f2d62fb84ad04258e1cb271739cf9726bebcd016..fe5a886297550599033f1b3e6f52da1994e29264 100644 (file)
@@ -64,15 +64,15 @@ MathXArray const & MathXYArrowInset::sourceCell() const
 }
 
 
-void MathXYArrowInset::metrics(MathMetricsInfo const & mi) const
+void MathXYArrowInset::metrics(MathMetricsInfo & mi) const
 {
        MathNestInset::metrics(mi);
-       mi_ = mi;
-       whichFont(font_, LM_TC_TEXTRM, mi);
+       mi_   = mi;
+       MathFontSetChanger dummy(mi.base, "textrm");
        target_ = mi.inset ? mi.inset->asXYMatrixInset() : 0;
 
        if (editing()) {
-               int w    = mathed_string_width(font_, "target: ");
+               int w    = mathed_string_width(mi.base.font, "target: ");
                width_   = w + max(xcell(0).width(), xcell(1).width());
                ascent_  = xcell(0).ascent();
                descent_ = xcell(0).descent() + xcell(1).height() + 10;
@@ -85,32 +85,33 @@ void MathXYArrowInset::metrics(MathMetricsInfo const & mi) const
 }
 
 
-void MathXYArrowInset::draw(Painter & pain, int x, int y) const
+void MathXYArrowInset::draw(MathPainterInfo & pi, int x, int y) const
 {
        metrics(mi_);
+       MathFontSetChanger dummy(pi.base, "textrm");
 
        if (editing()) {
 
                int lasc;
                int ldes;
                int lwid;
-               mathed_string_dim(font_, "target: ", lasc, ldes, lwid);
+               mathed_string_dim(pi.base.font, "target: ", lasc, ldes, lwid);
 
-               xcell(0).draw(pain, x + lwid, y);
-               drawStr(pain, font_, x + 3, y, "target");
+               xcell(0).draw(pi, x + lwid, y);
+               drawStr(pi, pi.base.font, x + 3, y, "target");
                y += max(xcell(0).descent(), ldes) + 5;
 
                y += max(xcell(1).ascent(), lasc) + 5;
-               xcell(1).draw(pain, x + lwid, y);
-               drawStr(pain, font_, x + 3, y, "label");
+               xcell(1).draw(pi, x + lwid, y);
+               drawStr(pi, pi.base.font, x + 3, y, "label");
 
        } else {
 
-               //drawStr(pain, font_, x, y, "X");
+               //drawStr(pi, font_, x, y, "X");
                MathXArray const & s = sourceCell();
                MathXArray const & t = targetCell();
-               pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);
-               xcell(1).draw(pain, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
+               pi.pain.line(s.xm(), s.ym(), t.xm(), t.ym(), LColor::math);
+               xcell(1).draw(pi, (s.xm() + t.xm())/2, (s.ym() + t.ym())/2);
 
        }
 }
index a6534e23b7da0b071ba295822506a9f48bf6a094..ecdfd3e2470d6d6002a661b9e820bfaddb0e3b47 100644 (file)
@@ -19,9 +19,9 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
-       void draw(Painter & pain, int x, int y) const;
+       void draw(MathPainterInfo & pain, int x, int y) const;
        ///
        MathXYArrowInset * asXYArrowInset() { return this; }
 
index c18052a8d97455de3f29c542ad3e8e40b2c85496..d9ae049ca2477d636178b3c34dd9451797df2745 100644 (file)
@@ -32,11 +32,11 @@ int MathXYMatrixInset::rowsep() const
 }
 
 
-void MathXYMatrixInset::metrics(MathMetricsInfo const & st) const
+void MathXYMatrixInset::metrics(MathMetricsInfo & st) const
 {
        MathMetricsInfo mi = st;
-       if (mi.style == LM_ST_DISPLAY)
-               mi.style = LM_ST_TEXT;
+       if (mi.base.style == LM_ST_DISPLAY)
+               mi.base.style = LM_ST_TEXT;
        MathGridInset::metrics(mi);
 }
 
index 3cabea91d596e10da81ba5a226d78e4d0a6dc527..c0c8600859f0ccc7b522975d4b809756abfab40c 100644 (file)
@@ -16,7 +16,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void metrics(MathMetricsInfo const & st) const;
+       void metrics(MathMetricsInfo & st) const;
        ///
        MathXYMatrixInset const * asXYMatrixInset() const { return this; }
        ///