From 360b55ea0fad8daa33a8b595209bde3e4800f21c Mon Sep 17 00:00:00 2001 From: Angus Leeming Date: Mon, 13 Oct 2003 10:16:05 +0000 Subject: [PATCH] Make it compile with g++-2.95. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7907 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/mathed/ChangeLog | 2 ++ src/mathed/formula.C | 40 ++++++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 20 deletions(-) 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); } -- 2.39.2