X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fmathed%2Fformula.C;h=a6c0b602018d1942208792fcdc2a17c6e4868572;hb=46880e2b9b49632c56bab2377ce9a3c826cf8d1d;hp=d66adac7d3579fd1d950939c4a4d56f397db2ded;hpb=79ca6fbe6dd0f047348e82740eb2f19834c72506;p=lyx.git diff --git a/src/mathed/formula.C b/src/mathed/formula.C index d66adac7d3..a6c0b60201 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -64,29 +64,24 @@ InsetFormula::InsetFormula() {} -InsetFormula::InsetFormula(MathInsetTypes t) - : par_(MathAtom(new MathHullInset(t))), loader_(0) -{} - - -InsetFormula::InsetFormula(string const & s) +InsetFormula::InsetFormula(BufferView * bv) + : par_(MathAtom(new MathHullInset)), loader_(0) { - if (s.size()) { - bool res = mathed_parse_normal(par_, s); + view_ = bv; +} - if (!res) - res = mathed_parse_normal(par_, "$" + s + "$"); - if (!res) { - lyxerr << "cannot interpret '" << s << "' as math\n"; - par_ = MathAtom(new MathHullInset(LM_OT_SIMPLE)); - } - } - metrics(); - updatePreview(); +InsetFormula::InsetFormula(string const & data) + : par_(MathAtom(new MathHullInset)), loader_(0) +{ + if (!data.size()) + return; + if (!mathed_parse_normal(par_, data)) + lyxerr << "cannot interpret '" << data << "' as math\n"; } + Inset * InsetFormula::clone(Buffer const &, bool) const { return new InsetFormula(*this); @@ -109,6 +104,7 @@ int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const } + int InsetFormula::ascii(Buffer const *, ostream & os, int) const { #if 0 @@ -180,7 +176,8 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font, if (canPreview()) { pi.pain.image(x + 1, y - a + 1, w - 2, h - 2, *(loader_->image())); } else { - pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT; + //pi.base.style = display() ? LM_ST_DISPLAY : LM_ST_TEXT; + pi.base.style = LM_ST_TEXT; pi.base.font = font; pi.base.font.setColor(LColor::math); if (lcolor.getX11Name(LColor::mathbg) @@ -298,7 +295,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, int x; int y; mathcursor->getPos(x, y); - hull()->mutate(arg); + mutate(arg); mathcursor->setPos(x, y); mathcursor->normalize(); updateLocal(bv, true); @@ -321,10 +318,10 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, int x = 0; int y = 0; mathcursor->getPos(x, y); - if (getType() == LM_OT_SIMPLE) - hull()->mutate(LM_OT_EQUATION); + if (hullType() == "simple") + mutate("equation"); else - hull()->mutate(LM_OT_SIMPLE); + mutate("simple"); mathcursor->setPos(x, y); mathcursor->normalize(); updateLocal(bv, true); @@ -351,7 +348,7 @@ InsetFormula::localDispatch(BufferView * bv, kb_action action, bool InsetFormula::display() const { - return getType() != LM_OT_SIMPLE; + return hullType() != "simple" && hullType() != "none"; } @@ -415,9 +412,16 @@ int InsetFormula::width(BufferView * bv, LyXFont const & font) const } -MathInsetTypes InsetFormula::getType() const +string InsetFormula::hullType() const +{ + return hull() ? hull()->getType() : "none"; +} + + +void InsetFormula::mutate(string const & type ) { - return hull()->getType(); + if (hull()) + hull()->mutate(type); }