]> git.lyx.org Git - features.git/commitdiff
mathed108.diff
authorAndré Pönitz <poenitz@gmx.net>
Thu, 26 Jul 2001 06:46:50 +0000 (06:46 +0000)
committerAndré Pönitz <poenitz@gmx.net>
Thu, 26 Jul 2001 06:46:50 +0000 (06:46 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2352 a592a061-630c-0410-9148-cb99ea01b6c8

48 files changed:
src/mathed/ChangeLog
src/mathed/Makefile.am
src/mathed/array.C
src/mathed/array.h
src/mathed/formula.C
src/mathed/formulabase.C
src/mathed/math_bigopinset.C
src/mathed/math_bigopinset.h
src/mathed/math_cursor.C
src/mathed/math_cursor.h
src/mathed/math_decorationinset.C
src/mathed/math_decorationinset.h
src/mathed/math_deliminset.C
src/mathed/math_deliminset.h
src/mathed/math_dotsinset.C
src/mathed/math_dotsinset.h
src/mathed/math_fracinset.C
src/mathed/math_fracinset.h
src/mathed/math_funcinset.C
src/mathed/math_funcinset.h
src/mathed/math_gridinset.C
src/mathed/math_gridinset.h
src/mathed/math_hash.C
src/mathed/math_inset.C
src/mathed/math_inset.h
src/mathed/math_macro.C
src/mathed/math_macro.h
src/mathed/math_macroarg.C
src/mathed/math_macroarg.h
src/mathed/math_macrotemplate.C
src/mathed/math_macrotemplate.h
src/mathed/math_matrixinset.C
src/mathed/math_matrixinset.h
src/mathed/math_parser.C
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_sqrtinset.C
src/mathed/math_sqrtinset.h
src/mathed/math_updowninset.C [deleted file]
src/mathed/math_updowninset.h [deleted file]
src/mathed/xarray.C
src/mathed/xarray.h

index 384d5f81b66f77b4d582d0ceb80c54f8ca9acf5f..e5c4c4257c33b82ce7f0a06d6ddafd1fbc5703e3 100644 (file)
@@ -2,6 +2,9 @@
        
        * formulabase.C: re-enable 'space enlargement' feature
 
+       * math_scriptinset.C:
+               math_bigopinset.C: rework of script insets
+
 2001-07-22  André Pönitz  <poenitz@gmx.net>
 
        * math_cursor.C: fix "pullArg" behaviour
index d2e13830f7a5023ffa975202b612d9de08996ee2..ead7112d3568dfa393ebfd0b0a133ac12634d8bb 100644 (file)
@@ -62,8 +62,6 @@ libmathed_la_SOURCES = \
        math_spaceinset.h \
        math_sqrtinset.C \
        math_sqrtinset.h \
-       math_updowninset.C \
-       math_updowninset.h \
        math_utils.C \
        math_utils.h \
        support.C \
index c1cee61e430c1d9d3e96aaeb9b5970f7cf8dd1aa..aa65bbcc1b2168e6718c0604eb19f6249126bf69 100644 (file)
@@ -369,3 +369,11 @@ void MathArray::Validate(LaTeXFeatures & features) const
                        nextInset(pos)->Validate(features);
 }
 
+
+void MathArray::pop_back()
+{      
+       int pos = size();
+       prev(pos);
+       erase(pos);
+}
+
index 2155c16fde9f25672fecf167c0da5d4fbb646dd7..16da85b7d33668d88eddf430c442d995bd9387db 100644 (file)
@@ -92,6 +92,8 @@ public:
        ///
        void push_back(MathArray const &);
        ///
+       void pop_back();
+       ///
        MathInset * back_inset() const;
 
        ///
index 31af423668c2985d0b523bb75415fee006172d9f..d761dd5cd92a4d569b2c21a6c855ad2368a6a5b1 100644 (file)
@@ -271,6 +271,14 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action,
                        updateLocal(bv, true);
                        break;
                }
+               
+               case LFUN_PASTESELECTION:
+               {
+                       string const clip = bv->getClipboard();
+               if (!clip.empty())
+                               par(mathed_parse(clip));
+                       break;
+               }
 
                default:
                        result = InsetFormulaBase::localDispatch(bv, action, arg);
index 2dd0a2d97e71731d463f1112a6e3e91cd027811d..d666fce5c1d2cc22fa3695037033f745711b56de 100644 (file)
@@ -507,7 +507,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action,
        }
        break;
 
-               // cursor selection ---------------------------- 
 
        case LFUN_PASTE:
                if (was_macro)
index 96eeb84aa82c2e5dd6be4a8801758cab5ec23475..cba5e869c50ad9d9b94e79d5c8945fff18404997 100644 (file)
@@ -7,7 +7,7 @@
 using std::ostream;
 
 MathBigopInset::MathBigopInset(string const & name, int id)
-       : MathUpDownInset(false, false), sym_(id), limits_(0)
+       : sym_(id)
 {
        SetName(name);
 }
@@ -19,29 +19,10 @@ MathInset * MathBigopInset::clone() const
 }
 
 
-int MathBigopInset::limits() const 
-{
-       return limits_; 
-} 
-
-
-void MathBigopInset::limits(int limits) 
-{  
-       limits_ = limits;
-}
-
-
-bool MathBigopInset::hasLimits() const
-{
-       return limits_ == 1 || (limits_ == 0 && size() == LM_ST_DISPLAY);
-}
-
-
-void MathBigopInset::Write(ostream & os, bool fragile) const
+void MathBigopInset::Write(ostream & os, bool /* fragile */) const
 {
        //bool f = sym_ != LM_int && sym_ != LM_oint && size() == LM_ST_DISPLAY;
        os << '\\' << name();
-       MathUpDownInset::Write(os, fragile);
 }
 
 
@@ -51,7 +32,7 @@ void MathBigopInset::WriteNormal(ostream & os) const
 }
 
 
-void MathBigopInset::Metrics(MathStyles st, int, int)
+void MathBigopInset::Metrics(MathStyles st)
 {
        //cerr << "\nBigopDraw\n";
        size(st);
@@ -65,50 +46,9 @@ void MathBigopInset::Metrics(MathStyles st, int, int)
                code_ = LM_TC_TEXTRM;
        }
 
-       int wid;
-       mathed_string_dim(code_, size(), ssym_, ascent_, descent_, wid);
+       mathed_string_dim(code_, size(), ssym_, ascent_, descent_, width_);
        if (sym_ == LM_oint)
