]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/formula.C
rename commandtags.h to lfuns.h and renumber/cleanup. Rebuild the tree !
[lyx.git] / src / mathed / formula.C
index 5bbd64be6cd9516c21d2add8f9ec5ad0307d20c2..15d10238f51d9c0bd9e7a831979806ac2bc973e9 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());
@@ -197,11 +194,11 @@ void InsetFormula::read(Buffer const *, LyXLex & lex)
 
 
 void InsetFormula::draw(BufferView * bv, LyXFont const & font,
-                       int y, float & xx, bool) const
+                       int y, float & xx) 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;
@@ -230,7 +227,7 @@ void InsetFormula::draw(BufferView * bv, LyXFont const & font,
                        //pi.pain.rectangle(x, y - a, w, h, LColor::mathframe);
                }
 
-               par_->draw(pi, x + 1, y);
+               par_->draw(pi, x, y);
        }
 
        xx += w;
@@ -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
 }
 
 
@@ -330,5 +328,6 @@ string const InsetFormula::PreviewImpl::latexString() const
        ostringstream ls;
        WriteStream wi(ls, false, false);
        parent().par_->write(wi);
-       return ls.str().c_str();
+       return STRCONV(ls.str());
 }
+