From 9ccefe810b24031894fff8cf3dd39c1bc7f31241 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 26 Jul 2001 06:46:50 +0000 Subject: [PATCH] mathed108.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2352 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 3 + src/mathed/Makefile.am | 2 - src/mathed/array.C | 8 + src/mathed/array.h | 2 + src/mathed/formula.C | 8 + src/mathed/formulabase.C | 1 - src/mathed/math_bigopinset.C | 79 +--------- src/mathed/math_bigopinset.h | 22 +-- src/mathed/math_cursor.C | 80 ++++------ src/mathed/math_cursor.h | 6 +- src/mathed/math_decorationinset.C | 2 +- src/mathed/math_decorationinset.h | 2 +- src/mathed/math_deliminset.C | 2 +- src/mathed/math_deliminset.h | 2 +- src/mathed/math_dotsinset.C | 2 +- src/mathed/math_dotsinset.h | 2 +- src/mathed/math_fracinset.C | 2 +- src/mathed/math_fracinset.h | 2 +- src/mathed/math_funcinset.C | 2 +- src/mathed/math_funcinset.h | 2 +- src/mathed/math_gridinset.C | 2 +- src/mathed/math_gridinset.h | 2 +- src/mathed/math_hash.C | 2 +- src/mathed/math_inset.C | 2 +- src/mathed/math_inset.h | 8 +- src/mathed/math_macro.C | 2 +- src/mathed/math_macro.h | 2 +- src/mathed/math_macroarg.C | 2 +- src/mathed/math_macroarg.h | 2 +- src/mathed/math_macrotemplate.C | 2 +- src/mathed/math_macrotemplate.h | 2 +- src/mathed/math_matrixinset.C | 2 +- src/mathed/math_matrixinset.h | 2 +- src/mathed/math_parser.C | 69 +++++---- src/mathed/math_rootinset.C | 2 +- src/mathed/math_rootinset.h | 2 +- src/mathed/math_scriptinset.C | 250 ++++++++++++++++++++++++++++-- src/mathed/math_scriptinset.h | 84 +++++++++- src/mathed/math_sizeinset.C | 2 +- src/mathed/math_sizeinset.h | 2 +- src/mathed/math_spaceinset.C | 2 +- src/mathed/math_spaceinset.h | 2 +- src/mathed/math_sqrtinset.C | 2 +- src/mathed/math_sqrtinset.h | 2 +- src/mathed/math_updowninset.C | 179 --------------------- src/mathed/math_updowninset.h | 75 --------- src/mathed/xarray.C | 14 +- src/mathed/xarray.h | 2 +- 48 files changed, 465 insertions(+), 487 deletions(-) delete mode 100644 src/mathed/math_updowninset.C delete mode 100644 src/mathed/math_updowninset.h diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 384d5f81b6..e5c4c4257c 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -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 * math_cursor.C: fix "pullArg" behaviour diff --git a/src/mathed/Makefile.am b/src/mathed/Makefile.am index d2e13830f7..ead7112d35 100644 --- a/src/mathed/Makefile.am +++ b/src/mathed/Makefile.am @@ -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 \ diff --git a/src/mathed/array.C b/src/mathed/array.C index c1cee61e43..aa65bbcc1b 100644 --- a/src/mathed/array.C +++ b/src/mathed/array.C @@ -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); +} + diff --git a/src/mathed/array.h b/src/mathed/array.h index 2155c16fde..16da85b7d3 100644 --- a/src/mathed/array.h +++ b/src/mathed/array.h @@ -92,6 +92,8 @@ public: /// void push_back(MathArray const &); /// + void pop_back(); + /// MathInset * back_inset() const; /// diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 31af423668..d761dd5cd9 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -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); diff --git a/src/mathed/formulabase.C b/src/mathed/formulabase.C index 2dd0a2d97e..d666fce5c1 100644 --- a/src/mathed/formulabase.C +++ b/src/mathed/formulabase.C @@ -507,7 +507,6 @@ InsetFormulaBase::localDispatch(BufferView * bv, kb_action action, } break; - // cursor selection ---------------------------- case LFUN_PASTE: if (was_macro) diff --git a/src/mathed/math_bigopinset.C b/src/mathed/math_bigopinset.C index 96eeb84aa8..cba5e869c5 100644 --- a/src/mathed/math_bigopinset.C +++ b/src/mathed/math_bigopinset.C @@ -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); } } - - diff --git a/src/mathed/math_bigopinset.h b/src/mathed/math_bigopinset.h index cf4f50ed57..7c56750920 100644 --- a/src/mathed/math_bigopinset.h +++ b/src/mathed/math_bigopinset.h @@ -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 diff --git a/src/mathed/math_cursor.C b/src/mathed/math_cursor.C index ca5852a3ca..a3b77d5a2d 100644 --- a/src/mathed/math_cursor.C +++ b/src/mathed/math_cursor.C @@ -115,8 +115,6 @@ struct Selection data_.clear(); } - - std::vector 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(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(p) : 0; + return (p && p->isScriptInset()) ? static_cast(p) : 0; } diff --git a/src/mathed/math_cursor.h b/src/mathed/math_cursor.h index 769143eb05..766cc1c26d 100644 --- a/src/mathed/math_cursor.h +++ b/src/mathed/math_cursor.h @@ -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; diff --git a/src/mathed/math_decorationinset.C b/src/mathed/math_decorationinset.C index fb3ae4009c..43153ee93c 100644 --- a/src/mathed/math_decorationinset.C +++ b/src/mathed/math_decorationinset.C @@ -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; diff --git a/src/mathed/math_decorationinset.h b/src/mathed/math_decorationinset.h index 94c368b24a..da247eb4cd 100644 --- a/src/mathed/math_decorationinset.h +++ b/src/mathed/math_decorationinset.h @@ -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: diff --git a/src/mathed/math_deliminset.C b/src/mathed/math_deliminset.C index 1ee6475ddb..6c530180cc 100644 --- a/src/mathed/math_deliminset.C +++ b/src/mathed/math_deliminset.C @@ -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; diff --git a/src/mathed/math_deliminset.h b/src/mathed/math_deliminset.h index cd25fe6f1b..8ab72b17d1 100644 --- a/src/mathed/math_deliminset.h +++ b/src/mathed/math_deliminset.h @@ -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; /// diff --git a/src/mathed/math_dotsinset.C b/src/mathed/math_dotsinset.C index 7054cde4bf..f29b3a52f7 100644 --- a/src/mathed/math_dotsinset.C +++ b/src/mathed/math_dotsinset.C @@ -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_); diff --git a/src/mathed/math_dotsinset.h b/src/mathed/math_dotsinset.h index d6d973a820..7f1b29e276 100644 --- a/src/mathed/math_dotsinset.h +++ b/src/mathed/math_dotsinset.h @@ -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_; diff --git a/src/mathed/math_fracinset.C b/src/mathed/math_fracinset.C index 576f98c4e8..1bb6b902c4 100644 --- a/src/mathed/math_fracinset.C +++ b/src/mathed/math_fracinset.C @@ -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_); diff --git a/src/mathed/math_fracinset.h b/src/mathed/math_fracinset.h index 10da11aae8..4a3e7ab8e8 100644 --- a/src/mathed/math_fracinset.h +++ b/src/mathed/math_fracinset.h @@ -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); /// diff --git a/src/mathed/math_funcinset.C b/src/mathed/math_funcinset.C index a75ba7360c..933b0f3446 100644 --- a/src/mathed/math_funcinset.C +++ b/src/mathed/math_funcinset.C @@ -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()) diff --git a/src/mathed/math_funcinset.h b/src/mathed/math_funcinset.h index 9b386b274d..5c7dcf0c1e 100644 --- a/src/mathed/math_funcinset.h +++ b/src/mathed/math_funcinset.h @@ -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_; diff --git a/src/mathed/math_gridinset.C b/src/mathed/math_gridinset.C index 5b4afb14e2..bfd69f770a 100644 --- a/src/mathed/math_gridinset.C +++ b/src/mathed/math_gridinset.C @@ -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); diff --git a/src/mathed/math_gridinset.h b/src/mathed/math_gridinset.h index cb58ebfd2d..027433705e 100644 --- a/src/mathed/math_gridinset.h +++ b/src/mathed/math_gridinset.h @@ -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); /// diff --git a/src/mathed/math_hash.C b/src/mathed/math_hash.C index 51b70065cb..693cfaffba 100644 --- a/src/mathed/math_hash.C +++ b/src/mathed/math_hash.C @@ -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}, diff --git a/src/mathed/math_inset.C b/src/mathed/math_inset.C index bbbf107db2..b5980fc019 100644 --- a/src/mathed/math_inset.C +++ b/src/mathed/math_inset.C @@ -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) diff --git a/src/mathed/math_inset.h b/src/mathed/math_inset.h index b5ad07d7d1..d2919dcb43 100644 --- a/src/mathed/math_inset.h +++ b/src/mathed/math_inset.h @@ -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; } /// diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 5085e783bf..143b547cda 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -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); diff --git a/src/mathed/math_macro.h b/src/mathed/math_macro.h index f40f3df829..a820b708aa 100644 --- a/src/mathed/math_macro.h +++ b/src/mathed/math_macro.h @@ -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; /// diff --git a/src/mathed/math_macroarg.C b/src/mathed/math_macroarg.C index c64f750c77..325cf2010c 100644 --- a/src/mathed/math_macroarg.C +++ b/src/mathed/math_macroarg.C @@ -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_; diff --git a/src/mathed/math_macroarg.h b/src/mathed/math_macroarg.h index f089bf3c9e..594b7100e4 100644 --- a/src/mathed/math_macroarg.h +++ b/src/mathed/math_macroarg.h @@ -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); /// diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index ba994c14b9..6d64a524c6 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -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; diff --git a/src/mathed/math_macrotemplate.h b/src/mathed/math_macrotemplate.h index 64283ab14c..c1cc9eb94c 100644 --- a/src/mathed/math_macrotemplate.h +++ b/src/mathed/math_macrotemplate.h @@ -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_; diff --git a/src/mathed/math_matrixinset.C b/src/mathed/math_matrixinset.C index d552e20242..042c4f23f7 100644 --- a/src/mathed/math_matrixinset.C +++ b/src/mathed/math_matrixinset.C @@ -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; diff --git a/src/mathed/math_matrixinset.h b/src/mathed/math_matrixinset.h index 950caa9e17..ed37ec3eec 100644 --- a/src/mathed/math_matrixinset.h +++ b/src/mathed/math_matrixinset.h @@ -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); /// diff --git a/src/mathed/math_parser.C b/src/mathed/math_parser.C index 863346232d..e9b96cef8b 100644 --- a/src/mathed/math_parser.C +++ b/src/mathed/math_parser.C @@ -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(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(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(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) { diff --git a/src/mathed/math_rootinset.C b/src/mathed/math_rootinset.C index 427af7150e..4e6be68cf3 100644 --- a/src/mathed/math_rootinset.C +++ b/src/mathed/math_rootinset.C @@ -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; diff --git a/src/mathed/math_rootinset.h b/src/mathed/math_rootinset.h index cae5cfb93a..1b1fb2e360 100644 --- a/src/mathed/math_rootinset.h +++ b/src/mathed/math_rootinset.h @@ -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; /// diff --git a/src/mathed/math_scriptinset.C b/src/mathed/math_scriptinset.C index 09e52cccf0..5157182f8a 100644 --- a/src/mathed/math_scriptinset.C +++ b/src/mathed/math_scriptinset.C @@ -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 << " "; } @@ -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_); +} diff --git a/src/mathed/math_scriptinset.h b/src/mathed/math_scriptinset.h index 7f589e953b..359db5ee34 100644 --- a/src/mathed/math_scriptinset.h +++ b/src/mathed/math_scriptinset.h @@ -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(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 diff --git a/src/mathed/math_sizeinset.C b/src/mathed/math_sizeinset.C index 124f03bce3..83cbf6e64f 100644 --- a/src/mathed/math_sizeinset.C +++ b/src/mathed/math_sizeinset.C @@ -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_; diff --git a/src/mathed/math_sizeinset.h b/src/mathed/math_sizeinset.h index d581be7320..98d209e5e1 100644 --- a/src/mathed/math_sizeinset.h +++ b/src/mathed/math_sizeinset.h @@ -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); /// diff --git a/src/mathed/math_spaceinset.C b/src/mathed/math_spaceinset.C index 8f9d999825..231f4c8b1c 100644 --- a/src/mathed/math_spaceinset.C +++ b/src/mathed/math_spaceinset.C @@ -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; diff --git a/src/mathed/math_spaceinset.h b/src/mathed/math_spaceinset.h index df88004c9a..8edbdc1983 100644 --- a/src/mathed/math_spaceinset.h +++ b/src/mathed/math_spaceinset.h @@ -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; } /// diff --git a/src/mathed/math_sqrtinset.C b/src/mathed/math_sqrtinset.C index 6ad124ef0f..f9097d9c91 100644 --- a/src/mathed/math_sqrtinset.C +++ b/src/mathed/math_sqrtinset.C @@ -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; diff --git a/src/mathed/math_sqrtinset.h b/src/mathed/math_sqrtinset.h index e3e153de39..18019df49d 100644 --- a/src/mathed/math_sqrtinset.h +++ b/src/mathed/math_sqrtinset.h @@ -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 index 77c2117e4c..0000000000 --- a/src/mathed/math_updowninset.C +++ /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 index 325f068482..0000000000 --- a/src/mathed/math_updowninset.h +++ /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 diff --git a/src/mathed/xarray.C b/src/mathed/xarray.C index 269bfafefa..e05d3167e2 100644 --- a/src/mathed/xarray.C +++ b/src/mathed/xarray.C @@ -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(); diff --git a/src/mathed/xarray.h b/src/mathed/xarray.h index abd9a3d3e9..7bc0bc8269 100644 --- a/src/mathed/xarray.h +++ b/src/mathed/xarray.h @@ -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); -- 2.39.2