-               wid += 2;
-       //cerr << "  asc: " << ascent_ << " des: " << descent_
-       //      << " wid: " << wid << "\n";
-       //cerr << "  hasLimits: " << hasLimits() << " up: "
-       //      << up() << " down: " << down() << "\n";
-       
-       width_ = wid;
-
-       if (hasLimits()) {
-               xcell(0).Metrics(st);
-               xcell(1).Metrics(st);
-               //cerr << "  0: ascent_: " << xcell(0).ascent() << " descent_: " <<
-               //      xcell(0).descent() << " width_: " << xcell(0).width() << "\n";
-               //cerr << "  1: ascent_: " << xcell(1).ascent() << " descent_: " <<
-               //      xcell(1).descent() << " width_: " << xcell(1).width() << "\n";
-               if (up()) {
-                       ascent_  += xcell(0).height() + 1;
-                       width_   = std::max(width_, xcell(0).width());
-                       dy0_     = - (ascent_ - xcell(0).ascent());
-               }
-               if (down()) {
-                       descent_ += xcell(1).height() + 1;
-                       width_   = std::max(width_, xcell(1).width());
-                       dy1_     = descent_ - xcell(1).descent();
-               }
-               dxx_  = (width_ - wid) / 2;
-               dx0_  = (width_ - xcell(0).width()) / 2;
-               dx1_  = (width_ - xcell(1).width()) / 2;
-               //cerr << "  ascent_: " << ascent_ << " descent_: "
-               //      << descent_ << " width_: " << width_ << "\n";
-               //cerr << "  dx0_: " << dx0_ << " dx1_: " << dx1_
-               //      << " dxx_: " << dxx_ << "\n";
-               //cerr << "  dy0_: " << dy0_ << " dy1_: " << dy1_
-               //      << "\n";
-       } else {
-               MathUpDownInset::Metrics(st, ascent_, descent_);
-               width_   += wid;
-               dx0_     = wid;
-               dx1_     = wid;
-               dxx_     = 0;
-       }
+               width_ += 2;
 }
 
 
@@ -117,12 +57,7 @@ void MathBigopInset::draw(Painter & pain, int x, int y)
        xo(x);
        yo(y);
 
-       drawStr(pain, code_, size_, x + dxx_, y, ssym_);
-
-       if (up())
-               xcell(0).draw(pain, x + dx0_, y + dy0_);
-       if (down())
-               xcell(1).draw(pain, x + dx1_, y + dy1_);
+       drawStr(pain, code_, size_, x, y, ssym_);
 
        if (sym_ == LM_oint) {
                int xx = x - 1;
@@ -130,5 +65,3 @@ void MathBigopInset::draw(Painter & pain, int x, int y)
                pain.arc(xx, yy, width_, width_, 0, 360 * 64, LColor::mathline);
        }
 }
-
-
index cf4f50ed57e1bb8ce3a64234bc311c4cd4b824c7..7c5675092096809cffaebcc072deaa8409e92462 100644 (file)
@@ -2,10 +2,10 @@
 #ifndef MATH_BIGOPINSET_H
 #define MATH_BIGOPINSET_H
 
-#include "math_updowninset.h"
+#include "math_inset.h"
 
 /// big operators
-class MathBigopInset : public MathUpDownInset {
+class MathBigopInset : public MathInset {
 public:
        ///
        MathBigopInset(string const &, int);
@@ -16,31 +16,17 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter &, int, int);
        ///
-       void limits(int);
-       ///
-       int limits() const;
-       /// Identifies BigopInsets
-       bool isBigopInset() const { return true; }
+       bool isScriptable() const { return true; }
 private:
-       ///
-       bool hasLimits() const;
        ///
        int sym_;
        ///
        string ssym_;
        ///
        MathTextCodes code_;
-       /// 1: \limits, -1: \nolimits, 0: use default
-       int limits_;
-       /// x offset for drawing the superscript
-       int dx0_;
-       /// x offset for drawing the subscript
-       int dx1_;
-       /// x offset for drawing the inner symbol
-       int dxx_;
 };
 #endif
index ca5852a3ca87b3fa169312d70a062fb38ba426ad..a3b77d5a2d6057c826c2aa500b1a7767dd5f1283 100644 (file)
@@ -115,8 +115,6 @@ struct Selection
                data_.clear();
        }
 
-       
-
        std::vector<MathArray> data_;
 };
 
@@ -124,20 +122,6 @@ struct Selection
 Selection theSelection;
 
 
