- BufferView * bv = pi.base.bv;
- // MakeAbsPath returns params().filename unchanged if it absolute
- // already.
- string const file_with_path =
- MakeAbsPath(params().filename, bv->buffer()->filePath());
-
- // A 'paste' operation creates a new inset with the correct filepath,
- // but then the 'old' inset stored in the 'copy' operation is actually
- // added to the buffer.
- // Thus, we should ensure that the filepath is correct.
- if (file_with_path != cache_->loader.filename())
- cache_->update(file_with_path);
-
- cache_->view = bv->owner()->view();
- int oasc = cache_->old_ascent;
-
- Dimension dim;
- MetricsInfo mi;
- mi.base.bv = pi.base.bv;
- mi.base.font = pi.base.font;
- metrics(mi, dim);
- dim_ = dim;
-
- // we may have changed while someone other was drawing us so better
- // to not draw anything as we surely call to redraw ourself soon.
- // This is not a nice thing to do and should be fixed properly somehow.
- // But I still don't know the best way to go. So let's do this like this
- // for now (Jug 20020311)
- if (dim.asc != oasc)
- return;
-
- // Make sure now that x is updated upon exit from this routine
- grfx::Params const & gparams = params().as_grfxParams();
-
- if (gparams.display != grfx::NoDisplay &&
- cache_->loader.status() == grfx::WaitingToLoad)
- cache_->loader.startLoading();
-
- if (!cache_->loader.monitoring())
- cache_->loader.startMonitoring();
-
- // This will draw the graphics. If the graphics has not been loaded yet,
- // we draw just a rectangle.
-
- if (imageIsDrawable()) {
- pi.pain.image(x + TEXT_TO_INSET_OFFSET, y - dim_.asc,
- dim_.wid - 2 * TEXT_TO_INSET_OFFSET, dim_.asc + dim_.des,
- *cache_->loader.image());
-
- } else {
-
- pi.pain.rectangle(x + TEXT_TO_INSET_OFFSET, y - dim_.asc,
- dim_.wid - 2 * TEXT_TO_INSET_OFFSET, dim_.asc + dim_.des);
-
- // Print the file name.
- LyXFont msgFont = pi.base.font;
- msgFont.setFamily(LyXFont::SANS_FAMILY);
- string const justname = OnlyFilename (params().filename);
- if (!justname.empty()) {
- msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
- pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6,
- y - font_metrics::maxAscent(msgFont) - 4,
- justname, msgFont);
- }
-
- // Print the message.
- string const msg = statusMessage();
- if (!msg.empty()) {
- msgFont.setSize(LyXFont::SIZE_TINY);
- pi.pain.text(x + TEXT_TO_INSET_OFFSET + 6, y - 4, msg, msgFont);
- }
- }