People are encouraged to try this one !

Note the horrible hack in updateableinset.C. I have to admit I can't
convince myself of why this works, but it does ... and it has to be
better than all the CID code (which  this patch does *not* remove - the
CID code totals at least another 80 lines)

OK ?

john


Index: insets/insettext.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insettext.C,v
retrieving revision 1.361
diff -u -p -r1.361 insettext.C
--- insets/insettext.C  20 Mar 2003 14:13:48 -0000      1.361
+++ insets/insettext.C  20 Mar 2003 19:41:36 -0000
@@ -360,6 +360,8 @@ void InsetText::draw(BufferView * bv, Ly
                topx_set = true;
                int nw = getMaxWidth(bv, this);
                if (nw > 0 && old_max_width != nw) {
+                       lyxerr << "Darn, CID !" << endl;
+                       lyxerr << "New is " << nw << " old is " << old_max_width << 
endl;
                        need_update = INIT;
                        old_max_width = nw;
                        bv->text->postChangedInDraw();
@@ -495,6 +497,7 @@ void InsetText::update(BufferView * bv, 
                return;
        }
        in_update = true;
+
        if (reinit || need_update == INIT) {
                need_update = FULL;
                // we should put this call where we set need_update to INIT!
@@ -502,6 +505,13 @@ void InsetText::update(BufferView * bv, 
                if (owner())
                        owner()->update(bv, true);
                in_update = false;
+               int nw = getMaxWidth(bv, this);
+               if (nw > 0 && old_max_width != nw) {
+                       need_update |= INIT;
+                       lyxerr << "width changed in update" << endl;
+                       lyxerr << "New is " << nw << " old is " << old_max_width << 
endl;
+                       old_max_width = nw;
+               }
                return;
        }
 
@@ -529,6 +539,14 @@ void InsetText::update(BufferView * bv, 
        if (clear)
                lt = 0;
        in_update = false;
+
+       int nw = getMaxWidth(bv, this);
+       if (nw > 0 && old_max_width != nw) {
+               need_update |= INIT;
+               lyxerr << "width changed in update" << endl;
+               lyxerr << "New is " << nw << " old is " << old_max_width << endl;
+               old_max_width = nw;
+       }
 }
 
 
Index: insets/updatableinset.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/updatableinset.C,v
retrieving revision 1.6
diff -u -p -r1.6 updatableinset.C
--- insets/updatableinset.C     19 Mar 2003 14:45:22 -0000      1.6
+++ insets/updatableinset.C     20 Mar 2003 19:41:36 -0000
@@ -160,9 +160,9 @@ Inset::RESULT UpdatableInset::localDispa
 int UpdatableInset::getMaxWidth(BufferView * bv, UpdatableInset const *) const
 {
        int w;
+
        if (owner()) {
-               w = static_cast<UpdatableInset*>
-                       (owner())->getMaxWidth(bv, this);
+               w = static_cast<UpdatableInset*> (owner())->getMaxWidth(bv, this);
        } else {
                w = bv->text->workWidth(const_cast<UpdatableInset *>(this));
        }
@@ -172,6 +172,14 @@ int UpdatableInset::getMaxWidth(BufferVi
        // check for margins left/right and extra right margin "const 5"
        if ((w - ((2 * TEXT_TO_INSET_OFFSET) + 5)) >= 0)
                w -= (2 * TEXT_TO_INSET_OFFSET) + 5;
+
+       // Deep magic. I don't understand this either.
+       if (owner() && owner()->owner()) {
+               // add the right paper margin
+               w -= 40;
+       }
+
+#if 0
        if (topx_set && owner()) {
                w -= top_x;
                w += owner()->x();
@@ -181,6 +189,7 @@ int UpdatableInset::getMaxWidth(BufferVi
                // least the default margin as top_x
                w -= 20;
        }
+#endif
        if (w < 10) {
                w = 10;
        }

Reply via email to