-bool IsMacro(short tok, int id)
-{
-       return tok != LM_TK_STACK &&
-              tok != LM_TK_FRAC &&
-              tok != LM_TK_SQRT &&
-              tok != LM_TK_DECORATION &&
-              tok != LM_TK_SPACE &&
-              tok != LM_TK_DOTS &&
-              tok != LM_TK_FUNCLIM &&
-              tok != LM_TK_BIGSYM &&
-              !(tok == LM_TK_SYM && id < 255);
-}
-
-
 std::ostream & operator<<(std::ostream & os, MathCursorPos const & p)
 {
        os << "(par: " << p.par_ << " idx: " << p.idx_
@@ -229,7 +213,7 @@ bool MathCursor::openable(MathInset * p, bool sel, bool useupdown) const
 {
        if (!p)
                return false;
-       if (!(p->isActive() || (useupdown && p->isUpDownInset())))
+       if (!(p->isActive() || (useupdown && p->isScriptInset())))
                return false;
 
        if (sel) {
@@ -376,8 +360,7 @@ void MathCursor::SetPos(int x, int y)
 void MathCursor::Home()
 {
        dump("Home 1");
-       if (macro_mode)
-               MacroModeClose();
+       MacroModeClose();
        clearLastCode();
        if (!cursor().par_->idxHome(cursor().idx_, cursor().pos_)) 
                pop();
@@ -388,8 +371,7 @@ void MathCursor::Home()
 void MathCursor::End()
 {
        dump("End 1");
-       if (macro_mode)
-               MacroModeClose();
+       MacroModeClose();
        clearLastCode();
        if (!cursor().par_->idxEnd(cursor().idx_, cursor().pos_)) {
                pop();
@@ -399,6 +381,12 @@ void MathCursor::End()
 }
 
 
+void MathCursor::erase()
+{
+       array().erase(cursor().pos_);
+}
+
+
 void MathCursor::insert(char c, MathTextCodes t)
 {
        //lyxerr << "inserting '" << c << "'\n";
@@ -623,15 +611,22 @@ void MathCursor::SetSize(MathStyles size)
 
 void MathCursor::Interpret(string const & s)
 {
-       lyxerr << "Interpret: '" << s << "'  ('" << s.substr(0, 7)  << "' " <<
-in_word_set(s) << " \n";
+       //lyxerr << "Interpret: '" << s << "'\n";
+       //lyxerr << "in: " << in_word_set(s) << " \n";
 
-       if (s[0] == '^' || s[0] == '_') {
+       if (s.size() && (s[0] == '^' || s[0] == '_')) {
                bool const up = (s[0] == '^');
                SelCut();       
-               MathUpDownInset * p = prevUpDownInset();
+               MathScriptInset * p = prevScriptInset();
                if (!p) {
-                       p = new MathScriptInset(up, !up);
+                       MathInset * b = prevInset();
+                       if (b && b->isScriptable()) {
+                               p = new MathScriptInset(up, !up, b->clone());
+                               plainLeft();
+                               erase();
+                       } else {
+                               p = new MathScriptInset(up, !up);
+                       }
                        insert(p);
                        plainLeft();
                }
@@ -680,8 +675,8 @@ in_word_set(s) << " \n";
        } else {
                switch (l->token) {
                        case LM_TK_BIGSYM: 
-                                       p = new MathBigopInset(l->name, l->id);
-                                       break;
+                               p = new MathBigopInset(s, l->id);
+                               break;
                                
                        case LM_TK_SYM: {
                                MathTextCodes code = static_cast<MathTextCodes>(l->id);
@@ -760,27 +755,14 @@ void MathCursor::MacroModeOpen()
 
 void MathCursor::MacroModeClose()
 {
-       if (macro_mode)  {
+       if (macro_mode) {
+               string name = imacro->name();
+               plainLeft();
+               erase();
+               delete imacro;
                macro_mode = false;
-               latexkeys const * l = in_word_set(imacro->name());
-               if (!imacro->name().empty()
-                               && (!l || (l && IsMacro(l->token, l->id)))
-                               && !MathMacroTable::hasTemplate(imacro->name()))
-               {
-                       if (!l) {
-                               //imacro->SetName(macrobf);
-                               // This guarantees that the string will be removed by destructor
-                               imacro->SetType(LM_OT_UNDEF);
-                       } else
-                               imacro->SetName(l->name);
-               } else {
-                       Left();
-                       array().erase(cursor().pos_);
-                       if (l || MathMacroTable::hasTemplate(imacro->name())) 
-                               Interpret(imacro->name());
-                       imacro->SetName(string());
-               }
                imacro = 0;
+               Interpret(name);
        }
 }
 
@@ -1095,11 +1077,11 @@ MathInset * MathCursor::nextInset() const
 }
 
 
-MathUpDownInset * MathCursor::prevUpDownInset() const
+MathScriptInset * MathCursor::prevScriptInset() const
 {
        normalize();
        MathInset * p = array().prevInset(cursor().pos_);
-       return (p && p->isUpDownInset()) ? static_cast<MathUpDownInset *>(p) : 0;
+       return (p && p->isScriptInset()) ? static_cast<MathScriptInset *>(p) : 0;
 }
 
 
index 769143eb0561d4d601f7b3267b8a2cfaa1402d8a..766cc1c26d3ff2825990e0f4dbd4abf93d8ae11b 100644 (file)
@@ -25,7 +25,7 @@
 
 class MathInset;
 class MathFuncInset;
-class MathUpDownInset;
+class MathScriptInset;
 class MathSpaceInset;
 class InsetFormulaBase;
 class MathArray;
@@ -76,6 +76,8 @@ public:
        ///
        void insert(MathArray const &);
        ///
+       void erase();
+       ///
        void Home();
        ///
        void End();
@@ -259,7 +261,7 @@ public:
        ///
        MathInset * prevInset() const;
        ///
-       MathUpDownInset * prevUpDownInset() const;
+       MathScriptInset * prevScriptInset() const;
        ///
        MathSpaceInset * prevSpaceInset() const;
 
index fb3ae4009c10005c18a01c705ad6ec8fa38b4d34..43153ee93c160774a15f2230943cefb1b5fef2a3 100644 (file)
@@ -25,7 +25,7 @@ MathInset * MathDecorationInset::clone() const
 
 
 
-void MathDecorationInset::Metrics(MathStyles st, int, int)
+void MathDecorationInset::Metrics(MathStyles st)
 {
        xcell(0).Metrics(st);
        size_    = st;
index 94c368b24a5d90fdb21c0d431fd7d6c475d94a98..da247eb4cd192cc50c21b66a251ce5190378e21f 100644 (file)
@@ -22,7 +22,7 @@ public:
        ///
        void Write(std::ostream &, bool fragile) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void WriteNormal(std::ostream & os) const;
 private:
index 1ee6475ddbffc05cd5f6ca88834eb6b6f92d218c..6c530180cc8daf5c2df180f6ad3227dd1999621c 100644 (file)
@@ -86,7 +86,7 @@ int MathDelimInset::dw() const
 }
 
 
-void MathDelimInset::Metrics(MathStyles st, int, int)
+void MathDelimInset::Metrics(MathStyles st)
 {
        xcell(0).Metrics(st);
        size_    = st;
index cd25fe6f1b94e4d896ecca827d51bb68468352fa..8ab72b17d145c2c78f53dbd6cbbad093cd6b91c5 100644 (file)
@@ -22,7 +22,7 @@ public:
        ///
        void Write(std::ostream &, bool fragile) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
 private:
        int dw() const;
        ///
index 7054cde4bf2bf0e2a41a090294673a52cbbfd9cf..f29b3a52f79f689ec7d063457708525fd6406f88 100644 (file)
@@ -31,7 +31,7 @@ void MathDotsInset::draw(Painter & pain, int x, int y)
 }
 
 
-void MathDotsInset::Metrics(MathStyles st, int, int)
+void MathDotsInset::Metrics(MathStyles st)
 {
        size(st);
        mathed_char_dim(LM_TC_VAR, size(), 'M', ascent_, descent_, width_);
index d6d973a820a43861e23ddf7d387bd97bd4349cb0..7f1b29e276c8bebfb9ca40393c6210beb3691a75 100644 (file)
@@ -23,7 +23,7 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
 protected:
        ///
        int dh_;
index 576f98c4e877fe15f8d0dd30dff23a3f63425bbb..1bb6b902c49cc35ca7274f8aebcba90f6096f58e 100644 (file)
@@ -19,7 +19,7 @@ MathInset * MathFracInset::clone() const
 }
 
 
-void MathFracInset::Metrics(MathStyles st, int, int)
+void MathFracInset::Metrics(MathStyles st)
 {
        size_    = smallerStyleFrac(st);
        xcell(0).Metrics(size_);
index 10da11aae86e044150701de50ae86a8a893a9848..4a3e7ab8e841b24e51f9fd2d84c08ac7c4ad1a4f 100644 (file)
@@ -22,7 +22,7 @@ public:
        ///
        virtual void WriteNormal(std::ostream &) const;
        ///
-       virtual void Metrics(MathStyles st, int asc = 0, int des = 0);
+       virtual void Metrics(MathStyles st);
        ///
        virtual void draw(Painter &, int x, int baseline);
        ///
index a75ba7360cc7efe63629e5f3039766d9340e08d2..933b0f344695dfed8de428688a410abb7329b86b 100644 (file)
@@ -39,7 +39,7 @@ void MathFuncInset::WriteNormal(std::ostream & os) const
 }
 
 
-void MathFuncInset::Metrics(MathStyles st, int, int
+void MathFuncInset::Metrics(MathStyles st) 
 {
        size_ = st;
        if (name_.empty()) 
index 9b386b274ddde6a2457a261eeaf9e2f393d2fd42..5c7dcf0c1e817a625ec8919256548ec3c5daa810 100644 (file)
@@ -25,7 +25,7 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
 private:
        ///
        bool lims_;
index 5b4afb14e29b0cfc72abb8c604814713e696d0f0..bfd69f770a6bd112a724d533b7939310c26179dc 100644 (file)
@@ -74,7 +74,7 @@ char MathGridInset::valign() const
        return v_align_;
 }
 
-void MathGridInset::Metrics(MathStyles st, int, int)
+void MathGridInset::Metrics(MathStyles st)
 {
        // let the cells adjust themselves
        MathInset::Metrics(st);
index cb58ebfd2d8687a10f7b209ab3d9b66c11705602..027433705ea4b3e1423bca6088bc11e0736c76a7 100644 (file)
@@ -58,7 +58,7 @@ public:
        ///
        void Write(std::ostream &, bool fragile) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter &, int, int);
        ///
index 51b70065cb0610572b518c7986b5be0848aab71d..693cfaffbaaabff63db2dc9b0e10b71713488e6e 100644 (file)
@@ -82,7 +82,7 @@ latexkeys const wordlist[] =
        {"widehat",  LM_TK_DECORATION, LM_widehat},
        {"sin",  LM_TK_FUNC, 0},
        {"asymp",  LM_TK_SYM, LM_asymp},
-       {"nolimits",  LM_TK_LIMIT, },
+       {"nolimits",  LM_TK_LIMIT, -1},
        {"perp",  LM_TK_MACRO, LM_perp},
        {"wedge",  LM_TK_SYM, LM_wedge},
        {"ln",  LM_TK_FUNC, 0},
index bbbf107db2ec3ef327905660ab5200aec7d9adba..b5980fc019530eeea4bbb7a63ff6fdc26233793b 100644 (file)
@@ -170,7 +170,7 @@ void MathInset::substitute(MathArray & array, MathMacro const & m) const
        array.push_back(p);
 }
 
-void MathInset::Metrics(MathStyles st, int, int)
+void MathInset::Metrics(MathStyles st)
 {
        size_ = st;
        for (int i = 0; i < nargs(); ++i)
index b5ad07d7d14c0bd3b7877827ff98b52915c765b1..d2919dcb43465b9bc1f550d6ec53e3111841c2d9 100644 (file)
@@ -64,7 +64,7 @@ public:
        /// Appends itself with macro arguments substituted
        virtual void substitute(MathArray & array, MathMacro const & macro) const;
        /// Compute the size of the object
-       virtual void Metrics(MathStyles st, int = 0, int = 0) = 0;
+       virtual void Metrics(MathStyles st) = 0;
        /// 
        virtual int ascent() const;
        ///
@@ -178,10 +178,10 @@ public:
        void GetXY(int & x, int & y) const;
        ///
        bool covers(int x, int y) const;
+       /// Identifies things that can get scripts
+       virtual bool isScriptable() const { return false; }
        /// Identifies ScriptInsets
-       virtual bool isUpDownInset() const { return false; }
-       /// Identifies BigopInsets
-       virtual bool isBigopInset() const { return false; }
+       virtual bool isScriptInset() const { return false; }
        /// Identifies SpaceInsets
        virtual bool isSpaceInset() const { return false; }
        ///
index 5085e783bf864957aff6bea102d2e7df514b0865..143b547cdaafe011652531668d852e58e951ac05 100644 (file)
@@ -49,7 +49,7 @@ MathInset * MathMacro::clone() const
 }
 
 
-void MathMacro::Metrics(MathStyles st, int, int)
+void MathMacro::Metrics(MathStyles st)
 {
        if (mathcursor && mathcursor->isInside(this)) {
                expanded_ = tmplate_->xcell(0);
index f40f3df82905160247fc2608802b40bd47af02ed..a820b708aa5389eff2a3d6a0b855bd0f5f31058d 100644 (file)
@@ -43,7 +43,7 @@ public:
        ///
        void draw(Painter &, int, int);
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        MathInset * clone() const;
        ///
index c64f750c77dab189abf72ca85c5f4da5a6715cdb..325cf2010c105caab8d546cb23b2ec86c8240f36 100644 (file)
@@ -34,7 +34,7 @@ void MathMacroArgument::draw(Painter & pain, int x, int y)
 }
 
 
-void MathMacroArgument::Metrics(MathStyles st, int, int)
+void MathMacroArgument::Metrics(MathStyles st)
 {
        char str[] = "#0";
        str[1] += number_; 
index f089bf3c9e2da5ea2e6a4c4a453269e2cb0573aa..594b7100e4ef3b70d3f79e26c89896794b832816 100644 (file)
@@ -18,7 +18,7 @@ public:
        ///
        MathInset * clone() const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter &, int x, int baseline);
        ///
index ba994c14b9e8bc51785085617deadd10213ee8f5..6d64a524c6651073359bc6eb27f05dc1a71c9749 100644 (file)
@@ -49,7 +49,7 @@ void MathMacroTemplate::Write(std::ostream & os, bool fragile) const
 }
 
 
-void MathMacroTemplate::Metrics(MathStyles st, int, int)
+void MathMacroTemplate::Metrics(MathStyles st)
 {
        xcell(0).Metrics(st);
        size_    = st;
index 64283ab14c802e281a3e161d776a58b649a926a5..c1cc9eb94c2da964762055ae13d8a7773ff11b1d 100644 (file)
@@ -32,7 +32,7 @@ public:
        ///
        void draw(Painter &, int, int);
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
 private:
        ///
        int numargs_;
index d552e20242c35a77f4e4c3fce6a0f920abb728e7..042c4f23f7c09341ce68f11a7b8a03d86bb494ba 100644 (file)
@@ -92,7 +92,7 @@ MathInset * MathMatrixInset::clone() const
 }
 
 
-void MathMatrixInset::Metrics(MathStyles /* st */, int, int)
+void MathMatrixInset::Metrics(MathStyles /* st */)
 {
        size_ = (GetType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY;
 
index 950caa9e174a5ffed8f5da39f15a0cb3467c2751..ed37ec3eec308b7912b4ff8447c2c0a233aaef72 100644 (file)
@@ -27,7 +27,7 @@ public:
        ///
        void Write(std::ostream &, bool fragile) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter &, int, int);
        ///
index 863346232d568f9c3700b9004101d92de39da019..e9b96cef8b2384547bf8ad7567913c27832fe2a3 100644 (file)
@@ -339,29 +339,37 @@ int yylex()
 }
 
 
-MathInset * lastUpDownInset(MathArray & array, bool up, bool down)
+
+MathScriptInset * prevScriptInset(MathArray const & array)
 {
        MathInset * p = array.back_inset();
-       if (!p || !p->isUpDownInset()) {
-               p = new MathScriptInset(up, down);
+       return (p && p->isScriptInset()) ? static_cast<MathScriptInset *>(p) : 0;
+}
+
+
+MathInset * lastScriptInset(MathArray & array, bool up, bool down, int limits)
+{
+       MathScriptInset * p = prevScriptInset(array);
+       if (!p) {
+               MathInset * b = array.back_inset();
+               if (b && b->isScriptable()) {
+                       p = new MathScriptInset(up, down, b->clone());
+                       array.pop_back();       
+               } else {
+                       p = new MathScriptInset(up, down);
+               }
                array.push_back(p);
        }
-       MathUpDownInset * q = static_cast<MathScriptInset *>(p);
        if (up)
-               q->up(true);
+               p->up(true);
        if (down)
-               q->down(down);
+               p->down(down);
+       if (limits)
+               p->limits(limits);
        return p;
 }
 
 
-MathBigopInset * lastBigopInset(MathArray & array)
-{
-       MathInset * p = array.back_inset();
-       return (p && p->isBigopInset()) ? static_cast<MathBigopInset *>(p) : 0;
-}
-
-
 
 static bool   curr_num;
 static string curr_label;
@@ -499,11 +507,14 @@ void mathed_parse(MathArray & array, unsigned flags)
        static int plevel = -1;
        yyvarcode = LM_TC_VAR;
        
-       int brace = 0;
+       int brace  = 0;
+       int limits = 0;
 
        ++plevel;
        while (t) {
-               //lyxerr << "t: " << t << " flags: " << flags << " i: " << yylval.i << " "
+               //lyxerr << "t: " << t << " flags: " << flags << " i: " << yylval.i
+               //      << " TK_LIMIT " << LM_TK_LIMIT << "\n";
+                               
                //      << " plevel: " << plevel << " ";
                //array.dump(lyxerr);
                //lyxerr << "\n";
@@ -585,48 +596,46 @@ void mathed_parse(MathArray & array, unsigned flags)
                        break;
                
                case '^':
-                       mathed_parse(lastUpDownInset(array, true, false)->cell(0), FLAG_ITEM);
+                       mathed_parse(
+                               lastScriptInset(array, true, false, limits)->cell(0), FLAG_ITEM);
                        break;
                
                case '_':
-                       mathed_parse(lastUpDownInset(array, false, true)->cell(1), FLAG_ITEM);
+                       mathed_parse(
+                               lastScriptInset(array, false, true, limits)->cell(1), FLAG_ITEM);
                        break;
                
                case LM_TK_LIMIT:
-               {
-                       MathBigopInset * p = lastBigopInset(array);
-                       if (p) 
-                               p->limits(yylval.l->id ? 1 : -1);
+                       limits = yylval.l->id;
+                       //lyxerr << "setting limit to " << limits << "\n";
                        break;
-               }
                
                case '&':
-               {
                        if (flags & FLAG_AMPERSAND) {
                                flags &= ~FLAG_AMPERSAND;
                                --plevel;
                                return;
                        }
-                       lyxerr[Debug::MATHED] << "found tab unexpectedly, array: '" << array << "'\n";
+                       lyxerr[Debug::MATHED]
+                               << "found tab unexpectedly, array: '" << array << "'\n";
                        break;
-               }
                
                case LM_TK_NEWLINE:
-               {
                        if (flags & FLAG_NEWLINE) {
                                flags &= ~FLAG_NEWLINE;
                                --plevel;
                                return;
                        }
-                       lyxerr[Debug::MATHED] << "found newline unexpectedly, array: '" << array << "'\n";
+                       lyxerr[Debug::MATHED]
+                               << "found newline unexpectedly, array: '" << array << "'\n";
                        break;
-               }
                
                case LM_TK_BIGSYM:  
-               {
+                       //lyxerr << "clearing limits " << limits << "\n";
+                       limits = 0;
+                       //lyxerr << "found bigop '" << yylval.l->name << "'\n";
                        array.push_back(new MathBigopInset(yylval.l->name, yylval.l->id));
                        break;
-               }
                
                case LM_TK_SYM:
                        if (yylval.l->id < 256) {
index 427af7150e928bf8539bf09afd5d1a0d01317a27..4e6be68cf3927b0c760ae5d91079e56bec27ed59 100644 (file)
@@ -30,7 +30,7 @@ MathInset * MathRootInset::clone() const
 }
 
 
-void MathRootInset::Metrics(MathStyles st, int, int)
+void MathRootInset::Metrics(MathStyles st)
 {
        MathInset::Metrics(st);
        size_    = st;
index cae5cfb93ac622136cf2a8ead6e0b4c7cc3cdf82..1b1fb2e360b2ea048ba80b0f6f7a911fc5800383 100644 (file)
@@ -39,7 +39,7 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        bool idxUp(int & idx, int & pos) const;
        ///
index 09e52cccf0e6fbdda0c4543f7526eb30eb316dfe..5157182f8ad881bf4a55c901431d6943f669198f 100644 (file)
 #include "support/LOstream.h"
 
 
-MathScriptInset::MathScriptInset(bool up, bool down)
-       : MathUpDownInset(up, down)
+MathScriptInset::MathScriptInset()
+       : MathInset(2), up_(false), down_(false), limits_(0), symbol_(0)
 {}
 
 
+MathScriptInset::MathScriptInset(bool up, bool down, MathInset * symbol)
+       : MathInset(2), up_(up), down_(down), limits_(0), symbol_(symbol)
+{}
+
+
+MathScriptInset::MathScriptInset(MathScriptInset const & p)
+       : MathInset(p), up_(p.up_), down_(p.down_),
+               limits_(p.limits_), symbol_(p.symbol_ ? p.symbol_->clone() : 0)
+{}
+
+
+MathScriptInset::~MathScriptInset()
+{
+       delete symbol_;
+}
+
+
 MathInset * MathScriptInset::clone() const
 {   
        return new MathScriptInset(*this);
 }
 
 
-void MathScriptInset::WriteNormal(std::ostream & os) const
+bool MathScriptInset::up() const
+{
+       return up_;
+}
+
+
+bool MathScriptInset::down() const
+{
+       return down_;
+}
+
+
+void MathScriptInset::up(bool b)
+{
+       up_ = b;
+}
+
+
+void MathScriptInset::down(bool b)
+{
+       down_ = b;
+}
+
+
+bool MathScriptInset::idxRight(int &, int &) const
 {
+       return false;
+}
+
+
+bool MathScriptInset::idxLeft(int &, int &) const
+{
+       return false;
+}
+
+
+bool MathScriptInset::idxUp(int & idx, int & pos) const
+{
+       if (idx == 0 || !up()) 
+               return false;
+       idx = 0;
+       pos = 0;
+       return true;
+}
+
+bool MathScriptInset::idxDown(int & idx, int & pos) const
+{
+       if (idx == 1 || !down()) 
+               return false;
+       idx = 1;
+       pos = 0;
+       return true;
+}
+
+bool MathScriptInset::idxFirst(int & idx, int & pos) const
+{
+       idx = up() ? 0 : 1;
+       pos = 0;
+       return true;
+}
+
+bool MathScriptInset::idxLast(int & idx, int & pos) const
+{
+       idx = down() ? 1 : 0;
+       pos = cell(idx).size();
+       return true;
+}
+
+
+bool MathScriptInset::idxFirstUp(int & idx, int & pos) const
+{
+       if (!up()) 
+               return false;
+       idx = 0;
+       pos = 0;
+       return true;
+}
+
+
+bool MathScriptInset::idxFirstDown(int & idx, int & pos) const
+{
+       if (!down()) 
+               return false;
+       idx = 1;
+       pos = 0;
+       return true;
+}
+
+
+bool MathScriptInset::idxLastUp(int & idx, int & pos) const
+{
+       if (!up()) 
+               return false;
+       idx = 0;
+       pos = cell(idx).size();
+       return true;
+}
+
+
+bool MathScriptInset::idxLastDown(int & idx, int & pos) const
+{
+       if (!down()) 
+               return false;
+       idx = 1;
+       pos = cell(idx).size();
+       return true;
+}
+
+
+void MathScriptInset::Write(std::ostream & os, bool fragile) const
+{
+       if (symbol_) {
+               symbol_->Write(os, fragile);
+               if (limits())
+                       os << (limits() == 1 ? "\\limits" : "\\nolimits");
+       }
        if (up()) {
-               os << "[superscript ";
-               cell(0).WriteNormal(os);
-               os << "";
+               os << "^{";
+               cell(0).Write(os, fragile);
+               os << "}";
        }
        if (down()) {
-               os << "[subscript ";
-               cell(1).WriteNormal(os);
-               os << "";
+               os << "_{";
+               cell(1).Write(os, fragile);
+               os << "}";
        }
+       os << " ";
 }
 
 
@@ -41,3 +173,103 @@ void MathScriptInset::idxDelete(int & idx, bool & popit, bool & deleteit)
        popit = true;
        deleteit = !(up() || down());
 }
+
+
+int MathScriptInset::limits() const
+{  
+       return limits_;
+}
+
+
+void MathScriptInset::limits(int limits) 
+{  
+       limits_ = limits;
+}
+
+
+bool MathScriptInset::hasLimits() const
+{
+       return
+               symbol_ && (limits_ == 1 || (limits_ == 0 && size() == LM_ST_DISPLAY));
+}
+
+
+void MathScriptInset::WriteNormal(std::ostream & os) const
+{
+       if (limits() && symbol_) 
+               os << "[" << (limits() ? "limits" : "nolimits") << "]";
+       if (up()) {
+               os << "[superscript ";
+               cell(0).WriteNormal(os);
+               os << "] ";
+       }
+       if (down()) {
+               os << "[subscript ";
+               cell(1).WriteNormal(os);
+               os << "] ";
+       }
+}
+
+
+void MathScriptInset::Metrics(MathStyles st)
+{
+       size_ = st;
+       MathStyles tt = smallerStyleScript(st);
+       
+       xcell(0).Metrics(tt);
+       xcell(1).Metrics(tt);
+
+       width_   = std::max(xcell(0).width(), xcell(1).width());
+
+       if (hasLimits()) {
+               symbol_->Metrics(st);
+               int wid  = symbol_->width();
+               ascent_  = symbol_->ascent();
+               descent_ = symbol_->descent();
+               width_   = std::max(width_, wid);
+               if (up()) {
+                       ascent_  += xcell(0).height() + 2;
+                       dy0_     = - (ascent_ - xcell(0).ascent());
+               }
+               if (down()) {
+                       descent_ += xcell(1).height() + 2;
+                       dy1_     = descent_ - xcell(1).descent();
+               }
+               dxx_   = (width_ - wid) / 2;
+               dx0_   = (width_ - xcell(0).width()) / 2;
+               dx1_   = (width_ - xcell(1).width()) / 2;
+       } else {
+               int asc;
+               int des;
+               int wid = 0;
+               mathed_char_height(LM_TC_VAR, st, 'I', asc, des);
+               if (symbol_) {
+                       symbol_->Metrics(st);
+                       wid  = symbol_->width();
+                       asc  = symbol_->ascent();
+                       des = symbol_->descent();
+               }
+               ascent_  = up()   ? xcell(0).height() + asc : 0;
+               descent_ = down() ? xcell(1).height() + des : 0;
+               width_  += wid;
+               dy0_     = - asc - xcell(0).descent();
+               dy1_     =   des + xcell(1).ascent();
+               dx0_     = wid;
+               dx1_     = wid;
+               dxx_     = 0;
+       }
+}
+
+
+void MathScriptInset::draw(Painter & pain, int x, int y)
+{  
+       xo(x);
+       yo(y);
+
+       if (symbol_)
+               symbol_->draw(pain, x + dxx_, y);
+       if (up())
+               xcell(0).draw(pain, x + dx0_, y + dy0_);
+       if (down())
+               xcell(1).draw(pain, x + dx1_, y + dy1_);
+}
index 7f589e953b67d38ed5b4f140aa41bcee872cf915..359db5ee3452d317125d2ea83b2769a652e6850c 100644 (file)
@@ -2,7 +2,7 @@
 #ifndef MATH_SCRIPTINSET_H
 #define MATH_SCRIPTINSET_H
 
-#include "math_updowninset.h"
+#include "math_inset.h"
 
 #ifdef __GNUG__
 #pragma interface
     \author André Pönitz
  */
 
-class MathScriptInset : public MathUpDownInset {
+
+class MathScriptInset : public MathInset {
 public:
        ///
-       MathScriptInset(bool up, bool down);
+       MathScriptInset();
+       ///
+       MathScriptInset(bool up, bool down, MathInset * = 0);
+       ///
+       MathScriptInset(MathScriptInset const &);
+       ///
+       ~MathScriptInset();
        ///
        MathInset * clone() const;
        ///
+       void Write(std::ostream &, bool fragile) const;
+       ///
        void WriteNormal(std::ostream &) const;
-       /// Identifies ScriptInsets
-       bool isUpDownInset() const { return true; }
+       ///
+       void Metrics(MathStyles st);
+       ///
+       void draw(Painter &, int x, int baseline);
+
+       ///
+       bool idxUp(int & idx, int & pos) const;
+       ///
+       bool idxDown(int & idx, int & pos) const;
+       ///
+       bool idxLeft(int & idx, int & pos) const;
+       ///
+       bool idxRight(int & idx, int & pos) const;
+       ///
+       bool idxFirst(int & idx, int & pos) const;
+       ///
+       bool idxFirstUp(int & idx, int & pos) const;
+       ///
+       bool idxFirstDown(int & idx, int & pos) const;
+       ///
+       bool idxLast(int & idx, int & pos) const;
+       ///
+       bool idxLastUp(int & idx, int & pos) const;
+       ///
+       bool idxLastDown(int & idx, int & pos) const;
        ///
        void idxDelete(int & idx, bool & popit, bool & deleteit);
+
+       ///
+       bool up() const;
+       ///
+       bool down() const;
+       ///
+       void up(bool);
+       ///
+       void down(bool);
+       ///
+       void limits(int);
+       ///
+       int limits() const;
+       ///
+       bool isActive() const { return false; }
+       /// Identifies ScriptInsets
+       bool isScriptInset() const { return true; }
+       ///
+       int xoffset() const { return dxx_; }
+private:
+       ///
+       bool hasLimits() const;
+       ///
+       bool up_;
+       ///
+       bool down_;
+       ///
+       string ssym_;
+       /// 1: \limits, -1: \nolimits, 0: use default
+       int limits_;
+       /// x offset for drawing the superscript
+       int dx0_;
+       /// x offset for drawing the subscript
+       int dx1_;
+       /// x offset for drawing the inner symbol
+       int dxx_;
+       ///
+       int dy0_;
+       ///
+       int dy1_;
+       ///
+       MathInset * symbol_;
 };
 
 #endif
index 124f03bce35f214624c283107ba994f998ce7cc8..83cbf6e64f4bd5847402ac85a108fa69bc2d0985 100644 (file)
@@ -43,7 +43,7 @@ void MathSizeInset::draw(Painter & pain, int x, int y)
 }
 
 
-void MathSizeInset::Metrics(MathStyles /* st */, int, int)
+void MathSizeInset::Metrics(MathStyles /* st */)
 {
        xcell(0).Metrics(style_);
        ascent_   = xcell(0).ascent_;
index d581be7320276db1adbc6a9b1c20f1393a68914e..98d209e5e161f4d347582d8f803d4122df900be3 100644 (file)
@@ -20,7 +20,7 @@ public:
        ///
        virtual MathInset * clone() const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter &, int x, int baseline);
        ///
index 8f9d99982554dbd9e4599fe35f0400405b293f8f..231f4c8b1c29aaafcfecbb9850ece68b3d23ffd8 100644 (file)
@@ -51,7 +51,7 @@ void MathSpaceInset::WriteNormal(std::ostream & os) const
 }
 
 
-void MathSpaceInset::Metrics(MathStyles st, int, int)
+void MathSpaceInset::Metrics(MathStyles st)
 {
        size_  = st;
        width_ = space_ ? space_ * 2 : 2;
index df88004c9aecb6eb66e903d1e2a3abfb781814d1..8edbdc198377745cac0c8803a0572eb1d94e1b17 100644 (file)
@@ -23,7 +23,7 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        bool isSpaceInset() const { return true; }
        ///
index 6ad124ef0fd97bd4126ec72c48e14f83b0869f33..f9097d9c9103bc4a2fae2a2d072e2739ec9fe78e 100644 (file)
@@ -19,7 +19,7 @@ MathInset * MathSqrtInset::clone() const
 }
 
 
-void MathSqrtInset::Metrics(MathStyles st, int, int)
+void MathSqrtInset::Metrics(MathStyles st)
 {
        xcell(0).Metrics(st);
        size_    = st;
index e3e153de39c82e81a702e2e8e73ab5e81c85699f..18019df49def899c25f0d99e49e0fbd113d7b2a7 100644 (file)
@@ -24,6 +24,6 @@ public:
        ///
        void WriteNormal(std::ostream &) const;
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
 };
 #endif
diff --git a/src/mathed/math_updowninset.C b/src/mathed/math_updowninset.C
deleted file mode 100644 (file)
index 77c2117..0000000
+++ /dev/null
@@ -1,179 +0,0 @@
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-#include "math_updowninset.h"
-#include "support/LOstream.h"
-
-
-MathUpDownInset::MathUpDownInset()
-       : MathInset(2), up_(false), down_(false)
-{}
-
-MathUpDownInset::MathUpDownInset(bool up, bool down)
-       : MathInset(2), up_(up), down_(down)
-{}
-
-
-MathInset * MathUpDownInset::clone() const
-{   
-       return new MathUpDownInset(*this);
-}
-
-
-bool MathUpDownInset::up() const
-{
-       return up_;
-}
-
-bool MathUpDownInset::down() const
-{
-       return down_;
-}
-
-void MathUpDownInset::up(bool b)
-{
-       up_ = b;
-}
-
-void MathUpDownInset::down(bool b)
-{
-       down_ = b;
-}
-
-
-bool MathUpDownInset::idxRight(int &, int &) const
-{
-       return false;
-}
-
-bool MathUpDownInset::idxLeft(int &, int &) const
-{
-       return false;
-}
-
-
-bool MathUpDownInset::idxUp(int & idx, int & pos) const
-{
-       if (idx == 0 || !up()) 
-               return false;
-       idx = 0;
-       pos = 0;
-       return true;
-}
-
-bool MathUpDownInset::idxDown(int & idx, int & pos) const
-{
-       if (idx == 1 || !down()) 
-               return false;
-       idx = 1;
-       pos = 0;
-       return true;
-}
-
-bool MathUpDownInset::idxFirst(int & idx, int & pos) const
-{
-       idx = up() ? 0 : 1;
-       pos = 0;
-       return true;
-}
-
-bool MathUpDownInset::idxLast(int & idx, int & pos) const
-{
-       idx = down() ? 1 : 0;
-       pos = cell(idx).size();
-       return true;
-}
-
-
-bool MathUpDownInset::idxFirstUp(int & idx, int & pos) const
-{
-       if (!up()) 
-               return false;
-       idx = 0;
-       pos = 0;
-       return true;
-}
-
-bool MathUpDownInset::idxFirstDown(int & idx, int & pos) const
-{
-       if (!down()) 
-               return false;
-       idx = 1;
-       pos = 0;
-       return true;
-}
-
-bool MathUpDownInset::idxLastUp(int & idx, int & pos) const
-{
-       if (!up()) 
-               return false;
-       idx = 0;
-       pos = cell(idx).size();
-       return true;
-}
-
-bool MathUpDownInset::idxLastDown(int & idx, int & pos) const
-{
-       if (!down()) 
-               return false;
-       idx = 1;
-       pos = cell(idx).size();
-       return true;
-}
-
-
-void MathUpDownInset::idxDelete(int & idx, bool & popit, bool & deleteit)
-{
-       if (idx == 0) 
-               up(false);
-       else
-               down(false);
-       popit = true;
-       deleteit = !(up() || down());
-}
-
-void MathUpDownInset::Write(std::ostream & os, bool fragile) const
-{
-       if (up()) {
-               os << "^{";
-               cell(0).Write(os, fragile);
-               os << "}";
-       }
-       if (down()) {
-               os << "_{";
-               cell(1).Write(os, fragile);
-               os << "}";
-       }
-}
-
-void MathUpDownInset::Metrics(MathStyles st, int asc, int des)
-{
-       size_ = st;
-       MathStyles tt = smallerStyleScript(st);
-       
-       if (up())
-               xcell(0).Metrics(tt);
-       if (down())
-               xcell(1).Metrics(tt);
-
-       // we assume that asc, des, wid are the metrics of the item in front
-       // of this MathScriptInset
-       width_   = std::max(xcell(0).width(), xcell(1).width());
-       ascent_  = up()   ? xcell(0).height() + asc : 0;
-       descent_ = down() ? xcell(1).height() + des : 0;
-       dy0_     = - asc  - xcell(0).descent();
-       dy1_     =   des + xcell(1).ascent();
-}
-
-
-void MathUpDownInset::draw(Painter & pain, int x, int y)
-{ 
-       xo(x);
-       yo(y);
-       if (up())
-               xcell(0).draw(pain, x, y + dy0_);
-       if (down())
-               xcell(1).draw(pain, x, y + dy1_);
-}
-
diff --git a/src/mathed/math_updowninset.h b/src/mathed/math_updowninset.h
deleted file mode 100644 (file)
index 325f068..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-// -*- C++ -*-
-#ifndef MATH_UPDOWNINSET_H
-#define MATH_UPDOWNINSET_H
-
-#include "math_inset.h"
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-/** Abstract base class for super- and subscripts and mathop inset
-    \author André Pönitz
- */
-
-class MathUpDownInset : public MathInset {
-public:
-       ///
-       MathUpDownInset();
-       ///
-       MathUpDownInset(bool up, bool down);
-       ///
-       MathInset * clone() const;
-       ///
-       void Write(std::ostream &, bool fragile) const;
-       ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
-       ///
-       void draw(Painter &, int x, int baseline);
-       ///
-       bool idxUp(int & idx, int & pos) const;
-       ///
-       bool idxDown(int & idx, int & pos) const;
-       ///
-       bool idxLeft(int & idx, int & pos) const;
-       ///
-       bool idxRight(int & idx, int & pos) const;
-       ///
-       bool idxFirst(int & idx, int & pos) const;
-       ///
-       bool idxFirstUp(int & idx, int & pos) const;
-       ///
-       bool idxFirstDown(int & idx, int & pos) const;
-       ///
-       bool idxLast(int & idx, int & pos) const;
-       ///
-       bool idxLastUp(int & idx, int & pos) const;
-       ///
-       bool idxLastDown(int & idx, int & pos) const;
-       ///
-       bool up() const;
-       ///
-       bool down() const;
-       ///
-       void up(bool);
-       ///
-       void down(bool);
-       ///
-       bool isActive() const { return false; }
-       /// Identifies ScriptInsets
-       bool isUpDownInset() const { return true; }
-       ///
-       void idxDelete(int & idx, bool & popit, bool & deleteit);
-private:
-       ///
-       bool up_;
-       ///
-       bool down_;
-protected:
-       ///
-       int dy0_;
-       ///
-       int dy1_;
-};
-
-#endif
index 269bfafefaa8c33474a020fab0c3cf1a72566bbd..e05d3167e24bcba0be7f00f80ffd625177e279ed 100644 (file)
@@ -19,7 +19,7 @@ MathXArray::MathXArray()
 {}
 
 
-void MathXArray::Metrics(MathStyles st, int, int)
+void MathXArray::Metrics(MathStyles st)
 {
        if (data_.empty()) {
                mathed_char_dim(LM_TC_VAR, st, 'I', ascent_, descent_, width_); 
@@ -31,17 +31,13 @@ void MathXArray::Metrics(MathStyles st, int, int)
        width_   = 0;
        style_    = st;
 
-       // keep last values for scriptInset's need to look back
-       int asc = 0;
-       int des = 0;
-       int wid = 0;
-       mathed_char_height(LM_TC_VAR, st, 'I', asc, des);
-
        for (int pos = 0; pos < data_.size(); data_.next(pos)) {
+               int asc;
+               int des;
+               int wid;
                MathInset * p = data_.nextInset(pos);
                if (p) {
-                       // only MathUpDownInsets will use the asc/des information...
-                       p->Metrics(st, asc, des);
+                       p->Metrics(st);
                        asc = p->ascent();
                        des = p->descent();
                        wid = p->width();
index abd9a3d3e907dffa890597f42b07c2022b77feac..7bc0bc826914eba521c18792adfcf7f1c8b47b74 100644 (file)
@@ -18,7 +18,7 @@ public:
        ///
        MathXArray();
        ///
-       void Metrics(MathStyles st, int asc = 0, int des = 0);
+       void Metrics(MathStyles st);
        ///
        void draw(Painter & pain, int x, int y);