Somewhat larger, that's why to the list. (Hopefully last) re-vamp of MathScriptInset. I hope this does not break too much (I can't see anything right now, so...) Andre' -- André Pönitz ............................................. [EMAIL PROTECTED]
? todo ? todo.backup ? .math_parser.C.swp Index: Makefile.am =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/Makefile.am,v retrieving revision 1.27 diff -u -p -r1.27 Makefile.am --- Makefile.am 2001/07/17 07:38:41 1.27 +++ Makefile.am 2001/07/25 19:28:50 @@ -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: array.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/array.C,v retrieving revision 1.38 diff -u -p -r1.38 array.C --- array.C 2001/07/24 16:10:16 1.38 +++ array.C 2001/07/25 19:28:50 @@ -369,3 +369,11 @@ void MathArray::Validate(LaTeXFeatures & nextInset(pos)->Validate(features); } + +void MathArray::pop_back() +{ + int pos = size(); + prev(pos); + erase(pos); +} + Index: array.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/array.h,v retrieving revision 1.33 diff -u -p -r1.33 array.h --- array.h 2001/07/16 15:53:25 1.33 +++ array.h 2001/07/25 19:28:50 @@ -92,6 +92,8 @@ public: /// void push_back(MathArray const &); /// + void pop_back(); + /// MathInset * back_inset() const; /// Index: formula.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formula.C,v retrieving revision 1.123 diff -u -p -r1.123 formula.C --- formula.C 2001/07/23 09:11:14 1.123 +++ formula.C 2001/07/25 19:28:50 @@ -271,6 +271,14 @@ InsetFormula::localDispatch(BufferView * 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: formulabase.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/formulabase.C,v retrieving revision 1.30 diff -u -p -r1.30 formulabase.C --- formulabase.C 2001/07/25 14:15:05 1.30 +++ formulabase.C 2001/07/25 19:28:50 @@ -507,7 +507,6 @@ InsetFormulaBase::localDispatch(BufferVi } break; - // cursor selection ---------------------------- case LFUN_PASTE: if (was_macro) Index: math_bigopinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_bigopinset.C,v retrieving revision 1.16 diff -u -p -r1.16 math_bigopinset.C --- math_bigopinset.C 2001/07/20 14:54:12 1.16 +++ math_bigopinset.C 2001/07/25 19:28:50 @@ -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() cons } -int MathBigopInset::limits() const +void MathBigopInset::Write(ostream & os, bool /* fragile */) 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 -{ //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 } -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 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; } @@ -116,13 +56,8 @@ void MathBigopInset::draw(Painter & pain { 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 pain.arc(xx, yy, width_, width_, 0, 360 * 64, LColor::mathline); } } - - Index: math_bigopinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_bigopinset.h,v retrieving revision 1.11 diff -u -p -r1.11 math_bigopinset.h --- math_bigopinset.h 2001/07/20 14:54:12 1.11 +++ math_bigopinset.h 2001/07/25 19:28:50 @@ -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: math_cursor.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.C,v retrieving revision 1.76 diff -u -p -r1.76 math_cursor.C --- math_cursor.C 2001/07/25 14:15:05 1.76 +++ math_cursor.C 2001/07/25 19:28:50 @@ -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, { 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() cons } -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: math_cursor.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_cursor.h,v retrieving revision 1.34 diff -u -p -r1.34 math_cursor.h --- math_cursor.h 2001/07/25 14:15:05 1.34 +++ math_cursor.h 2001/07/25 19:28:50 @@ -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: math_decorationinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.C,v retrieving revision 1.16 diff -u -p -r1.16 math_decorationinset.C --- math_decorationinset.C 2001/07/13 09:54:32 1.16 +++ math_decorationinset.C 2001/07/25 19:28:50 @@ -25,7 +25,7 @@ MathInset * MathDecorationInset::clone() -void MathDecorationInset::Metrics(MathStyles st, int, int) +void MathDecorationInset::Metrics(MathStyles st) { xcell(0).Metrics(st); size_ = st; Index: math_decorationinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_decorationinset.h,v retrieving revision 1.11 diff -u -p -r1.11 math_decorationinset.h --- math_decorationinset.h 2001/07/13 08:49:45 1.11 +++ math_decorationinset.h 2001/07/25 19:28:50 @@ -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: math_deliminset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_deliminset.C,v retrieving revision 1.12 diff -u -p -r1.12 math_deliminset.C --- math_deliminset.C 2001/07/13 09:54:32 1.12 +++ math_deliminset.C 2001/07/25 19:28:50 @@ -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: math_deliminset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_deliminset.h,v retrieving revision 1.6 diff -u -p -r1.6 math_deliminset.h --- math_deliminset.h 2001/07/12 07:18:28 1.6 +++ math_deliminset.h 2001/07/25 19:28:50 @@ -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: math_dotsinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_dotsinset.C,v retrieving revision 1.12 diff -u -p -r1.12 math_dotsinset.C --- math_dotsinset.C 2001/07/13 09:54:32 1.12 +++ math_dotsinset.C 2001/07/25 19:28:50 @@ -31,7 +31,7 @@ void MathDotsInset::draw(Painter & pain, } -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: math_dotsinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_dotsinset.h,v retrieving revision 1.8 diff -u -p -r1.8 math_dotsinset.h --- math_dotsinset.h 2001/07/12 07:18:28 1.8 +++ math_dotsinset.h 2001/07/25 19:28:50 @@ -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: math_fracinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_fracinset.C,v retrieving revision 1.20 diff -u -p -r1.20 math_fracinset.C --- math_fracinset.C 2001/07/13 09:54:32 1.20 +++ math_fracinset.C 2001/07/25 19:28:50 @@ -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: math_fracinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_fracinset.h,v retrieving revision 1.13 diff -u -p -r1.13 math_fracinset.h --- math_fracinset.h 2001/07/12 07:18:28 1.13 +++ math_fracinset.h 2001/07/25 19:28:50 @@ -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: math_funcinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.C,v retrieving revision 1.14 diff -u -p -r1.14 math_funcinset.C --- math_funcinset.C 2001/07/20 14:54:13 1.14 +++ math_funcinset.C 2001/07/25 19:28:50 @@ -39,7 +39,7 @@ void MathFuncInset::WriteNormal(std::ost } -void MathFuncInset::Metrics(MathStyles st, int, int) +void MathFuncInset::Metrics(MathStyles st) { size_ = st; if (name_.empty()) Index: math_funcinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_funcinset.h,v retrieving revision 1.10 diff -u -p -r1.10 math_funcinset.h --- math_funcinset.h 2001/07/12 07:18:28 1.10 +++ math_funcinset.h 2001/07/25 19:28:50 @@ -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: math_gridinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.C,v retrieving revision 1.1 diff -u -p -r1.1 math_gridinset.C --- math_gridinset.C 2001/07/17 07:38:41 1.1 +++ math_gridinset.C 2001/07/25 19:28:50 @@ -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: math_gridinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_gridinset.h,v retrieving revision 1.1 diff -u -p -r1.1 math_gridinset.h --- math_gridinset.h 2001/07/17 07:38:41 1.1 +++ math_gridinset.h 2001/07/25 19:28:50 @@ -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: math_hash.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_hash.C,v retrieving revision 1.21 diff -u -p -r1.21 math_hash.C --- math_hash.C 2001/07/13 09:54:32 1.21 +++ math_hash.C 2001/07/25 19:28:50 @@ -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, 0 }, + {"nolimits", LM_TK_LIMIT, -1}, {"perp", LM_TK_MACRO, LM_perp}, {"wedge", LM_TK_SYM, LM_wedge}, {"ln", LM_TK_FUNC, 0}, Index: math_inset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.C,v retrieving revision 1.37 diff -u -p -r1.37 math_inset.C --- math_inset.C 2001/07/16 15:53:25 1.37 +++ math_inset.C 2001/07/25 19:28:50 @@ -170,7 +170,7 @@ void MathInset::substitute(MathArray & a 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: math_inset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_inset.h,v retrieving revision 1.41 diff -u -p -r1.41 math_inset.h --- math_inset.h 2001/07/25 14:15:05 1.41 +++ math_inset.h 2001/07/25 19:28:50 @@ -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: math_macro.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.C,v retrieving revision 1.65 diff -u -p -r1.65 math_macro.C --- math_macro.C 2001/07/13 14:54:56 1.65 +++ math_macro.C 2001/07/25 19:28:50 @@ -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: math_macro.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macro.h,v retrieving revision 1.46 diff -u -p -r1.46 math_macro.h --- math_macro.h 2001/07/13 14:54:56 1.46 +++ math_macro.h 2001/07/25 19:28:50 @@ -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: math_macroarg.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macroarg.C,v retrieving revision 1.15 diff -u -p -r1.15 math_macroarg.C --- math_macroarg.C 2001/07/13 09:54:32 1.15 +++ math_macroarg.C 2001/07/25 19:28:50 @@ -34,7 +34,7 @@ void MathMacroArgument::draw(Painter & p } -void MathMacroArgument::Metrics(MathStyles st, int, int) +void MathMacroArgument::Metrics(MathStyles st) { char str[] = "#0"; str[1] += number_; Index: math_macroarg.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macroarg.h,v retrieving revision 1.11 diff -u -p -r1.11 math_macroarg.h --- math_macroarg.h 2001/07/12 07:18:28 1.11 +++ math_macroarg.h 2001/07/25 19:28:50 @@ -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: math_macrotemplate.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.C,v retrieving revision 1.25 diff -u -p -r1.25 math_macrotemplate.C --- math_macrotemplate.C 2001/07/20 10:55:58 1.25 +++ math_macrotemplate.C 2001/07/25 19:28:50 @@ -49,7 +49,7 @@ void MathMacroTemplate::Write(std::ostre } -void MathMacroTemplate::Metrics(MathStyles st, int, int) +void MathMacroTemplate::Metrics(MathStyles st) { xcell(0).Metrics(st); size_ = st; Index: math_macrotemplate.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_macrotemplate.h,v retrieving revision 1.18 diff -u -p -r1.18 math_macrotemplate.h --- math_macrotemplate.h 2001/07/20 10:55:58 1.18 +++ math_macrotemplate.h 2001/07/25 19:28:50 @@ -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: math_matrixinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.C,v retrieving revision 1.31 diff -u -p -r1.31 math_matrixinset.C --- math_matrixinset.C 2001/07/20 14:54:13 1.31 +++ math_matrixinset.C 2001/07/25 19:28:50 @@ -92,7 +92,7 @@ MathInset * MathMatrixInset::clone() con } -void MathMatrixInset::Metrics(MathStyles /* st */, int, int) +void MathMatrixInset::Metrics(MathStyles /* st */) { size_ = (GetType() == LM_OT_SIMPLE) ? LM_ST_TEXT : LM_ST_DISPLAY; Index: math_matrixinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_matrixinset.h,v retrieving revision 1.17 diff -u -p -r1.17 math_matrixinset.h --- math_matrixinset.h 2001/07/17 07:38:41 1.17 +++ math_matrixinset.h 2001/07/25 19:28:50 @@ -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: math_parser.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_parser.C,v retrieving revision 1.68 diff -u -p -r1.68 math_parser.C --- math_parser.C 2001/07/20 14:54:13 1.68 +++ math_parser.C 2001/07/25 19:28:50 @@ -339,30 +339,38 @@ 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, uns 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, uns 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: math_rootinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_rootinset.C,v retrieving revision 1.1 diff -u -p -r1.1 math_rootinset.C --- math_rootinset.C 2001/07/17 07:38:41 1.1 +++ math_rootinset.C 2001/07/25 19:28:50 @@ -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: math_rootinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_rootinset.h,v retrieving revision 1.1 diff -u -p -r1.1 math_rootinset.h --- math_rootinset.h 2001/07/17 07:38:41 1.1 +++ math_rootinset.h 2001/07/25 19:28:50 @@ -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: math_scriptinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_scriptinset.C,v retrieving revision 1.9 diff -u -p -r1.9 math_scriptinset.C --- math_scriptinset.C 2001/07/13 09:54:32 1.9 +++ math_scriptinset.C 2001/07/25 19:28:50 @@ -6,29 +6,161 @@ #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 << " "; } @@ -40,4 +172,104 @@ void MathScriptInset::idxDelete(int & id down(false); 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: math_scriptinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_scriptinset.h,v retrieving revision 1.5 diff -u -p -r1.5 math_scriptinset.h --- math_scriptinset.h 2001/07/12 07:18:29 1.5 +++ math_scriptinset.h 2001/07/25 19:28:50 @@ -2,7 +2,7 @@ #ifndef MATH_SCRIPTINSET_H #define MATH_SCRIPTINSET_H -#include "math_updowninset.h" +#include "math_inset.h" #ifdef __GNUG__ #pragma interface @@ -12,18 +12,92 @@ \author André Pönitz */ -class MathScriptInset : public MathUpDownInset { + +class MathScriptInset : public MathInset { public: + /// + MathScriptInset(); + /// + MathScriptInset(bool up, bool down, MathInset * = 0); /// - MathScriptInset(bool up, bool down); + 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: math_sizeinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.C,v retrieving revision 1.6 diff -u -p -r1.6 math_sizeinset.C --- math_sizeinset.C 2001/07/13 09:54:32 1.6 +++ math_sizeinset.C 2001/07/25 19:28:50 @@ -43,7 +43,7 @@ void MathSizeInset::draw(Painter & pain, } -void MathSizeInset::Metrics(MathStyles /* st */, int, int) +void MathSizeInset::Metrics(MathStyles /* st */) { xcell(0).Metrics(style_); ascent_ = xcell(0).ascent_; Index: math_sizeinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sizeinset.h,v retrieving revision 1.3 diff -u -p -r1.3 math_sizeinset.h --- math_sizeinset.h 2001/07/12 07:18:29 1.3 +++ math_sizeinset.h 2001/07/25 19:28:50 @@ -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: math_spaceinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_spaceinset.C,v retrieving revision 1.14 diff -u -p -r1.14 math_spaceinset.C --- math_spaceinset.C 2001/07/25 14:15:05 1.14 +++ math_spaceinset.C 2001/07/25 19:28:50 @@ -51,7 +51,7 @@ void MathSpaceInset::WriteNormal(std::os } -void MathSpaceInset::Metrics(MathStyles st, int, int) +void MathSpaceInset::Metrics(MathStyles st) { size_ = st; width_ = space_ ? space_ * 2 : 2; Index: math_spaceinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_spaceinset.h,v retrieving revision 1.11 diff -u -p -r1.11 math_spaceinset.h --- math_spaceinset.h 2001/07/25 14:15:05 1.11 +++ math_spaceinset.h 2001/07/25 19:28:50 @@ -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: math_sqrtinset.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sqrtinset.C,v retrieving revision 1.15 diff -u -p -r1.15 math_sqrtinset.C --- math_sqrtinset.C 2001/07/13 09:54:32 1.15 +++ math_sqrtinset.C 2001/07/25 19:28:50 @@ -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: math_sqrtinset.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/math_sqrtinset.h,v retrieving revision 1.7 diff -u -p -r1.7 math_sqrtinset.h --- math_sqrtinset.h 2001/07/12 07:18:29 1.7 +++ math_sqrtinset.h 2001/07/25 19:28:50 @@ -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 Index: math_updowninset.C =================================================================== RCS file: math_updowninset.C diff -N math_updowninset.C --- /tmp/cvsENbPk2 Wed Jul 25 21:28:51 2001 +++ /dev/null Tue May 5 22:32:27 1998 @@ -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_); -} - Index: math_updowninset.h =================================================================== RCS file: math_updowninset.h diff -N math_updowninset.h --- /tmp/cvs57YBSy Wed Jul 25 21:28:51 2001 +++ /dev/null Tue May 5 22:32:27 1998 @@ -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: xarray.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/xarray.C,v retrieving revision 1.7 diff -u -p -r1.7 xarray.C --- xarray.C 2001/07/24 16:39:55 1.7 +++ xarray.C 2001/07/25 19:28:50 @@ -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, 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: xarray.h =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/mathed/xarray.h,v retrieving revision 1.3 diff -u -p -r1.3 xarray.h --- xarray.h 2001/07/12 07:18:29 1.3 +++ xarray.h 2001/07/25 19:28:50 @@ -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);