From d559de976f8bc1b312a2d3c2718913a3445142b3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Tue, 27 Feb 2001 11:26:18 +0000 Subject: [PATCH] small mathed change add the find_if git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1632 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/BufferView_pimpl.C | 1 + src/ChangeLog | 4 ++ src/mathed/ChangeLog | 8 ++++ src/mathed/math_macro.C | 13 ++++--- src/mathed/math_macrotemplate.C | 7 ++-- src/mathed/math_parinset.C | 68 ++++++++++++++++++--------------- 6 files changed, 60 insertions(+), 41 deletions(-) diff --git a/src/BufferView_pimpl.C b/src/BufferView_pimpl.C index a0865b74a3..ddc32735da 100644 --- a/src/BufferView_pimpl.C +++ b/src/BufferView_pimpl.C @@ -63,6 +63,7 @@ extern int greek_kb_flag; using SigC::slot; #endif +using std::find_if; using std::pair; using std::endl; using std::make_pair; diff --git a/src/ChangeLog b/src/ChangeLog index ecd545cba1..c549ab874d 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2001-02-27 Lars Gullik Bjønnes + + * BufferView_pimpl.C: add using std::find_if + 2001-02-27 José Matos * LaTeXFeatures.C (getIncludedFiles): call to BasePath replaced diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 42d1610769..2cdd809a06 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,3 +1,11 @@ +2001-02-27 Lars Gullik Bjønnes + + * math_parinset.C (draw): move MathedXiter data(this) up. and + remove it two other places. + + * math_macro.C (MathMacro): use array directly, don't use + setArgumentIdx and GetData + 2001-02-26 Lars Gullik Bjønnes * math_macroarg.C (MathMacroArgument): delete diff --git a/src/mathed/math_macro.C b/src/mathed/math_macro.C index 13ac9b5531..606caf9e70 100644 --- a/src/mathed/math_macro.C +++ b/src/mathed/math_macro.C @@ -44,8 +44,8 @@ ostream & operator<<(ostream & o, MathedTextCodes mtc) } -MathMacro::MathMacro(MathMacroTemplate * t): - MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate_(t) +MathMacro::MathMacro(MathMacroTemplate * t) + : MathParInset(LM_ST_TEXT, "", LM_OT_MACRO), tmplate_(t) { nargs_ = tmplate_->getNoArgs(); tcode_ = tmplate_->getTCode(); @@ -58,8 +58,8 @@ MathMacro::MathMacro(MathMacroTemplate * t): } -MathMacro::MathMacro(MathMacro * m): - MathParInset(LM_ST_TEXT, m->GetName(), LM_OT_MACRO) +MathMacro::MathMacro(MathMacro * m) + : MathParInset(LM_ST_TEXT, m->GetName(), LM_OT_MACRO) { tmplate_ = m->tmplate_; nargs_ = tmplate_->getNoArgs(); @@ -68,9 +68,10 @@ MathMacro::MathMacro(MathMacro * m): idx_ = 0; SetName(tmplate_->GetName()); for (int i = 0; i < tmplate_->getNoArgs(); ++i) { - m->setArgumentIdx(i); + //m->setArgumentIdx(i); args_[i].row = m->args_[i].row; - args_[i].array = m->GetData(); + //args_[i].array = m->GetData(); + args_[i].array = m->args_[i].array; } } diff --git a/src/mathed/math_macrotemplate.C b/src/mathed/math_macrotemplate.C index d2579604ce..4e78366363 100644 --- a/src/mathed/math_macrotemplate.C +++ b/src/mathed/math_macrotemplate.C @@ -59,8 +59,7 @@ void MathMacroTemplate::setEditMode(bool ed) for (int i = 0; i < nargs_; ++i) { args_[i].setExpand(false); } - } - else { + } else { flags_ &= ~MMF_Edit; for (int i = 0; i < nargs_; ++i) { args_[i].setExpand(true); @@ -73,7 +72,7 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y) { int x2; int y2; - bool expnd = (nargs_ > 0) ? args_[0].getExpand(): false; + bool expnd = (nargs_ > 0) ? args_[0].getExpand() : false; if (flags_ & MMF_Edit) { for (int i = 0; i < nargs_; ++i) { args_[i].setExpand(false); @@ -99,7 +98,7 @@ void MathMacroTemplate::draw(Painter & pain, int x, int y) void MathMacroTemplate::Metrics() { - bool expnd = (nargs_ > 0) ? args_[0].getExpand(): false; + bool expnd = (nargs_ > 0) ? args_[0].getExpand() : false; if (flags_ & MMF_Edit) { for (int i = 0; i < nargs_; ++i) { diff --git a/src/mathed/math_parinset.C b/src/mathed/math_parinset.C index 1a0e01b25d..83336a8753 100644 --- a/src/mathed/math_parinset.C +++ b/src/mathed/math_parinset.C @@ -35,6 +35,7 @@ MathParInset::MathParInset(short st, string const & nm, short ot) } +// This is virtual and needed. MathParInset::~MathParInset() { } @@ -72,25 +73,26 @@ MathParInset::draw(Painter & pain, int x, int y) bool limits = false; xo_ = x; - yo_ = y; + yo_ = y; + MathedXIter data(this); if (array.empty()) { - MathedXIter data(this); + //MathedXIter data(this); data.GetPos(x, y); - pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); + pain.rectangle(x, y - df_asc, df_width, df_asc, + LColor::mathline); return; - } - MathedXIter data(this); + } + //MathedXIter data(this); data.GoBegin(); while (data.OK()) { data.GetPos(x, y); byte cx = data.GetChar(); if (cx >= ' ') { - string s = data.GetString(); + string const s = data.GetString(); drawStr(pain, data.fcode(), size(), x, y, s); mathed_char_height(LM_TC_CONST, size(), 'y', asc, des); limits = false; - } - else { + } else { if (cx == 0) break; if (MathIsInset(cx)) { @@ -98,46 +100,49 @@ MathParInset::draw(Painter & pain, int x, int y) MathedInset * p = data.GetInset(); if (cx == LM_TC_UP) { if (limits) { - x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp; - yy -= (asc + p->Descent()+4); - } - else - yy -= (p->Descent()>asc) ? p->Descent()+4: asc; - } - else if (cx == LM_TC_DOWN) { + x -= (xp > p->Width()) ? + p->Width() + (xp - p->Width()) / 2 : xp; + yy -= (asc + p->Descent() + 4); + } else + yy -= (p->Descent() > asc) ? + p->Descent() + 4 : asc; + } else if (cx == LM_TC_DOWN) { if (limits) { - x -= (xp>p->Width()) ? p->Width()+(xp-p->Width())/2: xp; + x -= (xp > p->Width()) ? + p->Width() + (xp - p->Width()) / 2 : xp; yy += des + p->Ascent() + 2; } else - yy += des + p->Ascent()/2; - } - else { + yy += des + p->Ascent() / 2; + } else { asc = p->Ascent(); des = p->Descent(); } p->draw(pain, x, yy); - if (cx!= LM_TC_UP && cx!= LM_TC_DOWN) { + if (cx != LM_TC_UP && cx != LM_TC_DOWN) { limits = p->GetLimits(); if (limits) xp = p->Width(); } data.Next(); - } - else if (cx == LM_TC_TAB) { - if (cxp == cx || cxp == LM_TC_CR || data.IsFirst()) { - pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); + } else if (cx == LM_TC_TAB) { + if (cxp == cx + || cxp == LM_TC_CR || data.IsFirst()) { + pain.rectangle(x, y - df_asc, + df_width, df_asc, + LColor::mathline); } data.Next(); limits = false; - } - else if (cx == LM_TC_CR) { - if (cxp == LM_TC_TAB || cxp == LM_TC_CR || data.IsFirst()) { - pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); + } else if (cx == LM_TC_CR) { + if (cxp == LM_TC_TAB + || cxp == LM_TC_CR || data.IsFirst()) { + pain.rectangle(x, y - df_asc, + df_width, df_asc, + LColor::mathline); } data.Next(); limits = false; - } - else { + } else { lyxerr << "GMathed Error: Unrecognized code[" << cx << "]" << endl; break; } @@ -146,7 +151,8 @@ MathParInset::draw(Painter & pain, int x, int y) } if (cxp == LM_TC_TAB || cxp == LM_TC_CR) { data.GetPos(x, y); - pain.rectangle(x, y - df_asc, df_width, df_asc, LColor::mathline); + pain.rectangle(x, y - df_asc, df_width, df_asc, + LColor::mathline); } } -- 2.39.2