]> git.lyx.org Git - features.git/commitdiff
Small bugfixes and cosmetic changes
authorAndré Pönitz <poenitz@gmx.net>
Mon, 9 Jul 2001 10:19:50 +0000 (10:19 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Mon, 9 Jul 2001 10:19:50 +0000 (10:19 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2208 a592a061-630c-0410-9148-cb99ea01b6c8

27 files changed:
src/mathed/ChangeLog
src/mathed/formulabase.C
src/mathed/math_accentinset.C
src/mathed/math_accentinset.h
src/mathed/math_bigopinset.C
src/mathed/math_cursor.C
src/mathed/math_decorationinset.C
src/mathed/math_defs.h
src/mathed/math_deliminset.C
src/mathed/math_dotsinset.C
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_funcinset.C
src/mathed/math_grid.C
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macrotable.C
src/mathed/math_macrotemplate.C
src/mathed/math_matrixinset.C
src/mathed/math_parser.C
src/mathed/math_root.C
src/mathed/math_scriptinset.C
src/mathed/math_sizeinset.C
src/mathed/math_spaceinset.C
src/mathed/math_spaceinset.h
src/mathed/math_sqrtinset.C

index 98823926f2f6a988ee745d68df5c5010d51d2d9a..81f989dad69793239891a60add2665ae2af9ab4e 100644 (file)
@@ -1,3 +1,9 @@
+2001-07-04 André Pönitz  <poenitz@htwm.de>
+
+       * math_*inset.C: Change order of arguments in MathInset constructor 
+
+       * math_cursor.C: Remove broken "increase space" feature for a while
+
 2001-07-07  Dekel Tsur  <dekelts@tau.ac.il>
 
        * formulabase.C (mathDispatchInsertMath): Create an inline formula.
index 66a7146698967e5eec5853ee56f1e4a57f01574e..b72eef40258c987925e55e8440344d3134d82954 100644 (file)
@@ -477,10 +477,8 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
        MathTextCodes varcode = LM_TC_MIN;
        bool was_macro = mathcursor->InMacroMode();
        bool sel = false;
-       bool space_on = false;
        bool was_selection = mathcursor->Selection();
        RESULT result = DISPATCHED;
-       static MathSpaceInset * sp = 0;
 
        hideInsetCursor(bv);
 
@@ -690,27 +688,18 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                }
                break;
 
-       case LFUN_INSERT_MATH:
+       case LFUN_INSERT_MATRIX:
                if (!arg.empty()) {
                        bv->lockedInsetStoreUndo(Undo::INSERT);
-                       mathcursor->Interpret(arg);
+                       mathcursor->Interpret("matrix " + arg);
                        updateLocal(bv);
                }
                break;
 
-       case LFUN_INSERT_MATRIX:
-               if (mathcursor) {
+       case LFUN_INSERT_MATH:
+               if (!arg.empty()) {
                        bv->lockedInsetStoreUndo(Undo::INSERT);
-                       int m = 1;
-                       int n = 1;
-                       string v_align;
-                       string h_align;
-                       istringstream is(arg.c_str());
-                       is >> m >> n >> v_align >> h_align;
-                       MathArrayInset * p = new MathArrayInset(m, n);
-                       p->valign(v_align[0]);
-                       p->halign(h_align);
-                       mathcursor->insert(p);
+                       mathcursor->Interpret(arg);
                        updateLocal(bv);
                }
                break;
@@ -764,7 +753,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
        case LFUN_PROTECTEDSPACE:
                bv->lockedInsetStoreUndo(Undo::INSERT);
                mathcursor->insert(new MathSpaceInset(1));
-               space_on = true;
                updateLocal(bv);
                break;
 
@@ -936,7 +924,7 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                                if (code != LM_TC_TEXTRM)
                                        code = LM_TC_BOP;
                                mathcursor->insert(c, code);
-                       } else if (strchr(latex_special_chars, c) && c!= '_') {
+                       } else if (strchr(latex_special_chars, c) && c != '_') {
                                MathTextCodes code = mathcursor->getLastCode();
                                if (code != LM_TC_TEXTRM)
                                        code = LM_TC_SPECIAL;
@@ -960,10 +948,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
                                        mathcursor->insert(c, LM_TC_TEXTRM);
                                } else if (was_macro) {
                                        mathcursor->MacroModeClose();
-                               } else if (sp) {
-                                       int isp = (sp->GetSpace()<5) ? sp->GetSpace()+1: 0;
-                                       sp->SetSpace(isp);
-                                       space_on = true;
                                } else {
                                        if (!mathcursor->pop())
                                                result = FINISHED;
@@ -997,9 +981,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
        //if (mathcursor)
        //              updateLocal(bv);
 
-       if (sp && !space_on)
-               sp = 0;
-
        if (mathcursor && (mathcursor->Selection() || was_selection))
                toggleInsetSelection(bv);
 
index e5c89351bb429695da7ae223414e70eabb20938d..32712c9f8724e373bd4fe336b842fa23efe9f47e 100644 (file)
@@ -8,14 +8,12 @@
 using std::ostream;
 
 MathAccentInset::MathAccentInset(byte cx, MathTextCodes f, int cd)
-       : MathInset("", LM_OT_ACCENT),
-         c(cx), fn(f), code(cd), inset(0)
+       : MathInset(1), c(cx), fn(f), code(cd), inset(0)
 {}
 
 
 MathAccentInset::MathAccentInset(MathInset * ins, int cd)
-       : MathInset("", LM_OT_ACCENT),
-         c(0), fn(LM_TC_MIN), code(cd), inset(ins)
+       : MathInset(0), c(0), fn(LM_TC_MIN), code(cd), inset(ins)
 {}
 
 
index 4f2a2696a1646bc1fe6bf8fdc895ffff38cfd572..0888c1606e525c067cf14a50fa6c1fc9e06c0b3f 100644 (file)
@@ -27,6 +27,8 @@ public:
        void Metrics(MathStyles st);
        ///
        int getAccentCode() const;
+       ///
+       bool isAccentInset() const { return true; }
 protected:
        ///
        byte c;
index 50b56f5a5904b5b1a460fc7d119e6553d717efbc..b69206490da51ea3645ae00d95acfb3a4ee41164 100644 (file)
@@ -11,7 +11,7 @@
 using std::ostream;
 
 MathBigopInset::MathBigopInset(string const & name, int id)
-       : MathScriptInset(true, false), lims_(0), sym_(id)
+       : MathScriptInset(false, true), lims_(0), sym_(id)
 {
        SetName(name);
 }
@@ -101,9 +101,12 @@ void MathBigopInset::draw(Painter & pain, int x, int y)
                t = LM_TC_TEXTRM;
        }
        if (sym_ == LM_oint) {
-               pain.arc(x, y - 5 * width_ / 4, width_, width_, 0, 360 * 64,
-                        LColor::mathline);
-               ++x;
+               int wid;
+               int asc;
+               int des;
+               mathed_char_dim(t, size(), LM_int, asc, des, wid);
+               wid += 2;
+               pain.arc(x - 1, y - (asc - des) / 2, wid, wid, 0, 360 * 64, LColor::mathline);
        }
 
        int asc, des, wid;
index cad3c861f63d630a24efe43ed1aeaaa6aa404ab2..6a1fcfe578dd2f91521039a2a83040608ad9cd44 100644 (file)
@@ -23,6 +23,7 @@
 #include <cctype>
 
 #include "math_inset.h"
+#include "math_arrayinset.h"
 #include "math_parser.h"
 #include "math_cursor.h"
 #include "math_macro.h"
@@ -560,7 +561,8 @@ void MathCursor::SetSize(MathStyles size)
 
 void MathCursor::Interpret(string const & s)
 {
-       lyxerr << "Interpret: '" << s << "'\n";
+       lyxerr << "Interpret: '" << s << "'  ('" << s.substr(0, 7)  << "' " <<
+in_word_set(s) << " \n";
 
        if (s[0] == '^') {
                MathScriptInset * p = nearbyScriptInset();
@@ -604,6 +606,20 @@ void MathCursor::Interpret(string const & s)
                        p = new MathRootInset;
                else if (MathMacroTable::hasTemplate(s))
                        p = new MathMacro(MathMacroTable::provideTemplate(s));
+               else if (s.size() > 7 && s.substr(0, 7) == "matrix ") {
+                       int m = 1;
+                       int n = 1;
+                       string v_align;
+                       string h_align;
+                       std::istringstream is(s.substr(7).c_str());
+                       is >> m >> n >> v_align >> h_align;
+                       m = std::max(1, m);
+                       n = std::max(1, n);
+                       MathArrayInset * pp = new MathArrayInset(m, n);
+                       pp->valign(v_align[0]);
+                       pp->halign(h_align);
+                       p = pp;
+               }
                else
                        p = new MathFuncInset(s, LM_OT_UNDEF);
        } else {
@@ -624,11 +640,11 @@ void MathCursor::Interpret(string const & s)
                                break;
 
                        case LM_TK_STACK:
-                               p = new MathFracInset(LM_OT_STACKREL);
+                               p = new MathFracInset("stackrel");
                                break;
 
                        case LM_TK_FRAC:
-                               p = new MathFracInset(LM_OT_FRAC);
+                               p = new MathFracInset("frac");
                                break;
 
                        case LM_TK_SQRT:
@@ -709,7 +725,7 @@ void MathCursor::MacroModeClose()
                                imacro->SetName(l->name);
                } else {
                        Left();
-                       if (nextInset()->GetType() == LM_OT_ACCENT
+                       if (nextInset()->isAccentInset()
                                setAccent(
                                        static_cast<MathAccentInset*>(nextInset())->getAccentCode());
                        array().erase(cursor_);
index de582f6f9057eafa03c52dbe480c6d53185dfd55..c8c799c796c0c4095f1239dd7d1f93619564a2cc 100644 (file)
@@ -15,7 +15,7 @@ using std::ostream;
 
 
 MathDecorationInset::MathDecorationInset(int d)
-       : MathInset("", LM_OT_DECO, 1), deco_(d)
+       : MathInset(1), deco_(d)
 {
        upper_ = deco_ != LM_underline && deco_ != LM_underbrace;
 }
index b1790c87f23bb233cdbb2846a67a5d7577b1e793..5ff51edf87d2f58ea016ec7788bf6907b1b88823 100644 (file)
@@ -134,26 +134,6 @@ enum MathInsetTypes  {
        ///
        LM_OT_FUNCLIM,
        ///
-       LM_OT_SCRIPT,
-       ///
-       LM_OT_SPACE,
-       ///
-       LM_OT_DOTS,
-       /// A fraction
-       LM_OT_FRAC,
-       ///
-       LM_OT_ATOP,
-       ///
-       LM_OT_STACKREL,
-       /// A radical
-       LM_OT_SQRT,
-       /// A delimiter
-       LM_OT_DELIM,
-       /// A decoration
-       LM_OT_DECO,
-       /// An accent
-       LM_OT_ACCENT,
-       ///
        LM_OT_MACRO,
        ///
        LM_OT_MAX
index cb4788e9badf54ac06f9d246262ef27e94b9ccac..bea47553368dd309ea97e9aaf205fa6935b4cc4f 100644 (file)
@@ -13,7 +13,7 @@
 
 
 MathDelimInset::MathDelimInset(int l, int r)
-       : MathInset("", LM_OT_DELIM, 1), left_(l), right_(r)
+       : MathInset(1), left_(l), right_(r)
 {}
 
 
index 20964b3d0a05de367fe930cf64909caec3fc5f33..d173a3bb71e16ef4181f24f2452a97469e323901 100644 (file)
@@ -12,7 +12,7 @@ using std::ostream;
 
 
 MathDotsInset::MathDotsInset(string const & name, int id)
-       : MathInset(name, LM_OT_DOTS), code_(id)
+       : MathInset(0, name), code_(id)
 {}
 
 
index 856e3b664b5b333379481908975005f091ecdeae..6376eeab4d3d98d4d7d0b77b37b4d61850e50b9c 100644 (file)
 #include "support/LOstream.h"
 
 
-MathFracInset::MathFracInset(MathInsetTypes ot)
-       : MathInset("frac", ot, 2)
-{
-       if (objtype == LM_OT_STACKREL) 
-               SetName("stackrel");
-}
+MathFracInset::MathFracInset(string const & name)
+       : MathInset(2, name)
+{}
 
 
 MathInset * MathFracInset::clone() const
@@ -46,7 +43,7 @@ void MathFracInset::draw(Painter & pain, int x, int y)
        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);
        
-       if (objtype == LM_OT_FRAC)
+       if (name() == "frac")
                pain.line(x + 2, y - 5, x + width() - 4, y - 5, LColor::mathline);
 }
 
index bf03ffc10a816e1ca934903a75d4c939f8a484b7..4a3e7ab8e841b24e51f9fd2d84c08ac7c4ad1a4f 100644 (file)
@@ -14,7 +14,7 @@
 class MathFracInset : public MathInset {
 public:
        ///
-       explicit MathFracInset(MathInsetTypes ot = LM_OT_FRAC);
+       explicit MathFracInset(const string & name);
        ///
        virtual MathInset * clone() const;
        ///
index 8af9361d01022e49d5d16715b8639022b72d576f..22ba8210899ba98db12e94fd3ead0089fecd9ccc 100644 (file)
@@ -18,7 +18,7 @@ extern LyXFont WhichFont(short type, int size);
 
 
 MathFuncInset::MathFuncInset(string const & nm, MathInsetTypes ot)
-       : MathInset(nm, ot)
+       : MathInset(0, nm, ot)
 {
        lims_ = (GetType() == LM_OT_FUNCLIM);
 }
index 111e9b3f9fa23f610f2a96284061e872834ab45f..9c3fa1a1a96d2a8bf6beed81507fe4fd36f2d9bf 100644 (file)
@@ -33,7 +33,7 @@ MathGridInset::ColInfo::ColInfo()
 
 
 MathGridInset::MathGridInset(int m, int n, string const & nm, MathInsetTypes ot)
-       : MathInset(nm, ot, m * n), rowinfo_(n), colinfo_(m), v_align_('c')
+       : MathInset(m * n, nm, ot), rowinfo_(n), colinfo_(m), v_align_('c')
 {
        if (m <= 0)
                lyxerr << "positve number of columns expected\n";
index 8685048ebed3fd444fc42d1bb58d0fb960abfb6d..82760011adc9365ab6c70af77d0b46e1e46a7a7e 100644 (file)
@@ -30,7 +30,7 @@
 int MathInset::workwidth;
 
 
-MathInset::MathInset(string const & name, MathInsetTypes ot, int nargs)
+MathInset::MathInset(int nargs, string const & name, MathInsetTypes ot)
        : name_(name), objtype(ot), width_(0), ascent_(0), descent_(0),
                size_(LM_ST_DISPLAY), cells_(nargs), xo_(0), yo_(0)
 {}
index 0b89e9046013cf4d0cab0c4f560960d71fd5d543..7b86dc3c2dbc423258a4e7305752a055c89c0e7d 100644 (file)
@@ -43,8 +43,9 @@ public:
            type and font-size
        */
        ///
-       explicit
-       MathInset (string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE, int na = 0);
+       explicit MathInset
+       (int na = 0, string const & nm = string(), MathInsetTypes ot = LM_OT_SIMPLE);
+
        /// The virtual base destructor
        virtual ~MathInset() {}
 
@@ -173,6 +174,8 @@ public:
        bool covers(int x, int y) const;
        /// Identifies ScriptInsets
        virtual bool isScriptInset() const { return false; }
+       /// Identifies AccentInsets
+       virtual bool isAccentInset() const { return false; }
        ///
        virtual bool isActive() const { return nargs() > 0; }
 
index 44752e60d7d35dbf5c55a7962fb76c8d5deb034f..fae542145cdbb9bec142edc2d02912d6046bb422 100644 (file)
@@ -34,7 +34,7 @@
 using std::endl;
 
 MathMacro::MathMacro(MathMacroTemplate const & t)
-       : MathInset(t.name(), LM_OT_MACRO, t.numargs()), tmplate_(&t)
+       : MathInset(t.numargs(), t.name(), LM_OT_MACRO), tmplate_(&t)
 {}
 
 
index dba2b18e847d58793b311777ff6904e55f943eec..4eec3606649aacad005d7e1d91f5e9f9a557d6d4 100644 (file)
@@ -147,7 +147,7 @@ void MathMacroTable::builtinMacros()
 
        // binom has two arguments
        {
-               MathFracInset * frac = new MathFracInset(LM_OT_ATOP);
+               MathFracInset * frac = new MathFracInset("atop");
                frac->cell(0).push_back(new MathMacroArgument(1));
                frac->cell(1).push_back(new MathMacroArgument(2));
 
index 2b7c3ffde42f1821d4dff464821d8216fa43d8e5..5277073473168a29dde36a29b321ee3714580363 100644 (file)
 
 
 MathMacroTemplate::MathMacroTemplate() :
-       MathInset("undefined", LM_OT_MACRO, 1), numargs_(0), users_()
+       MathInset(1, "undefined", LM_OT_MACRO), numargs_(0), users_()
 {}
 
 
 MathMacroTemplate::MathMacroTemplate(string const & nm, int numargs) :
-       MathInset(nm, LM_OT_MACRO, 1), numargs_(numargs), users_()
+       MathInset(1, nm, LM_OT_MACRO), numargs_(numargs), users_()
 {}
 
 
index e8425423920a515d5380812bd07c0f6100b9ef85..c185e874e3eea30d32b58a10381256e630695e7c 100644 (file)
@@ -475,10 +475,20 @@ void MathMatrixInset::mutate(short newtype)
                case LM_OT_EQNARRAY:
                        switch (newtype) {
                                case LM_OT_SIMPLE:
-                               case LM_OT_EQUATION:
+                               case LM_OT_EQUATION: {
+                                       string label;
+                                       bool allnonum = true;
+                                       for (int r = 0; r < nrows(); ++r) {
+                                               label += label_[r];
+                                               if (!nonum_[r])
+                                                       allnonum = false;
+                                       }
                                        glueall();
                                        mutate(newtype);
+                                       label_[0] = label;
+                                       nonum_[0] = allnonum;
                                        break;
+                               }
 
                                case LM_OT_ALIGN:
                                default:
index cd1cadf1a3d511a338c8e5eea937b0e197527d7d..20e4c73276354d261aaefa07801ae2b4aa372b5c 100644 (file)
@@ -392,9 +392,9 @@ void do_insert(MathArray & dat, unsigned char ch, MathTextCodes fcode)
 }
 
 
-void handle_frac(MathArray & dat, MathInsetTypes t)
+void handle_frac(MathArray & dat, string const & name)
 {
-       MathFracInset * p = new MathFracInset(t);
+       MathFracInset * p = new MathFracInset(name);
        mathed_parse(p->cell(0), FLAG_BRACE | FLAG_BRACE_LAST);
        mathed_parse(p->cell(1), FLAG_BRACE | FLAG_BRACE_LAST);
        dat.push_back(p);
@@ -723,15 +723,15 @@ void mathed_parse(MathArray & array, unsigned flags)
                        break;
                
                case LM_TK_CHOOSE:
-                       handle_frac(array, LM_OT_ATOP); 
+                       handle_frac(array, "atop");     
                        break;
 
                case LM_TK_STACK:
-                       handle_frac(array, LM_OT_STACKREL);     
+                       handle_frac(array, "stackrel"); 
                        break;
 
                case LM_TK_FRAC:
-                       handle_frac(array, LM_OT_FRAC); 
+                       handle_frac(array, "frac");     
                        break;
 
                case LM_TK_SQRT:
index f6ae3478f3507ff252391df250aca3beb9829f3c..da68d2536efe28d15c2845bc6a2ab1c5189837bc 100644 (file)
@@ -24,7 +24,7 @@
 #include "Painter.h"
 
 MathRootInset::MathRootInset()
-       : MathInset("sqrt", LM_OT_SQRT, 2)
+       : MathInset(2)
 {}
 
 
index 76ca5a0b94ab87940f4fc83d1c45b098b8f51409..f80a61262bbb331c501001e009df924e394d40bc 100644 (file)
 
 
 MathScriptInset::MathScriptInset()
-       : MathInset("script", LM_OT_SCRIPT, 2), up_(false), down_(false)
+       : MathInset(2), up_(false), down_(false)
 {}
 
 MathScriptInset::MathScriptInset(bool up, bool down)
-       : MathInset("script", LM_OT_SCRIPT, 2), up_(up), down_(down)
+       : MathInset(2), up_(up), down_(down)
 {}
 
 
index 762632da333115ccdd8d0df05b233009ef887205..707248a13178585148b4d0d83ddd470bcdf24b73 100644 (file)
@@ -9,7 +9,7 @@
 
 
 MathSizeInset::MathSizeInset(MathStyles st)
-       : MathInset("", LM_OT_SIMPLE, 1), style_(st)
+       : MathInset(1), style_(st)
 {
        name_ = verbose();
 }
index b53d0ed491224fe009440354cd9099c1ec102cbb..85cb73146010f5291efd83fd285f5ca4a36fe180 100644 (file)
@@ -11,8 +11,8 @@
 #include "support/LOstream.h"
 
 
-MathSpaceInset::MathSpaceInset(int sp, MathInsetTypes ot)
-       : MathInset("", ot), space_(sp)
+MathSpaceInset::MathSpaceInset(int sp)
+       : space_(sp)
 {}
 
 
index 67062c52681d98e9f8973e9f47e6c13f1eb5be8a..9983f4945b7a79d1f312ec884346c5f4b22cd33c 100644 (file)
@@ -13,9 +13,9 @@
 class MathSpaceInset : public MathInset {
 public:
        ///
-       MathSpaceInset(int sp, MathInsetTypes ot = LM_OT_SPACE);
+       explicit MathSpaceInset(int sp);
        ///
-       MathInset *  clone() const;
+       MathInset * clone() const;
        ///
        void draw(Painter &, int, int);
        ///
index df36cf28ce9645b55b1cd603d0020e3b0a90bb08..b201df05457e58715d5c6bb5c50db7a7c8b63544 100644 (file)
@@ -12,7 +12,7 @@
 
 
 MathSqrtInset::MathSqrtInset()
-       : MathInset("sqrt", LM_OT_SQRT, 1)
+       : MathInset(1)
 {}