]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetgraphics.C
ws changes only
[lyx.git] / src / insets / insetgraphics.C
index db63aaba09893bb1e210c225fb518519efe21c6c..43128342690f21076c3a5ac11d9cf0ae9afff393 100644 (file)
@@ -53,7 +53,7 @@ TODO
 #include <config.h>
 
 #include "insets/insetgraphics.h"
-#include "insets/renderers.h"
+#include "insets/render_graphic.h"
 
 #include "buffer.h"
 #include "BufferView.h"
@@ -66,8 +66,10 @@ TODO
 #include "latexrunparams.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
+#include "metricsinfo.h"
 
 #include "frontends/Alert.h"
+#include "frontends/LyXView.h"
 
 #include "support/filetools.h"
 #include "support/lyxalgo.h" // lyx::count
@@ -152,7 +154,7 @@ string findTargetFormat(string const & suffix, LatexRunParams const & runparams)
 
 InsetGraphics::InsetGraphics()
        : graphic_label(uniqueID()),
-         graphic_(new GraphicRenderer)
+         graphic_(new RenderGraphic)
 {
        graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
 }
@@ -162,7 +164,7 @@ InsetGraphics::InsetGraphics(InsetGraphics const & ig)
        : InsetOld(ig),
          boost::signals::trackable(),
          graphic_label(uniqueID()),
-         graphic_(new GraphicRenderer(*ig.graphic_))
+         graphic_(new RenderGraphic(*ig.graphic_))
 {
        graphic_->connect(boost::bind(&InsetGraphics::statusChanged, this));
        setParams(ig.params());
@@ -181,9 +183,21 @@ InsetGraphics::~InsetGraphics()
 }
 
 
+void InsetGraphics::cache(BufferView * view) const
+{
+       BOOST_ASSERT(view);
+       view_ = view->owner()->view();
+}
+
+BufferView * InsetGraphics::view() const
+{
+       return view_.lock().get();
+}
+
+
 void InsetGraphics::statusChanged() const
 {
-       BufferView * bv = graphic_->view();
+       BufferView * bv = view();
        if (bv)
                bv->updateInset(this);
 }
@@ -213,7 +227,7 @@ dispatch_result InsetGraphics::localDispatch(FuncRequest const & cmd)
                return DISPATCHED;
 
        default:
-               return InsetOld::localDispatch(cmd);
+               return UNDISPATCHED;
        }
 }
 
@@ -227,6 +241,7 @@ void InsetGraphics::metrics(MetricsInfo & mi, Dimension & dim) const
 
 void InsetGraphics::draw(PainterInfo & pi, int x, int y) const
 {
+       cache(pi.base.bv);
        graphic_->draw(pi, x, y);
 }