#include <config.h>
#include "insetexternal.h"
-#include "insets/renderers.h"
#include "insets/ExternalSupport.h"
#include "insets/ExternalTemplate.h"
+#include "insets/render_button.h"
+#include "insets/render_graphic.h"
#include "buffer.h"
#include "BufferView.h"
#include "latexrunparams.h"
#include "lyxlex.h"
#include "lyxrc.h"
+#include "metricsinfo.h"
#include "frontends/lyx_gui.h"
+#include "frontends/LyXView.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
InsetExternal::InsetExternal()
- : renderer_(new ButtonRenderer)
+ : renderer_(new RenderButton)
{}
params_(other.params_),
renderer_(other.renderer_->clone())
{
- GraphicRenderer * ptr =
- dynamic_cast<GraphicRenderer *>(renderer_.get());
+ RenderGraphic * ptr =
+ dynamic_cast<RenderGraphic *>(renderer_.get());
if (ptr)
ptr->connect(boost::bind(&InsetExternal::statusChanged, this));
}
}
-void InsetExternal::statusChanged()
+void InsetExternal::cache(BufferView * view) const
{
- BufferView * const bv = renderer_->view();
+ BOOST_ASSERT(view);
+ view_ = view->owner()->view();
+}
+
+BufferView * InsetExternal::view() const
+{
+ return view_.lock().get();
+}
+
+
+void InsetExternal::statusChanged() const
+{
+ BufferView * const bv = view();
if (bv)
bv->updateInset(this);
}
void InsetExternal::draw(PainterInfo & pi, int x, int y) const
{
+ cache(pi.base.bv);
renderer_->draw(pi, x, y);
}
params_.display == lyx::graphics::NoDisplay);
if (display_button) {
- ButtonRenderer * button_ptr =
- dynamic_cast<ButtonRenderer *>(renderer_.get());
+ RenderButton * button_ptr =
+ dynamic_cast<RenderButton *>(renderer_.get());
if (!button_ptr) {
- button_ptr = new ButtonRenderer;
+ button_ptr = new RenderButton;
renderer_.reset(button_ptr);
}
button_ptr->update(getScreenLabel(params_, buffer), true);
} else {
- GraphicRenderer * graphic_ptr =
- dynamic_cast<GraphicRenderer *>(renderer_.get());
+ RenderGraphic * graphic_ptr =
+ dynamic_cast<RenderGraphic *>(renderer_.get());
if (!graphic_ptr) {
- graphic_ptr = new GraphicRenderer;
+ graphic_ptr = new RenderGraphic;
graphic_ptr->connect(
boost::bind(&InsetExternal::statusChanged, this));
renderer_.reset(graphic_ptr);