diff --git a/src/mathed/ChangeLog b/src/mathed/ChangeLog index 36f0778b17..a056f31b62 100644 --- a/src/mathed/ChangeLog +++ b/src/mathed/ChangeLog @@ -1,6 +1,8 @@ 2003-10-13 Angus Leeming * formula.C: remove #include "PreviewImage.h". + (draw, metrics): some simplification of the editing_inset check. + Also make it compile with g++2.95. 2003-10-12 Angus Leeming diff --git a/src/mathed/formula.C b/src/mathed/formula.C index 50423331dc..bafa9a967a 100644 --- a/src/mathed/formula.C +++ b/src/mathed/formula.C @@ -177,13 +177,24 @@ void InsetFormula::read(Buffer const &, LyXLex & lex) //} +namespace { + +bool editing_inset(InsetFormula const & inset) +{ + return (mathcursor && + mathcursor->formula() == const_cast(&inset)); +} + +} // namespace anon + + void InsetFormula::draw(PainterInfo & pi, int x, int y) const { cache(pi.base.bv); // The previews are drawn only when we're not editing the inset. - bool const editing_inset = mathcursor && mathcursor->formula() == this; - bool const use_preview = !editing_inset && preview_->previewReady(); + bool const use_preview = (!editing_inset(*this) && + preview_->previewReady()); int const w = dim_.wid; int const d = dim_.des; @@ -202,7 +213,7 @@ void InsetFormula::draw(PainterInfo & pi, int x, int y) const != lcolor.getX11Name(LColor::background)) p.pain.fillRectangle(x, y - a, w, h, LColor::mathbg); - if (editing_inset) { + if (editing_inset(*this)) { mathcursor->drawSelection(pi); //p.pain.rectangle(x, y - a, w, h, LColor::mathframe); } @@ -245,8 +256,8 @@ bool InsetFormula::insetAllowed(InsetOld::Code code) const void InsetFormula::metrics(MetricsInfo & m, Dimension & dim) const { - bool const editing_inset = mathcursor && mathcursor->formula() == this; - bool const use_preview = !editing_inset && preview_->previewReady(); + bool const use_preview = (!editing_inset(*this) && + preview_->previewReady()); if (use_preview) { preview_->metrics(m, dim); @@ -293,13 +304,6 @@ void InsetFormula::statusChanged() const namespace { -bool preview_wanted(InsetFormula const & inset, Buffer const &) -{ - // Don't want a preview when we're editing the inset - return !(mathcursor && mathcursor->formula() == &inset); -} - - string const latex_string(InsetFormula const & inset, Buffer const &) { ostringstream ls; @@ -313,17 +317,13 @@ string const latex_string(InsetFormula const & inset, Buffer const &) void InsetFormula::addPreview(lyx::graphics::PreviewLoader & ploader) const { - if (preview_wanted(*this, ploader.buffer())) { - string const snippet = latex_string(*this, ploader.buffer()); - preview_->addPreview(snippet, ploader); - } + string const snippet = latex_string(*this, ploader.buffer()); + preview_->addPreview(snippet, ploader); } void InsetFormula::generatePreview(Buffer const & buffer) const { - if (preview_wanted(*this, buffer)) { - string const snippet = latex_string(*this, buffer); - preview_->generatePreview(snippet, buffer); - } + string const snippet = latex_string(*this, buffer); + preview_->generatePreview(snippet, buffer); }