]> git.lyx.org Git - lyx.git/blobdiff - src/insets/renderers.C
prevent crash when inserting minipage in table cell,
[lyx.git] / src / insets / renderers.C
index 3839e167bb685ab7e3e3fee4ce7d2f4831407709..b9c52c1920b53f8a6091a2445428138ea1dd6904 100644 (file)
 #include "graphics/GraphicsImage.h"
 
 #include "support/filetools.h"
-
+#include "support/LAssert.h"
 
 using namespace lyx::support;
 
-namespace grfx = lyx::graphics;
 
 RenderInset::RenderInset()
 {}
@@ -128,7 +127,7 @@ RenderInset * GraphicRenderer::clone() const
 }
 
 
-void GraphicRenderer::update(grfx::Params const & params)
+void GraphicRenderer::update(lyx::graphics::Params const & params)
 {
        params_ = params;
 
@@ -158,27 +157,27 @@ boost::signals::connection GraphicRenderer::connect(slot_type const & slot) cons
 string const GraphicRenderer::statusMessage() const
 {
        switch (loader_.status()) {
-               case grfx::WaitingToLoad:
+               case lyx::graphics::WaitingToLoad:
                        return _("Not shown.");
-               case grfx::Loading:
+               case lyx::graphics::Loading:
                        return _("Loading...");
-               case grfx::Converting:
+               case lyx::graphics::Converting:
                        return _("Converting to loadable format...");
-               case grfx::Loaded:
+               case lyx::graphics::Loaded:
                        return _("Loaded into memory. Must now generate pixmap.");
-               case grfx::ScalingEtc:
+               case lyx::graphics::ScalingEtc:
                        return _("Scaling etc...");
-               case grfx::Ready:
+               case lyx::graphics::Ready:
                        return _("Ready to display");
-               case grfx::ErrorNoFile:
+               case lyx::graphics::ErrorNoFile:
                        return _("No file found!");
-               case grfx::ErrorConverting:
+               case lyx::graphics::ErrorConverting:
                        return _("Error converting to loadable format");
-               case grfx::ErrorLoading:
+               case lyx::graphics::ErrorLoading:
                        return _("Error loading file into memory");
-               case grfx::ErrorGeneratingPixmap:
+               case lyx::graphics::ErrorGeneratingPixmap:
                        return _("Error generating the pixmap");
-               case grfx::ErrorUnknown:
+               case lyx::graphics::ErrorUnknown:
                        return _("No image");
        }
        return string();
@@ -187,7 +186,7 @@ string const GraphicRenderer::statusMessage() const
 
 bool GraphicRenderer::readyToDisplay() const
 {
-       if (!loader_.image() || loader_.status() != grfx::Ready)
+       if (!loader_.image() || loader_.status() != lyx::graphics::Ready)
                return false;
        return loader_.image()->isDrawable();
 }
@@ -202,7 +201,7 @@ void GraphicRenderer::metrics(MetricsInfo & mi, Dimension & dim) const
 
        if (image_ready) {
                dim.wid = loader_.image()->getWidth() +
-                       2 * Inset::TEXT_TO_INSET_OFFSET;
+                       2 * InsetOld::TEXT_TO_INSET_OFFSET;
        } else {
                int font_width = 0;
 
@@ -259,27 +258,28 @@ void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const
        }
 #endif
 
-       if (params_.display != grfx::NoDisplay &&
-           loader_.status() == grfx::WaitingToLoad)
+       if (params_.display != lyx::graphics::NoDisplay &&
+           loader_.status() == lyx::graphics::WaitingToLoad)
                loader_.startLoading();
 
-       if (params_.display != grfx::NoDisplay && !loader_.monitoring())
+       if (params_.display != lyx::graphics::NoDisplay &&
+           !loader_.monitoring())
                loader_.startMonitoring();
 
        // This will draw the graphics. If the graphics has not been loaded yet,
        // we draw just a rectangle.
 
        if (readyToDisplay()) {
-               pi.pain.image(x + Inset::TEXT_TO_INSET_OFFSET,
+               pi.pain.image(x + InsetOld::TEXT_TO_INSET_OFFSET,
                              y - dim_.asc,
-                             dim_.wid - 2 * Inset::TEXT_TO_INSET_OFFSET,
+                             dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
                              dim_.asc + dim_.des,
                              *loader_.image());
 
        } else {
-               pi.pain.rectangle(x + Inset::TEXT_TO_INSET_OFFSET,
+               pi.pain.rectangle(x + InsetOld::TEXT_TO_INSET_OFFSET,
                                  y - dim_.asc,
-                                 dim_.wid - 2 * Inset::TEXT_TO_INSET_OFFSET,
+                                 dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
                                  dim_.asc + dim_.des);
 
                // Print the file name.
@@ -289,7 +289,7 @@ void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const
 
                if (!justname.empty()) {
                        msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
-                       pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
+                       pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
                                   y - font_metrics::maxAscent(msgFont) - 4,
                                   justname, msgFont);
                }
@@ -298,7 +298,7 @@ void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const
                string const msg = statusMessage();
                if (!msg.empty()) {
                        msgFont.setSize(LyXFont::SIZE_TINY);
-                       pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
+                       pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
                                     y - 4, msg, msgFont);
                }
        }