]> git.lyx.org Git - lyx.git/blobdiff - src/insets/render_preview.C
hopefully fix tex2lyx linking.
[lyx.git] / src / insets / render_preview.C
index dd61fe71348ef3336dbcc256593a3ac824d775b7..21ce5c58b68c33c273ca0ec96d8b2c679cae1818 100644 (file)
@@ -21,7 +21,7 @@
 #include "lyxrc.h"
 #include "metricsinfo.h"
 
-#include "frontends/font_metrics.h"
+#include "frontends/FontMetrics.h"
 #include "frontends/Painter.h"
 
 #include "graphics/PreviewImage.h"
 
 #include <boost/bind.hpp>
 
-using lyx::docstring;
+
+namespace lyx {
 
 using std::string;
 using std::auto_ptr;
 
-namespace graphics = lyx::graphics;
-namespace support  = lyx::support;
-
 
 LyXRC_PreviewStatus RenderPreview::status()
 {
@@ -76,7 +74,7 @@ graphics::PreviewLoader & getPreviewLoader(Buffer const & buffer)
 }
 
 
-string const statusMessage(BufferView const * bv, string const & snippet)
+docstring const statusMessage(BufferView const * bv, string const & snippet)
 {
        BOOST_ASSERT(bv && bv->buffer());
 
@@ -98,8 +96,7 @@ string const statusMessage(BufferView const * bv, string const & snippet)
                break;
        }
 
-       // FIXME UNICODE
-       return lyx::to_utf8(message);
+       return message;
 }
 
 } // namespace anon
@@ -131,9 +128,8 @@ void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
                LyXFont font(mi.base.font);
                font.setFamily(LyXFont::SANS_FAMILY);
                font.setSize(LyXFont::SIZE_FOOTNOTE);
-               string stat = statusMessage(mi.base.bv, snippet_);
-               docstring dstat(stat.begin(), stat.end());
-               dim.wid = 15 + font_metrics::width(dstat, font);
+               docstring const stat = statusMessage(mi.base.bv, snippet_);
+               dim.wid = 15 + theFontMetrics(font).width(stat);
        }
 
        dim_ = dim;
@@ -165,11 +161,10 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
                font.setFamily(LyXFont::SANS_FAMILY);
                font.setSize(LyXFont::SIZE_FOOTNOTE);
 
-               string stat = statusMessage(pi.base.bv, snippet_);
-               docstring dstat(stat.begin(), stat.end());
+               docstring const stat = statusMessage(pi.base.bv, snippet_);
                pi.pain.text(x + offset + 6,
-                            y - font_metrics::maxAscent(font) - 4,
-                            dstat, font);
+                            y - theFontMetrics(font).maxAscent() - 4,
+                            stat, font);
        }
 }
 
@@ -184,7 +179,7 @@ void RenderPreview::startLoading(Buffer const & buffer) const
 }
 
 
-void RenderPreview::addPreview(string const & latex_snippet,
+void RenderPreview::addPreview(docstring const & latex_snippet,
                               Buffer const & buffer)
 {
        if (status() == LyXRC::PREVIEW_OFF)
@@ -195,13 +190,15 @@ void RenderPreview::addPreview(string const & latex_snippet,
 }
 
 
-void RenderPreview::addPreview(string const & latex_snippet,
+void RenderPreview::addPreview(docstring const & latex_snippet,
                               graphics::PreviewLoader & ploader)
 {
        if (status() == LyXRC::PREVIEW_OFF)
                return;
 
-       snippet_ = support::trim(latex_snippet);
+       // FIXME UNICODE
+       // We have to make sure that we call latex with the right encoding
+       snippet_ = support::trim(to_utf8(latex_snippet));
        if (snippet_.empty())
                return;
 
@@ -264,3 +261,5 @@ RenderMonitoredPreview::fileChanged(slot_type const & slot)
 {
        return monitor_.connect(slot);
 }
+
+} // namespace lyx