From ec1f62628475dcb900bed4dc81d488701fbc15a8 Mon Sep 17 00:00:00 2001 From: Stefan Schimanski Date: Mon, 10 Mar 2008 12:49:50 +0000 Subject: [PATCH] * small fixes of the temporary change display of macro templates git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23618 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/MathMacroTemplate.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/mathed/MathMacroTemplate.cpp b/src/mathed/MathMacroTemplate.cpp index a8bbba4283..a18a83e817 100644 --- a/src/mathed/MathMacroTemplate.cpp +++ b/src/mathed/MathMacroTemplate.cpp @@ -400,7 +400,7 @@ MathMacroTemplate::MathMacroTemplate(docstring const & name, int numargs, int optionals, MacroType type, vector const & optionalValues, MathData const & def, MathData const & display) - : InsetMathNest(optionals + 3), numargs_(numargs), argsInLook_(0), + : InsetMathNest(optionals + 3), numargs_(numargs), argsInLook_(numargs), optionals_(optionals), optionalValues_(optionalValues), type_(type), lookOutdated_(true) { @@ -486,14 +486,13 @@ void MathMacroTemplate::createLook(int args) const if (optionals_ > 0) { look_.push_back(MathAtom(new InsetLabelBox(_("optional"), *this, false))); + MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0); for (; i < optionals_; ++i) { - MathData * optData = &look_[look_.size() - 1].nucleus()->cell(0); - - // color it red, if it is to be remove when the cursor leaves - if (optionals_ > argsInLook_) { + // color it light grey, if it is to be removed when the cursor leaves + if (i == argsInLook_) { optData->push_back(MathAtom( new InsetColoredCell(Color_mathbg, Color_mathmacrooldarg))); - optData = &(*optData)[0].nucleus()->cell(0); + optData = &(*optData)[optData->size() - 1].nucleus()->cell(0); } optData->push_back(MathAtom(new InsetMathChar('['))); @@ -598,9 +597,8 @@ void MathMacroTemplate::draw(PainterInfo & pi, int x, int y) const pi.pain.rectangle(x, a, w, h, Color_mathframe); // just to be sure: set some dummy values for coord cache - for (idx_type i = 0; i < nargs(); ++i) { + for (idx_type i = 0; i < nargs(); ++i) cell(i).setXY(*pi.base.bv, x, y); - } // draw contents look_.draw(pi, x + 3, y); @@ -1148,7 +1146,7 @@ void MathMacroTemplate::write(WriteStream & os, bool overwriteRedefinition) cons for (int i = 0; i < optionals_; ++i) { docstring optValue = asString(cell(optIdx(i))); if (optValue.find(']') != docstring::npos - || optValue.find('=') != docstring::npos) + || optValue.find(',') != docstring::npos) os << ", " << i + 1 << "=" << "{" << cell(optIdx(i)) << "}"; else -- 2.39.2