- // This will draw the graphics. As for now we only draw a
- // placeholder rectangele.
- paint.rectangle(int(x)+2, baseline - ascent(bv, font),
- width(bv, font) - 4,
- ascent(bv, font) + descent(bv, font));
+ int ldescent = descent(bv, font);
+ int lascent = ascent(bv, font);
+ int lwidth = width(bv, font);
+
+ // Make sure x is updated upon exit from this routine
+ int old_x = int(x);
+ x += lwidth;
+
+ // This will draw the graphics. If the graphics has not been loaded yet,
+ // we draw just a rectangle.
+ if (imageLoaded) {
+
+ paint.image(old_x + 2, baseline - lascent,
+ lwidth - 4, lascent + ldescent,
+ cacheHandle->getImage());
+ } else {
+
+ // Get the image status, default to unknown error.
+ GraphicsCacheItem::ImageStatus status = GraphicsCacheItem::UnknownError;
+ if (lyxrc.display_graphics != "no" &&
+ params.display != InsetGraphicsParams::NONE &&
+ cacheHandle.get())
+ status = cacheHandle->getImageStatus();
+
+ // Check if the image is now ready.
+ if (status == GraphicsCacheItem::Loaded) {
+ imageLoaded = true;
+
+ // Tell BufferView we need to be updated!
+ bv->text->status(bv, LyXText::CHANGED_IN_DRAW);
+ return;
+ }
+
+ paint.rectangle(old_x + 2, baseline - lascent,
+ lwidth - 4,
+ lascent + ldescent);
+
+ // Print the file name.
+ LyXFont msgFont(font);
+ msgFont.setFamily(LyXFont::SANS_FAMILY);
+
+ string const justname = OnlyFilename (params.filename);
+ if (!justname.empty()) {
+ msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
+ paint.text(old_x + 8,
+ baseline - lyxfont::maxAscent(msgFont) - 4,
+ justname, msgFont);
+ }
+
+ // Print the message.
+ string const msg = statusMessage();
+ if (!msg.empty()) {
+ msgFont.setSize(LyXFont::SIZE_TINY);
+ paint.text(old_x + 8, baseline - 4, msg, msgFont);
+ }
+ }