]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.C
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / formula.C
index 440648d582a125b7bb92a9e1d2851617ac9817d0..d8a90be29361a05900b07499dc4c03f97cfe387e 100644 (file)
@@ -13,9 +13,6 @@
 *   the GNU General Public Licence version 2 or later.
 */
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
 
 #include <config.h>
 
@@ -127,7 +124,7 @@ Inset * InsetFormula::clone(Buffer const &, bool) const
 void InsetFormula::write(Buffer const *, ostream & os) const
 {
        WriteStream wi(os, false, false);
-       os << par_->fileInsetLabel() << " ";
+       os << par_->fileInsetLabel() << ' ';
        par_->write(wi);
 }
 
@@ -142,7 +139,7 @@ int InsetFormula::latex(Buffer const *, ostream & os, bool fragile, bool) const
 
 int InsetFormula::ascii(Buffer const *, ostream & os, int) const
 {
-       if (display()) {
+       if (0 && display()) {
                TextMetricsInfo mi;
                par()->metricsT(mi);
                TextPainter tpain(par()->width(), par()->height());
@@ -199,9 +196,9 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 void InsetFormula::draw(BufferView * bv, LyXFont const & font,
                        int y, float & xx, bool) const
 {
+       cache(bv);
        // This initiates the loading of the preview, so should come
        // before the metrics are computed.
-       preview_->setView(bv);
        bool const use_preview = preview_->previewReady();
 
        int const x = int(xx);
@@ -213,8 +210,8 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
        MathPainterInfo pi(bv->painter());
 
        if (use_preview) {
-               pi.pain.image(x, y - a, w, h,
-                             *(preview_->pimage()->image(*this, *bv)));
+               pi.pain.image(x + 1, y - a, w, h,   // one pixel gap in front
+                             *(preview_->pimage()->image()));
        } else {
                pi.base.style = LM_ST_TEXT;
                pi.base.font  = font;
@@ -264,7 +261,7 @@ void InsetFormula::validate(LaTeXFeatures & features) const
 bool InsetFormula::insetAllowed(Inset::Code code) const
 {
        return
-               (code == Inset::LABEL_CODE)
+                  code == Inset::LABEL_CODE
                || code == Inset::REF_CODE
                || code == Inset::ERT_CODE;
 }
@@ -291,7 +288,8 @@ int InsetFormula::width(BufferView * bv, LyXFont const & font) const
 {
        metrics(bv, font);
        return preview_->previewReady() ?
-               preview_->pimage()->width() : par_->width();
+               1 + preview_->pimage()->width() : par_->width();
+               // insert a one pixel gap in front of the formula
 }
 
 
@@ -332,3 +330,4 @@ string const InsetFormula::PreviewImpl::latexString() const
        parent().par_->write(wi);
        return STRCONV(ls.str());
 }
+