#include "graphics/GraphicsImage.h"
#include "LyXView.h"
+#include "lyxtext.h"
#include "buffer.h"
#include "BufferView.h"
#include "converter.h"
#include "LaTeXFeatures.h"
#include "frontends/Dialogs.h"
-#include "frontends/Alert.h"
#include "frontends/controllers/helper_funcs.h" // getVectorFromString
#include "support/LAssert.h"
InsetGraphics::InsetGraphics()
: graphic_label(unique_id()),
- cached_status_(grfx::ErrorUnknown), cache_filled_(false)
+ cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0)
{}
: Inset(ig, same_id),
SigC::Object(),
graphic_label(unique_id()),
- cached_status_(grfx::ErrorUnknown), cache_filled_(false)
+ cached_status_(grfx::ErrorUnknown), cache_filled_(false), old_asc(0)
{
setParams(ig.params());
if (same_id)
int InsetGraphics::ascent(BufferView *, LyXFont const &) const
{
+ old_asc = 50;
if (drawImage())
- return cached_image_->getHeight();
- else
- return 50;
+ old_asc = cached_image_->getHeight();
+ return old_asc;
}
void InsetGraphics::draw(BufferView * bv, LyXFont const & font,
int baseline, float & x, bool) const
{
+ int oasc = old_asc;
+
int ldescent = descent(bv, font);
int lascent = ascent(bv, font);
int lwidth = width(bv, font);
+ // 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 (lascent != oasc) {
+// lyxerr << "IG(" << this << "): " << x << endl;
+ return;
+ }
+
// Make sure now that x is updated upon exit from this routine
int old_x = int(x);
x += lwidth;
Painter & paint = bv->painter();
if (drawImage()) {
-
+// lyxerr << "IG(" << this << "): " << old_x << endl;
paint.image(old_x + 2, baseline - lascent,
lwidth - 4, lascent + ldescent,
*cached_image_.get());
- } else {
+ } else {
paint.rectangle(old_x + 2, baseline - lascent,
lwidth - 4,