]> git.lyx.org Git - features.git/commitdiff
Make it compile with g++-2.95.
authorAngus Leeming <leeming@lyx.org>
Mon, 13 Oct 2003 10:16:05 +0000 (10:16 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 13 Oct 2003 10:16:05 +0000 (10:16 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7907 a592a061-630c-0410-9148-cb99ea01b6c8

src/mathed/ChangeLog
src/mathed/formula.C

index 36f0778b177f8e15cbd12a4daf8e6b5d5a77b480..a056f31b62b63c691038b89212ad832efd92bcb1 100644 (file)
@@ -1,6 +1,8 @@
 2003-10-13  Angus Leeming  <leeming@lyx.org>
 
        * 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  <leeming@lyx.org>
 
index 50423331dc0a93c5958300cdc3b084b054bd94c5..bafa9a967a56c6f9a335e6a04c4e0b54481a72c7 100644 (file)
@@ -177,13 +177,24 @@ void InsetFormula::read(Buffer const &, LyXLex & lex)
 //}
 
 
+namespace {
+
+bool editing_inset(InsetFormula const & inset)
+{
+       return (mathcursor &&
+               mathcursor->formula() == const_cast<InsetFormula *>(&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);
 }